org.robokind.api.common.osgi.lifecycle
Interface ServiceLifecycleProvider<T>

Type Parameters:
T - type of service managed by this lifecycle provider
All Known Implementing Classes:
AbstractLifecycleProvider

public interface ServiceLifecycleProvider<T>

Manages the state and availability of a service through a Dependency- Injection pattern. A ServiceLifecycleProvider defines the service dependencies as a List of ServiceDependencyDescriptors, which provide a unique String key, dependency class, and dependency filter string. When all of the dependencies are available, the service lifecycle will be started with a call to the start method. This should create the service and make it available through the getService method. Once the service is started, if a dependency is changed or removed, dependencyChanged will be called with the new dependency.

Author:
Matthew Stevenson

Nested Class Summary
static class ServiceLifecycleProvider.Validator
          The Validator is used validate a dependencyId and dependency against a list of DependencyDescriptors.
 
Method Summary
 void dependencyChanged(String dependencyId, Object dependency)
          Called after the service is started and a dependency is changed or removed.
 List<DependencyDescriptor> getDependencyDescriptors()
          Returns a list describing the service dependencies required by this lifecycle provider.
 Properties getRegistrationProperties()
          Returns the properties to be used when register the service managed by this lifecycle provider.
 T getService()
          Returns the service managed by this lifecycle provider.
 Class<T> getServiceClass()
          Returns the Class of the service managed by this lifecycle provider.
 void start(Map<String,Object> dependencyMap)
          Called the first time all dependencies are available.
 

Method Detail

start

void start(Map<String,Object> dependencyMap)
Called the first time all dependencies are available.

Parameters:
dependencyMap - dependencies needed to start the service lifecycle

dependencyChanged

void dependencyChanged(String dependencyId,
                       Object dependency)
Called after the service is started and a dependency is changed or removed. This may result in a new service or null being returned by getService.

Parameters:
dependencyId - dependency id defined in the DependencyDescriptor
dependency - the new dependency, or null if the dependency is no longer available.

getService

T getService()
Returns the service managed by this lifecycle provider. Returns null if the lifecycle has not been started or if the service is unavailable.

Returns:
service the service managed by this lifecycle provider

getDependencyDescriptors

List<DependencyDescriptor> getDependencyDescriptors()
Returns a list describing the service dependencies required by this lifecycle provider.

Returns:
list describing the service dependencies required by this lifecycle provider

getRegistrationProperties

Properties getRegistrationProperties()
Returns the properties to be used when register the service managed by this lifecycle provider. This is intended to be used as the registration properties for the OSGi Service Registry.

Returns:
properties to be used when register the service managed by this lifecycle provider

getServiceClass

Class<T> getServiceClass()
Returns the Class of the service managed by this lifecycle provider.

Returns:
Class of the service managed by this lifecycle provider


Copyright © 2011-2012. All Rights Reserved.