|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.dm.DependencyManager
public class DependencyManager
The dependency manager manages all components and their dependencies. Using
this API you can declare all components and their dependencies. Under normal
circumstances, you get passed an instance of this class through the
DependencyActivatorBase
subclass you use as your
BundleActivator
, but it is also possible to create your
own instance.
Field Summary | |
---|---|
static String |
ASPECT
|
Constructor Summary | |
---|---|
DependencyManager(BundleContext context)
Creates a new dependency manager. |
Method Summary | |
---|---|
void |
add(Component service)
Adds a new service to the dependency manager. |
Component |
createAdapterService(Class serviceInterface,
String serviceFilter)
Creates a new adapter. |
Component |
createAspectService(Class serviceInterface,
String serviceFilter,
int ranking,
String attributeName)
Creates a new aspect. |
Component |
createBundleAdapterService(int bundleStateMask,
String bundleFilter,
boolean propagate)
Creates a new bundle adapter. |
BundleDependency |
createBundleDependency()
Creates a new bundle dependency. |
Component |
createComponent()
Creates a new service. |
ConfigurationDependency |
createConfigurationDependency()
Creates a new configuration dependency. |
Component |
createFactoryConfigurationAdapterService(String factoryPid,
String update,
boolean propagate)
Creates a new Managed Service Factory Configuration Adapter. |
Component |
createFactoryConfigurationAdapterService(String factoryPid,
String update,
boolean propagate,
String heading,
String desc,
String localization,
PropertyMetaData[] propertiesMetaData)
Creates a new Managed Service Factory Configuration Adapter with meta type support. |
PropertyMetaData |
createPropertyMetaData()
Creates a new configuration property metadata. |
Component |
createResourceAdapterService(String resourceFilter,
boolean propagate,
Object callbackInstance,
String callbackChanged)
Creates a new resource adapter. |
Component |
createResourceAdapterService(String resourceFilter,
Object propagateCallbackInstance,
String propagateCallbackMethod,
Object callbackInstance,
String callbackChanged)
|
ResourceDependency |
createResourceDependency()
Creates a new resource dependency. |
ServiceDependency |
createServiceDependency()
Creates a new service dependency. |
TemporalServiceDependency |
createTemporalServiceDependency()
Creates a new temporal service dependency. |
List |
getServices()
Returns a list of services. |
void |
remove(Component service)
Removes a service from the dependency manager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ASPECT
Constructor Detail |
---|
public DependencyManager(BundleContext context)
BundleContext
to be used by the dependency
manager to register services and communicate with the
framework.
context
- the bundle contextMethod Detail |
---|
public void add(Component service)
service
- the service to addpublic void remove(Component service)
service
- the service to removepublic Component createComponent()
public ServiceDependency createServiceDependency()
public TemporalServiceDependency createTemporalServiceDependency()
public ConfigurationDependency createConfigurationDependency()
public PropertyMetaData createPropertyMetaData()
public BundleDependency createBundleDependency()
public ResourceDependency createResourceDependency()
public Component createAspectService(Class serviceInterface, String serviceFilter, int ranking, String attributeName)
manager.createAspectService(ExistingService.class, "(foo=bar)", 10, "m_aspect") .setImplementation(ExistingServiceAspect.class) .setServiceProperties(new Hashtable() {{ put("additional", "properties"); }});
serviceInterface
- the service interface to apply the aspect toserviceFilter
- the filter condition to use with the service interfaceranking
- the level used to organize the aspect chain orderingattributeName
- the aspect implementation field name where to inject original service.
If null, any field matching the original service will be injected.
public Component createAdapterService(Class serviceInterface, String serviceFilter)
manager.createAdapterService(AdapteeService.class, "(foo=bar)") // The interface to use when registering adapter .setInterface(AdapterService.class, new Hashtable() {{ put("additional", "properties"); }}) // the implementation of the adapter .setImplementation(AdapterImpl.class);
serviceInterface
- the service interface to apply the adapter toserviceFilter
- the filter condition to use with the service interface
public Component createResourceAdapterService(String resourceFilter, boolean propagate, Object callbackInstance, String callbackChanged)
manager.createResourceAdapterService("(&(path=/test)(repository=TestRepository))", true) // The interface to use when registering adapter .setInterface(AdapterService.class.getName(), new Hashtable() {{ put("foo", "bar"); }}) // the implementation of the adapter .setImplementation(AdapterServiceImpl.class);
resourceFilter
- the filter condition to use with the resourcepropagate
- true
if properties from the resource should be propagated to the servicecallbackInstance
- callbackChanged
-
Resource
public Component createResourceAdapterService(String resourceFilter, Object propagateCallbackInstance, String propagateCallbackMethod, Object callbackInstance, String callbackChanged)
public Component createBundleAdapterService(int bundleStateMask, String bundleFilter, boolean propagate)
manager.createBundleAdapterService(Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE, "(Bundle-SymbolicName=org.apache.felix.dependencymanager)", true) // The interface to use when registering adapter .setInterface(AdapterService.class.getName(), new Hashtable() {{ put("foo", "bar"); }}) // the implementation of the adapter .setImplementation(AdapterServiceImpl.class);
bundleStateMask
- the bundle state mask to applybundleFilter
- the filter to apply to the bundle manifestpropagate
- true
if properties from the bundle should be propagated to the service
public Component createFactoryConfigurationAdapterService(String factoryPid, String update, boolean propagate)
propagate
parameter, every public factory configuration properties
(which don't start with ".") will be propagated along with the adapter service properties.
It will also inherit all dependencies.
manager.createFactoryConfigurationAdapterService("MyFactoryPid", "update", true) // The interface to use when registering adapter .setInterface(AdapterService.class.getName(), new Hashtable() {{ put("foo", "bar"); }}) // the implementation of the adapter .setImplementation(AdapterServiceImpl.class);
factoryPid
- the pid matching the factory configurationupdate
- the adapter method name that will be notified when the factory configuration is created/updated.propagate
- true if public factory configuration should be propagated to the adapter service properties
public Component createFactoryConfigurationAdapterService(String factoryPid, String update, boolean propagate, String heading, String desc, String localization, PropertyMetaData[] propertiesMetaData)
propagate
parameter, every public factory configuration properties
(which don't start with ".") will be propagated along with the adapter service properties.
It will also inherit all dependencies.
PropertyMetaData[] propertiesMetaData = new PropertyMetaData[] { manager.createPropertyMetaData() .setCardinality(Integer.MAX_VALUE) .setType(String.class) .setHeading("English words") .setDescription("Declare here some valid english words") .setDefaults(new String[] {"hello", "world"}) .setId("words") }; manager.add(createFactoryConfigurationAdapterService("FactoryPid", "updated", true, // propagate CM settings "EnglishDictionary", "English dictionary configuration properties", null, propertiesMetaData) .setImplementation(Adapter.class));
factoryPid
- the pid matching the factory configurationupdate
- the adapter method name that will be notified when the factory configuration is created/updated.propagate
- true if public factory configuration should be propagated to the adapter service propertiesheading
- The label used to display the tab name (or section) where the properties are displayed.
Example: "Printer Service"desc
- A human readable description of the factory PID this configuration is associated with.
Example: "Configuration for the PrinterService bundle"localization
- Points to the basename of the Properties file that can localize the Meta Type informations.
The default localization base name for the properties is OSGI-INF/l10n/bundle, but can
be overridden by the manifest Bundle-Localization header (see core specification, in section Localization
on page 68). You can specify a specific localization basename file using this parameter
(e.g. "person"
will match person_du_NL.properties in the root bundle directory).propertiesMetaData
- Array of MetaData regarding configuration properties
public List getServices()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |