Versions Compared

Key

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

...

The following example shows a basic component, which uses the @Start, @Stop, annotation:

Code Block
/**
 * A ServiceComponent Using lifecyce callbacks
 */
@Service@Component
class X implements Y {
    @ServiceDependency
    void bindOtherService(OtherService other) {
       // Will be injected before we are started (because it's a required dependency).
    }

    @Start
    void publishing() {
        // All required dependencies are injected: initialize our component.
        // Once we return, our Y service will be published in the OSGi registry.
    }

    @Stop
    void unpublished() {
       // We are not registered anymore in the OSGi registry.
    }
}

...