com.eurotech.framework.core.configuration
Class ConfigurationServiceImpl

java.lang.Object
  extended by com.eurotech.framework.core.configuration.ConfigurationServiceImpl
All Implemented Interfaces:
ConfigurationService, org.osgi.service.cm.ConfigurationListener

public class ConfigurationServiceImpl
extends Object
implements ConfigurationService, org.osgi.service.cm.ConfigurationListener

Implementation of ConfigurationService.


Constructor Summary
ConfigurationServiceImpl()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext componentContext)
           
 void configurationEvent(org.osgi.service.cm.ConfigurationEvent event)
           
protected  void deactivate(org.osgi.service.component.ComponentContext componentContext)
           
 ComponentConfiguration getComponentConfiguration(String pid)
          Returns the ComponentConfiguration for the component identified with specified PID (service's persistent identity).
 List<ComponentConfiguration> getComponentConfigurations()
          Returns the list of ConfigurableComponents currently registered with the ConfigurationService.
 Set<String> getConfigurableComponentPids()
          Return the PIDs (service's persistent identity) for all the services that implements the ConfigurableComponent Maker interface and registered themselves with the container.
 List<ComponentConfiguration> getSnapshot(long sid)
          Loads a snapshot given its ID and return the component configurations stored in that snapshot.
 Set<Long> getSnapshots()
          Returns the ID of all the snapshots taken by the ConfigurationService.
 boolean hasConfigurableComponent(String pid)
           
 long rollback()
          Rolls back to the last saved snapshot if available.
 void rollback(long id)
          Rolls back to the specified snapshot id.
 void setConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)
           
 void setMetaTypeService(org.osgi.service.metatype.MetaTypeService metaTypeService)
           
 void setSystemService(SystemService systemService)
           
 long snapshot()
          Takes a new snapshot of the current configuration of all the registered ConfigurableCompoenents.
 void unsetConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)
           
 void unsetMetaTypeService(org.osgi.service.metatype.MetaTypeService metaTypeService)
           
 void unsetSystemService(SystemService systemService)
           
 void updateConfiguration(String pidToUpdate, Map<String,Object> propertiesToUpdate)
          Updates the Configuration of the registered component with the specified pid.
 void updateConfigurations(List<ComponentConfiguration> configsToUpdate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationServiceImpl

public ConfigurationServiceImpl()
Method Detail

setConfigurationAdmin

public void setConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)

unsetConfigurationAdmin

public void unsetConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)

setMetaTypeService

public void setMetaTypeService(org.osgi.service.metatype.MetaTypeService metaTypeService)

unsetMetaTypeService

public void unsetMetaTypeService(org.osgi.service.metatype.MetaTypeService metaTypeService)

setSystemService

public void setSystemService(SystemService systemService)

unsetSystemService

public void unsetSystemService(SystemService systemService)

activate

protected void activate(org.osgi.service.component.ComponentContext componentContext)
                 throws org.osgi.framework.InvalidSyntaxException
Throws:
org.osgi.framework.InvalidSyntaxException

deactivate

protected void deactivate(org.osgi.service.component.ComponentContext componentContext)

configurationEvent

public void configurationEvent(org.osgi.service.cm.ConfigurationEvent event)
Specified by:
configurationEvent in interface org.osgi.service.cm.ConfigurationListener

hasConfigurableComponent

public boolean hasConfigurableComponent(String pid)

getConfigurableComponentPids

