org.apache.felix.dm.annotation.api
Annotation Type BundleAdapterService


@Retention(value=CLASS)
@Target(value=TYPE)
public @interface BundleAdapterService

Annotates a bundle adapter service class. Bundle adapters are similar to 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 {
     Bundle bundle; // Injected by reflection
     
     void play() {
         URL mpegFile = bundle.getEntry(bundle.getHeaders().get("Video-Path"));
         // play the video provided by the bundle ...
     }
     
     void stop() {}
 }
 


Required Element Summary
 String filter
          The filter used to match a given bundle.
 
Optional Element Summary
 String factoryMethod
          Sets the static method used to create the BundleAdapterService implementation instance.
 boolean propagate
          Specifies if manifest headers from the bundle should be propagated to the service properties.
 Property[] properties
          Additional properties to use with the service registration
 Class<?>[] provides
          The interface(s) to use when registering adapters.
 int stateMask
          the bundle state mask to apply
 

Element Detail

filter

public abstract String filter
The filter used to match a given bundle.

provides

public abstract Class<?>[] provides
The interface(s) to use when registering adapters. By default, the interface(s) directly implemented by the annotated class is (are) used.

Default:
{}

properties

public abstract Property[] properties
Additional properties to use with the service registration

Default:
{}

stateMask

public abstract int stateMask
the bundle state mask to apply

Default:
38

propagate

public abstract boolean propagate
Specifies if manifest headers from the bundle should be propagated to the service properties.

Default:
true

factoryMethod

public abstract String factoryMethod
Sets the static method used to create the BundleAdapterService implementation instance.

Default:
""


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.