|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.dm.runtime.ServiceLifecycleHandler
public class ServiceLifecycleHandler
Allow Services to configure dynamically their dependency filters from their init() method. Basically, this class acts as a service implementation lifecycle handler. When we detect that the Service is called in its init() method, and if init() returns a Map, then the Map is assumed to contain dependency filters, which will be applied to all named dependencies. The Map optionally returned by Service's init method may contain the following keys:
Dependencies which provide a name attribute will be activated after the init method returns. Other dependencies are injected before the init method.
Example of a Service whose dependency filter is configured from ConfigAdmin:
/** * A Service whose service dependency filter/require attribute may be configured from ConfigAdmin */ @Service class X { private Dictionary m_config; @ConfigurationDependency(pid="MyPid") void configure(Dictionary conf) { // Initialize our service from config ... // And store the config for later usage (from our init method) m_config = config; } @ServiceDependency(name="dependency1") void bindOtherService(OtherService other) { // the filter and required flag will be configured from our init method. } // The returned Map will be used to configure our "dependency1" Dependency. @Init Map init() { return new HashMap() {{ put("dependency1.filter", m_config.get("filter")); put("dependency1.required", m_config.get("required")); }}; } }
Constructor Summary | |
---|---|
ServiceLifecycleHandler(Component srv,
Bundle srvBundle,
DependencyManager dm,
MetaData srvMeta,
Makes a new ServiceLifecycleHandler object. |
Method Summary | |
---|---|
void |
destroy(Component service)
Handles the Service's destroy lifecycle callback. |
void |
init(Component service)
Handles an "init" lifecycle service callback. |
void |
start(Component service)
Handles the Service's start lifecycle callback. |
void |
stop(Component service)
Handles the Service's stop lifecycle callback. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServiceLifecycleHandler(Component srv, Bundle srvBundle, DependencyManager dm, MetaData srvMeta,depMeta)
srv
- The Service for the annotated classsrvBundle
- the Service bundledm
- The DependencyManager that was used to create the servicesrvMeta
- The Service MetaDatadepMeta
- The Dependencies MetaDataMethod Detail |
---|
public void init(Component service) throws Exception
service
- The Annotated Service
Exception
public void start(Component service) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
public void stop(Component service) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
public void destroy(Component service) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |