Annotation Type BundleAdapterService
AdapterService,
but instead of adapting a service, they adapt a bundle with a certain set of states (STARTED|INSTALLED|...),
and provide a service on top of it. The bundle adapter will be applied to any bundle that matches the specified bundle state mask and filter conditions, which may match some of the bundle OSGi manifest headers. For each matching bundle an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface and with service properties found from the original bundle OSGi manifest headers plus any extra properties you supply here. If you declare the original bundle as a member it will be injected.
Usage Examples
In the following example, a "VideoPlayer" Service is registered into the OSGi registry each time an active bundle containing a "Video-Path" manifest header is detected:
@BundleAdapterService(filter = "(Video-Path=*)", stateMask = Bundle.ACTIVE, propagate=true)
public class VideoPlayerImpl implements VideoPlayer {
volatile Bundle bundle; // Injected by reflection
void play() {
URL mpegFile = bundle.getEntry(bundle.getHeaders().get("Video-Path"));
// play the video provided by the bundle ...
}
}
- Author:
- Felix Project Team
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSets the static method used to create the BundleAdapterService implementation instance.booleanSpecifies if manifest headers from the bundle should be propagated to the service properties.Property[]Deprecated.Class<?>[]The interface(s) to use when registering adapters.The service scope for the service of this Component.intthe bundle state mask to apply
-
Element Details
-
provides
Class<?>[] providesThe interface(s) to use when registering adapters. By default, the interface(s) directly implemented by the annotated class is (are) used.- Returns:
- the interface(s) to use when registering adapters
- Default:
{}
-
properties
Property[] propertiesDeprecated.you can applyPropertyannotation directly on the component class.Additional properties to use with the service registration- Returns:
- the bundle adapter properties
- Default:
{}
-
filter
String filterThe ldap filter used to match some manifest headers of the adapted bundle.- Returns:
- the bundle adapter filter
-
stateMask
int stateMaskthe bundle state mask to apply- Returns:
- the bundle state mask to apply
- Default:
38
-
propagate
boolean propagateSpecifies if manifest headers from the bundle should be propagated to the service properties. The component service properties take precedence over the propagated bundle manifest headers.- Returns:
- the propagation flag
- Default:
true
-
factoryMethod
String factoryMethodSets the static method used to create the BundleAdapterService implementation instance.- Returns:
- the factory method
- Default:
""
-
scope
ServiceScope scopeThe service scope for the service of this Component.If not specified, the
singletonservice scope is used.- Default:
SINGLETON
-
Propertyannotation directly on the component class.