at.ac.tuwien.infosys.sm4all.copal.api.osgi
Class GenericActivator

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.osgi.GenericActivator
All Implemented Interfaces:
DependencyTrackerCustomizer, org.osgi.framework.BundleActivator
Direct Known Subclasses:
BaseConfiguration, BaseProcessor, BasePublisher, ContextEventTypeRegistryTracker, ContextProcessorRegistryTracker, ContextPublisherRegistryTracker, ContextQueryFactoryTracker, ContextSecurityManagerImpl, ContextStateImpl, DeadLetterChannelImpl, DeadLetterListener, EsperPublishing, NotifiersActivator, Tracker

public abstract class GenericActivator
extends java.lang.Object
implements org.osgi.framework.BundleActivator, DependencyTrackerCustomizer

Abstract class to define OSGi BundleActivators for services which depend on multiple other services to be registered and running in OSGi.

Author:
sanjin

Constructor Summary
protected GenericActivator(java.lang.String... dependencies)
          Creates instance of OSGi Activator for some service that depends on multiple other services to be registered and running with OSGi.
 
Method Summary
 java.lang.Object addingService(java.lang.String dependencyName, org.osgi.framework.ServiceReference reference)
          A dependency is being added to the DependencyTracker.
protected
<T> T
getDependency(java.lang.String name)
          Returns the dependency with specified name.
 void modifiedService(java.lang.String dependencyName, org.osgi.framework.ServiceReference reference, java.lang.Object service)
          A service tracked by the DependencyTracker has been modified.
protected  boolean register(java.lang.Class<?> klass, java.lang.Object service)
          Register given service.
protected  boolean register(java.lang.Class<?> klass, java.lang.Object service, java.util.Dictionary<?,?> properties)
          Register given service.
 void removedService(java.lang.String dependencyName, org.osgi.framework.ServiceReference reference, java.lang.Object service)
          A service tracked by the DependencyTracker has been removed.
protected abstract  void start()
          Called when all dependencies are met.
 void start(org.osgi.framework.BundleContext bundleContext)
           
protected abstract  void stop()
          Called when start() was previously called and one of the dependencies has been unregistered.
 void stop(org.osgi.framework.BundleContext bundleContext)
           
protected  boolean unregister(java.lang.Class<?> klass)
          Unregister given service registered using given klass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericActivator

protected GenericActivator(java.lang.String... dependencies)
Creates instance of OSGi Activator for some service that depends on multiple other services to be registered and running with OSGi.

Parameters:
dependencies - the names of dependent services.
Method Detail

start

protected abstract void start()
Called when all dependencies are met.


stop

protected abstract void stop()
Called when start() was previously called and one of the dependencies has been unregistered.


start

public void start(org.osgi.framework.BundleContext bundleContext)
Specified by:
start in interface org.osgi.framework.BundleActivator

stop

public void stop(org.osgi.framework.BundleContext bundleContext)
Specified by:
stop in interface org.osgi.framework.BundleActivator

addingService

public java.lang.Object addingService(java.lang.String dependencyName,
                                      org.osgi.framework.ServiceReference reference)
Description copied from interface: DependencyTrackerCustomizer
A dependency is being added to the DependencyTracker.

Specified by:
addingService in interface DependencyTrackerCustomizer
Parameters:
dependencyName - the name of the added dependency.
reference - a dependency is being added to the DependencyTracker.
Returns:
the dependency object to be tracked for the specified referenced service or null if the specified referenced service should not be tracked.

modifiedService

public void modifiedService(java.lang.String dependencyName,
                            org.osgi.framework.ServiceReference reference,
                            java.lang.Object service)
Description copied from interface: DependencyTrackerCustomizer
A service tracked by the DependencyTracker has been modified.

Specified by:
modifiedService in interface DependencyTrackerCustomizer
Parameters:
dependencyName - the name of the modified dependency.
reference - the reference to the service that has been modified.
service - the service object for the specified referenced service.

removedService

public void removedService(java.lang.String dependencyName,
                           org.osgi.framework.ServiceReference reference,
                           java.lang.Object service)
Description copied from interface: DependencyTrackerCustomizer
A service tracked by the DependencyTracker has been removed.

Specified by:
removedService in interface DependencyTrackerCustomizer
Parameters:
dependencyName - the name of the removed dependency.
reference - the reference to the service that has been removed.
service - the service object for the specified referenced service.

getDependency

protected <T> T getDependency(java.lang.String name)
Returns the dependency with specified name.

Type Parameters:
T - the type of returned dependency.
Parameters:
name - the name of the dependency.
Returns:
the dependency if it is registered; null otherwise.

register

protected boolean register(java.lang.Class<?> klass,
                           java.lang.Object service)
Register given service. If any other service has been previously registered using same klass, that service will be first unregistered and then will the given one be registered.

Parameters:
klass - Class under which service will be registered (using Class.getName() method to determine name).
service - instance of service.
Returns:
true if service has been successfully registered; false otherwise.

register

protected boolean register(java.lang.Class<?> klass,
                           java.lang.Object service,
                           java.util.Dictionary<?,?> properties)
Register given service. If any other service has been previously registered using same klass, that service will be first unregistered and then will the given one be registered.

Parameters:
klass - Class under which service will be registered (using Class.getName() method to determine name).
service - instance of service.
properties - the properties for this service.
Returns:
true if service has been successfully registered; false otherwise.

unregister

protected boolean unregister(java.lang.Class<?> klass)
Unregister given service registered using given klass.

Parameters:
klass - Class under which service has been registered.
Returns:
true if service has been previously registered; false otherwise.


Copyright © 2010 Distributed Systems Group, Vienna University of Technology. All Rights Reserved.