@Retention(value=CLASS)
@Target(value=METHOD)
public @interface BundleDependency
In the following example, the "SCR" Component allows to track all bundles containing a specific "Service-Component" OSGi header, in order to load and manage all Declarative Service components specified in the SCR xml documents referenced by the header:
@Component public class SCR { @BundleDependency(required = false, removed = "unloadServiceComponents", filter = "(Service-Component=*)", stateMask = Bundle.ACTIVE) void loadServiceComponents(Bundle b) { String descriptorPaths = (String) b.getHeaders().get("Service-Component"); // load all service component specified in the XML descriptorPaths files ... } void unloadServiceComponents(Bundle b) { // unload all service component we loaded from our "loadServiceComponents" method. } }
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
changed
Returns the callback method to be invoked when the bundle have been updated
|
java.lang.String |
filter
Returns the ldap filter dependency matching some bundle manifest headers
|
java.lang.String |
name
The name used when dynamically configuring this dependency from the init method.
|
boolean |
propagate
Specifies if the manifest headers from the bundle should be propagated to the service properties.
|
java.lang.String |
removed
Returns the callback method to invoke when the bundle is lost.
|
boolean |
required
Returns whether the dependency is required or not.
|
int |
stateMask
Returns the bundle state mask
|
public abstract java.lang.String changed
public abstract java.lang.String removed
public abstract boolean required
public abstract java.lang.String filter
public abstract int stateMask
public abstract boolean propagate
public abstract java.lang.String name
filter
and required
flag from the Service's init method.
All unnamed dependencies will be injected before the init() method; so from the init() method, you can
then pick up whatever information needed from already injected (unnamed) dependencies, and configure dynamically
your named dependencies, which will then be calculated once the init() method returns.
See Init
annotation for an example usage of a dependency dynamically configured from the init method.