public Set<String> getConfigurableComponentPids()
Description copied from interface: ConfigurationService
Return the PIDs (service's persistent identity) for all the services that implements the ConfigurableComponent Maker interface and registered themselves with the container. The service's persistent identity is defined as the name attribute of the Component Descriptor XML file; at runtime, the same value is also available in the component.name and in the service.pid attributes of the Component Configuration.

Specified by:
getConfigurableComponentPids in interface ConfigurationService
Returns:
list of PIDs for registered ConfigurableComponents

getComponentConfigurations

public List<ComponentConfiguration> getComponentConfigurations()
                                                        throws EsfException
Description copied from interface: ConfigurationService
Returns the list of ConfigurableComponents currently registered with the ConfigurationService.

Specified by:
getComponentConfigurations in interface ConfigurationService
Returns:
list of registered ConfigurableComponents
Throws:
EsfException

getComponentConfiguration

public ComponentConfiguration getComponentConfiguration(String pid)
                                                 throws EsfException
Description copied from interface: ConfigurationService
Returns the ComponentConfiguration for the component identified with specified PID (service's persistent identity). The service's persistent identity is defined as the name attribute of the Component Descriptor XML file; at runtime, the same value is also available in the component.name and in the service.pid attributes of the Component Configuration.

Specified by:
getComponentConfiguration in interface ConfigurationService
Parameters:
pid - The ID of the component whose configuration is requested.
Returns:
ComponentConfiguration of the requested Component.
Throws:
EsfException

updateConfiguration

public void updateConfiguration(String pidToUpdate,
                                Map<String,Object> propertiesToUpdate)
                         throws EsfException
Description copied from interface: ConfigurationService
Updates the Configuration of the registered component with the specified pid. Using the OSGi ConfigurationAdmin, it retrieves the Configuration of the component with the specified PID and then send an update using the specified properties.
If the component to be updated is not yet registered with the ConfigurationService, it is first registered and then it is updated with the specified properties. Before updating the component, the specified properties are validated against the ObjectClassDefinition associated to the Component. The Configuration Service is fully compliant with the OSGi MetaType Information and the validation happens through the OSGi MetaType Service.
The Configuration Service is compliant with the OSGi MetaType Service so it accepts all attribute types defined in the OSGi Compendium Specifications.
it accepts all

Specified by:
updateConfiguration in interface ConfigurationService
Parameters:
pidToUpdate - The ID of the component whose configuration is requested.
propertiesToUpdate - Properties to be used as the new Configuration for the specified Component.
Throws:
EsfException - if the properties specified do not pass the validation of the ObjectClassDefinition

snapshot

public long snapshot()
              throws EsfException
Description copied from interface: ConfigurationService
Takes a new snapshot of the current configuration of all the registered ConfigurableCompoenents. It returns the ID of a snapshot as the epoch time at which the snapshot was taken.

Specified by:
snapshot in interface ConfigurationService
Returns:
the ID of the snapshot.
Throws:
EsfException

rollback

public long rollback()
              throws EsfException
Description copied from interface: ConfigurationService
Rolls back to the last saved snapshot if available.

Specified by:
rollback in interface ConfigurationService
Returns:
the ID of the snapshot it rolled back to
Throws:
EsfException - if no snapshots are available or

rollback

public void rollback(long id)
              throws EsfException
Description copied from interface: ConfigurationService
Rolls back to the specified snapshot id.

Specified by:
rollback in interface ConfigurationService
Parameters:
id - ID of the snapshot we need to rollback to
Throws:
EsfException - if the snapshot is not found

getSnapshots

public Set<Long> getSnapshots()
                       throws EsfException
Description copied from interface: ConfigurationService
Returns the ID of all the snapshots taken by the ConfigurationService. The snapshot ID is the epoch time at which the snapshot was taken. The snapshots are stored in the EsfHome/snapshots/ directory. This API will return all the snpashot files available in that location.

Specified by:
getSnapshots in interface ConfigurationService
Returns:
IDs of the snapshots available.
Throws:
EsfException

getSnapshot

public List<ComponentConfiguration> getSnapshot(long sid)
                                         throws EsfException
Description copied from interface: ConfigurationService
Loads a snapshot given its ID and return the component configurations stored in that snapshot.

Specified by:
getSnapshot in interface ConfigurationService
Parameters:
sid - - ID of the snapshot to be loaded
Returns:
List of ComponentConfigurations contained in the snapshot
Throws:
EsfException

updateConfigurations

public void updateConfigurations(List<ComponentConfiguration> configsToUpdate)
                          throws EsfException
Specified by:
updateConfigurations in interface ConfigurationService
Throws:
EsfException


Copyright © 2013. All Rights Reserved.