org.apache.felix.dependencymanager
Class DependencyActivatorBase

java.lang.Object
  extended by org.apache.felix.dependencymanager.DependencyActivatorBase
All Implemented Interfaces:
org.osgi.framework.BundleActivator

public abstract class DependencyActivatorBase
extends Object
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 Summary
DependencyActivatorBase()
           
 
Method Summary
 ConfigurationDependency createConfigurationDependency()
          Creates a new configuration dependency.
 Service createService()
          Creates a new service.
 ServiceDependency createServiceDependency()
          Creates a new service dependency.
abstract  void destroy(org.osgi.framework.BundleContext context, DependencyManager manager)
          Destroy the dependency manager.
abstract  void init(org.osgi.framework.BundleContext context, DependencyManager manager)
          Initialize the dependency manager.
 void start(org.osgi.framework.BundleContext context)
          Start method of the bundle activator.
 void stop(org.osgi.framework.BundleContext context)
          Stop method of the bundle activator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyActivatorBase

public DependencyActivatorBase()
Method Detail

init

public abstract void init(org.osgi.framework.BundleContext context,
                          DependencyManager manager)
                   throws Exception
Initialize the dependency manager. Here you can add all services 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 abstract void destroy(org.osgi.framework.BundleContext context,
                             DependencyManager manager)
                      throws Exception
Destroy the dependency manager. Here you can remove all services 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

createService

public Service createService()
Creates a new service.

Returns:
the new service

createServiceDependency

public ServiceDependency createServiceDependency()
Creates a new service dependency.

Returns:
the service dependency

createConfigurationDependency

public ConfigurationDependency createConfigurationDependency()
Creates a new configuration dependency.

Returns:
the configuration dependency


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.