Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Wait for all required dependencies to be available. When all required dependencies are available:
    • Instantiate the component.
    • Inject all required dependencies (on class fields using reflection, or by invoking callback methods).
    • Inject all optional dependencies defined on class fields, possibly with a NullObject if the dependency is not available.
    • Call the component init method (annotated with @Init). In the Init method, you are yet allowed to add some additional dependencies (but using the API). Alternatively, you can also configure some dependencies dynamically (explained later, in #Dynamic Dependency Configuration).
  2. Wait for extra dependencies eventually configured from the init() method.
  3. If the component is not using the @LifecycleController annotation (detailed in the #Controlling the Lifecycle section), then:
    • Invoke the component start method (annotated with @Start).
    • Publish eventual OSGi services (if the component provides some services).
    • Start tracking optional dependencies applied on method callbacks (useful for the whiteboard pattern).
  4. Else do nothing because  the component will trigger itself the startup using the lifecycle controller.

...

  1. If the bundle is stopped or if some required dependencies are unavailable, or if the component is deactivated by a factorySet, then:
    • Unbind eventual optional dependencies (defined on callback methods). Notice that any optional dependency unavailability does not trigger the component deactivation:  the removed callbacks are just invoked, if declared in the annotation.
    • Invoke the stop method (annotated wit @Stop), and unregister eventual OSGi services (if the components provides some services).
    • invoke destroy method (annotated with @Destroy).
    • invoke removed
    dependency
    • callbacks for required dependencies, if any.

Example

The following example show a basic service, which uses the @Start, @Stop, annotation:

...