org.robokind.api.common.lifecycle.utils
Class SimpleLifecycle<T>

java.lang.Object
  extended by org.robokind.api.common.lifecycle.utils.SimpleLifecycle<T>
All Implemented Interfaces:
ServiceLifecycleProvider<T>, PropertyChangeSource

public class SimpleLifecycle<T>
extends Object
implements ServiceLifecycleProvider<T>

Defines an empty lifecycle for managing a service with no dependencies.

Author:
Matthew Stevenson

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.robokind.api.common.lifecycle.ServiceLifecycleProvider
ServiceLifecycleProvider.Validator
 
Field Summary
 
Fields inherited from interface org.robokind.api.common.lifecycle.ServiceLifecycleProvider
PROP_DEPENDENCY_ADDED, PROP_DEPENDENCY_REMOVED
 
Constructor Summary
SimpleLifecycle(T service, Class<T> clazz)
          Creates a SimpleLifecycle for the given service.
SimpleLifecycle(T service, Class<T> clazz, Properties props)
          Creates a SimpleLifecycle for the given service.
SimpleLifecycle(T service, Class<T> clazz, String idKey, String idStr, Properties props)
           
SimpleLifecycle(T service, String className)
          Creates a SimpleLifecycle for the given service.
SimpleLifecycle(T service, String[] serviceClassNames, Properties props)
           
SimpleLifecycle(T service, String[] serviceClassNames, String idKey, String idStr, Properties props)
           
SimpleLifecycle(T service, String className, Properties props)
          Creates a SimpleLifecycle for the given service.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          A SimpleLifecycle has no dependencies and does not fire events.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          A SimpleLifecycle has no dependencies and does not fire events.
 void dependencyChanged(String dependencyId, Object dependency, Map<String,Object> dependencies)
          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.
 String[] getServiceClassNames()
          Returns the names of the interfaces this service implements and makes available.
 void removePropertyChangeListener(PropertyChangeListener listener)
          A SimpleLifecycle has no dependencies and does not fire events.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          A SimpleLifecycle has no dependencies and does not fire events.
 void start(Map<String,Object> dependencyMap)
          Called the first time all dependencies are available.
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLifecycle

public SimpleLifecycle(T service,
                       Class<T> clazz)
Creates a SimpleLifecycle for the given service.

Parameters:
service - service for the lifecycle to handle
clazz - class the service should be available as

SimpleLifecycle

public SimpleLifecycle(T service,
                       String className)
Creates a SimpleLifecycle for the given service.

Parameters:
service - service for the lifecycle to handle
className - class the service should be available as

SimpleLifecycle

public SimpleLifecycle(T service,
                       Class<T> clazz,
                       Properties props)
Creates a SimpleLifecycle for the given service.

Parameters:
service - service for the lifecycle to handle
clazz - class the service should be available as
props - Properties to use when registering the service

SimpleLifecycle

public SimpleLifecycle(T service,
                       Class<T> clazz,
                       String idKey,
                       String idStr,
                       Properties props)

SimpleLifecycle

public SimpleLifecycle(T service,
                       String className,
                       Properties props)
Creates a SimpleLifecycle for the given service.

Parameters:
service - service for the lifecycle to handle
className - class the service should be available as
props - Properties to use when registering the service

SimpleLifecycle

public SimpleLifecycle(T service,
                       String[] serviceClassNames,
                       String idKey,
                       String idStr,
                       Properties props)

SimpleLifecycle

public SimpleLifecycle(T service,
                       String[] serviceClassNames,
                       Properties props)
Method Detail

start

public void start(Map<String,Object> dependencyMap)
Description copied from interface: ServiceLifecycleProvider
Called the first time all dependencies are available.

Specified by:
start in interface ServiceLifecycleProvider<T>
Parameters:
dependencyMap - dependencies needed to start the service lifecycle

stop

public void stop()
Specified by:
stop in interface ServiceLifecycleProvider<T>

dependencyChanged

public void dependencyChanged(String dependencyId,
                              Object dependency,
                              Map<String,Object> dependencies)
Description copied from interface: ServiceLifecycleProvider
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.

Specified by:
dependencyChanged in interface ServiceLifecycleProvider<T>
Parameters:
dependencyId - dependency id defined in the DependencyDescriptor
dependency - the new dependency, or null if the dependency is no longer available.

getService

public T getService()
Description copied from interface: ServiceLifecycleProvider
Returns the service managed by this lifecycle provider. Returns null if the lifecycle has not been started or if the service is unavailable.

Specified by:
getService in interface ServiceLifecycleProvider<T>
Returns:
service the service managed by this lifecycle provider

getDependencyDescriptors

public List<DependencyDescriptor> getDependencyDescriptors()
Description copied from interface: ServiceLifecycleProvider
Returns a list describing the service dependencies required by this lifecycle provider.

Specified by:
getDependencyDescriptors in interface ServiceLifecycleProvider<T>
Returns:
list describing the service dependencies required by this lifecycle provider

getRegistrationProperties

public Properties getRegistrationProperties()
Description copied from interface: ServiceLifecycleProvider
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.

Specified by:
getRegistrationProperties in interface ServiceLifecycleProvider<T>
Returns:
properties to be used when register the service managed by this lifecycle provider

getServiceClassNames

public String[] getServiceClassNames()
Description copied from interface: ServiceLifecycleProvider
Returns the names of the interfaces this service implements and makes available.

Specified by:
getServiceClassNames in interface ServiceLifecycleProvider<T>
Returns:
names of the interfaces this service implements and makes available

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
A SimpleLifecycle has no dependencies and does not fire events. Listeners are unused.

Specified by:
addPropertyChangeListener in interface PropertyChangeSource
Parameters:
listener -

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
A SimpleLifecycle has no dependencies and does not fire events. Listeners are unused.

Specified by:
removePropertyChangeListener in interface PropertyChangeSource
Parameters:
listener -

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
A SimpleLifecycle has no dependencies and does not fire events. Listeners are unused.

Specified by:
addPropertyChangeListener in interface PropertyChangeSource
Parameters:
propertyName -
listener -

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
A SimpleLifecycle has no dependencies and does not fire events. Listeners are unused.

Specified by:
removePropertyChangeListener in interface PropertyChangeSource
Parameters:
propertyName -
listener -


Copyright © 2011-2013. All Rights Reserved.