OSGi Bundle Activators

In OSGi, all service implementations are packaged into bundles. You include a bundle activator to manage the lifecycle of the bundle. You create the bundle activator implementation and add the activator implementation to the bundle's JAR file. A bundle activator is a Java class that implements the org.osgi.framework.BundleActivator interface and is instantiated when the bundle is started. The activator class is the bundle's hook to the lifecycle layer for management.

By implementing the BundleActivator interface, the OSGi framework invokes the start() and stop() methods to initialize or shutdown bundle functionality. The OSGi container calls the implemented start() and stop() methods when the bundle is started and stopped. The start() method registers the component in the registry for another bundle to use.

You also get a BundleContext, which allows the API to communicate with the container. All access to the OSGi framework is through the bundle context object supplied to the bundle activator. Bundles register services or start processes using the lifecycle methods, start(BundleContext) and stop(BundleContext).

你可能感兴趣的:(Access,osgi)