Class DependencyActivatorBase

All Implemented Interfaces:
org.osgi.framework.BundleActivator

public abstract class DependencyActivatorBase extends DependencyActivatorBaseCompat implements org.osgi.framework.BundleActivator
Base bundle activator class. Subclass this activator if you want to use dependency management in your bundle. There are two methods you should implement: init() and destroy(). Both methods take two arguments, the bundle context and the dependency manager. The dependency manager can be used to define all the dependencies.
Author:
Felix Project Team
  • Constructor Details

    • DependencyActivatorBase

      public DependencyActivatorBase()
  • Method Details

    • init

      public abstract void init(org.osgi.framework.BundleContext context, DependencyManager manager) throws Exception
      Initialize the dependency manager. Here you can add all components and their dependencies. If something goes wrong and you do not want your bundle to be started, you can throw an exception. This exception will be passed on to the start() method of the bundle activator, causing the bundle not to start.
      Parameters:
      context - the bundle context
      manager - the dependency manager
      Throws:
      Exception - if the initialization fails
    • destroy

      public void destroy(org.osgi.framework.BundleContext context, DependencyManager manager) throws Exception
      Destroy the dependency manager. Here you can remove all components and their dependencies. Actually, the base class will clean up your dependencies anyway, so most of the time you don't need to do anything here.

      If something goes wrong and you do not want your bundle to be stopped, you can throw an exception. This exception will be passed on to the stop() method of the bundle activator, causing the bundle not to stop.

      Parameters:
      context - the bundle context
      manager - the dependency manager
      Throws:
      Exception - if the destruction fails
    • start

      public void start(org.osgi.framework.BundleContext context) throws Exception
      Start method of the bundle activator. Initializes the dependency manager and calls init().
      Specified by:
      start in interface org.osgi.framework.BundleActivator
      Parameters:
      context - the bundle context
      Throws:
      Exception
    • stop

      public void stop(org.osgi.framework.BundleContext context) throws Exception
      Stop method of the bundle activator. Calls the destroy() method and cleans up all left over dependencies.
      Specified by:
      stop in interface org.osgi.framework.BundleActivator
      Parameters:
      context - the bundle context
      Throws:
      Exception
    • getBundleContext

      public org.osgi.framework.BundleContext getBundleContext()
      Returns the bundle context that is associated with this bundle.
      Returns:
      the bundle context
    • getDependencyManager

      public DependencyManager getDependencyManager()
      Returns the dependency manager that is associated with this bundle.
      Returns:
      the dependency manager
    • getLogger

      public Logger getLogger()
      Returns the logger that is associated with this bundle. A logger instance is a proxy that will log to a real OSGi logservice if available and standard out if not.
      Returns:
      the logger
    • createComponent

      public Component createComponent()
      Creates a new component.
      Returns:
      the new component
    • createBundleComponent

      public BundleComponent createBundleComponent()
      Creates a new bundle adapter component.
      Returns:
      the bundle adapter component
    • createAspectComponent

      public AspectComponent createAspectComponent()
      Creates a new aspect component.
      Returns:
      the aspect component
      See Also:
    • createAdapterComponent

      public AdapterComponent createAdapterComponent()
      Creates a new adapter service.
      Returns:
      the adapter service
      See Also:
    • createFactoryComponent

      public FactoryComponent createFactoryComponent()
      Creates a new factory configuration component.
      Returns:
      the factory configuration component
      See Also:
    • createServiceDependency

      public ServiceDependency createServiceDependency()
      Creates a new service dependency.
      Returns:
      the service dependency
    • createTemporalServiceDependency

      public ServiceDependency createTemporalServiceDependency(long timeout)
      Creates a new temporal service dependency.
      Parameters:
      timeout - the max number of milliseconds to wait for a service availability.
      Returns:
      the service dependency
    • createConfigurationDependency

      public ConfigurationDependency createConfigurationDependency()
      Creates a new configuration dependency.
      Returns:
      the configuration dependency
    • createPropertyMetaData

      public PropertyMetaData createPropertyMetaData()
      Creates a new configuration property metadata.
      Returns:
      the configuration property metadata
    • createBundleDependency

      public BundleDependency createBundleDependency()
      Creates a new bundle dependency.
      Returns:
      the bundle dependency
    • createResourceDependency

      public ResourceDependency createResourceDependency()
      Creates a new resource dependency.
      Returns:
      the resource dependency
    • createResourceComponent

      public ResourceComponent createResourceComponent()
      Creates a new resource adapter component.
      Returns:
      the resource adapter component