org.robokind.api.common.osgi.lifecycle
Class DynamicServiceLauncher<T>

java.lang.Object
  extended by org.robokind.api.common.osgi.lifecycle.DynamicServiceLauncher<T>
Type Parameters:
T - type of the dynamic service to be launched

public class DynamicServiceLauncher<T>
extends Object

Launches and manages a ServiceLifecycleProvider. Creates a ServiceDependencyTracker to drive the service lifecycle from the OSGi Service Registry. The the service lifecycle changes, the DynamicServiceLauncher registers/unregisters the managed service in the OSGi ServiceRegistry.

Author:
Matthew Stevenson

Constructor Summary
DynamicServiceLauncher(org.osgi.framework.BundleContext context, ServiceLifecycleProvider<T> lifecycle)
          Creates a new DynamicServiceLauncher from the given lifecycle provider.
DynamicServiceLauncher(org.osgi.framework.BundleContext context, ServiceLifecycleProvider<T> lifecycle, Properties registrationProps)
          Creates a new DynamicServiceLauncher from the given lifecycle provider.
DynamicServiceLauncher(org.osgi.framework.BundleContext context, ServiceLifecycleProvider<T> lifecycle, String registrationClassName, Properties registrationProps)
          Creates a new DynamicServiceLauncher from the given lifecycle provider.
 
Method Summary
protected  void registerService()
          Registers the dynamic service to the OSGi Service Registry.
 void start()
          Starts the DynamicServiceLauncher.
 void stop()
          Stops tracking dependency changes.
 void unregisterService()
          Unregisters the dynamic service from the OSGi Service Registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicServiceLauncher

public DynamicServiceLauncher(org.osgi.framework.BundleContext context,
                              ServiceLifecycleProvider<T> lifecycle)
Creates a new DynamicServiceLauncher from the given lifecycle provider.

Parameters:
context - BundleContext for accessing the OSGi Service Registry
lifecycle - lifecycle provider for the managed service

DynamicServiceLauncher

public DynamicServiceLauncher(org.osgi.framework.BundleContext context,
                              ServiceLifecycleProvider<T> lifecycle,
                              Properties registrationProps)
Creates a new DynamicServiceLauncher from the given lifecycle provider. Uses the given registration properties when registering the dynamic service to the OSGi Service Registry.

Parameters:
context - BundleContext for accessing the OSGi Service Registry
lifecycle - lifecycle provider for the dynamic service
registrationProps - optional properties to be used when registering the dynamic service to the OSGi Service Registry. These are combined with any properties from the ServiceLifecycleProvider

DynamicServiceLauncher

public DynamicServiceLauncher(org.osgi.framework.BundleContext context,
                              ServiceLifecycleProvider<T> lifecycle,
                              String registrationClassName,
                              Properties registrationProps)
Creates a new DynamicServiceLauncher from the given lifecycle provider. Uses the given registration class name and properties when registering the dynamic service to the OSGi Service Registry.

Parameters:
context - BundleContext for accessing the OSGi Service Registry
lifecycle - lifecycle provider for the dynamic service
registrationProps - optional properties to be used when registering the dynamic service to the OSGi Service Registry. These are combined with any properties from the ServiceLifecycleProvider
registrationClassName - class name to be used when registering the dynamic service to the OSGi Service Registry. By default, this value is taken from the ServiceLifecycleProvider's getServiceClass().
Method Detail

start

public void start()
Starts the DynamicServiceLauncher. Begins tracker dependencies and notifies the lifecycle provider of dependency changes.


stop

public void stop()
Stops tracking dependency changes. Does not modify the existing service or its OSGi registration state.


unregisterService

public void unregisterService()
Unregisters the dynamic service from the OSGi Service Registry.


registerService

protected void registerService()
Registers the dynamic service to the OSGi Service Registry.



Copyright © 2011-2012. All Rights Reserved.