Created

Jan 29, 2013

OSGI Activate & Deactivate signatures

Posted by Nicolas Peltier

it's sometimes a bit confusing which signature to use for activate or deactivate in an OSGI component. This is because you have the choice, and this is nice :-) 

As long as you add the @Activate and @Deactivate tag before your methods, you can have zero, one or several arguments among following types (that will be automatically bound at component activation/deactivation): 

Activation

  • ComponentContext - the Component Context for the component
  • BundleContext - the Bundle Context of the component's bundle
  • Map - the Component Properties from ComponentContext.getProperties.     

Deactivation:     

  • int/Integer - the deactivation reason
  • ComponentContext - the Component Context for the component
  • BundleContext - the Bundle Context of the component's bundle
  • Map - the Component Properties from ComponentContext.getProperties.

For more information on this, you can look at the dedicated Apache Felix JIRA