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


@Retention(value=CLASS)
@Target(value=METHOD)
public @interface Start

Annotates a method which will be invoked when the component is started. The annotated method is invoked juste before registering the service into the OSGi registry (if the service provides an interface). Notice that the start method may optionally return a Map which will be propagated to the provided service properties.

Service activation/deactivation can be programatically controlled using LifecycleController.

Usage Examples

 @Component(properties={@Property(name="foo", value="bar")})
 class X implements Z {
     @ServiceDependency
     OtherService m_dependency;
   
     @Start
     Map start() {
         // Our Z Service is ready (all required dependencies have been satisfied), and is about to be 
         // registered into the OSGi registry. We return here an optional Map containing some extra-properties
         // which will be appended to the properties supplied in the Component annotation.
         return new HashMap() {{ put("foo2", "bar2"); }};
     }
 }
 



Copyright © 2013 The Apache Software Foundation. All Rights Reserved.