org.glite.ce.commonj.configuration.xppm
Class ConfigurationManager

java.lang.Object
  extended by org.glite.ce.commonj.configuration.xppm.ConfigurationManager
All Implemented Interfaces:
java.lang.Runnable

public class ConfigurationManager
extends java.lang.Object
implements java.lang.Runnable

The ConfigurationManager is the engine of the Common Configuration System for any all the Computing Element services. It loads the instantiates the registered configuration handlers and parses the XML configuration file.


Constructor Summary
ConfigurationManager(java.lang.String xmlFilename)
          Instantiates a new configuration manager.
ConfigurationManager(java.lang.String xmlFilename, long rate)
          Instantiates a new configuration manager.
ConfigurationManager(java.lang.String xmlFilename, long rate, ConfigurationListener[] listeners)
          Instantiates a new configuration manager.
 
Method Summary
 void addListener(ConfigurationListener lsnr)
          Registers a new configuration listener.
 java.lang.Object[] getConfigurationElements(java.lang.Class<?> category)
          Returns an array of configuration objects registered for a given category The category specify the class type of the returned object.
 void removeListener(ConfigurationListener lsnr)
          Removes a registered configuration listener.
 void run()
          Notifies the scheduled configuration events to the registered listeners If no events are scheduled the thread is blocked waiting for configuration changes.
 void shutdown()
          Stops the notification thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationManager

public ConfigurationManager(java.lang.String xmlFilename)
                     throws org.glite.ce.commonj.configuration.CommonConfigException
Instantiates a new configuration manager. The XML configuration file is parsed and the configuration handlers are loaded. The notification manager is disabled.

Parameters:
xmlFilename - is the path of the XML configuration file
Throws:
org.glite.ce.commonj.configuration.CommonConfigException - if XML file is not correct

ConfigurationManager

public ConfigurationManager(java.lang.String xmlFilename,
                            long rate)
                     throws org.glite.ce.commonj.configuration.CommonConfigException
Instantiates a new configuration manager. The XML configuration file is parsed and the configuration handlers are loaded. The notification manager is launched with a given refresh rate.

Parameters:
xmlFilename - is the path of the XML configuration file
rate - is the interval in milliseconds between two consecutive configuration lookups
Throws:
org.glite.ce.commonj.configuration.CommonConfigException - if XML file is not correct

ConfigurationManager

public ConfigurationManager(java.lang.String xmlFilename,
                            long rate,
                            ConfigurationListener[] listeners)
                     throws org.glite.ce.commonj.configuration.CommonConfigException
Instantiates a new configuration manager. The XML configuration file is parsed and the configuration handlers are loaded. The notification manager is launched with a given refresh rate; a list of listeners is registered at startup

Parameters:
xmlFilename - is the path of the XML configuration file
rate - is the interval in milliseconds between two consecutive configuration lookups
listeners - is the array of listeners to be registered at the startup of the notification manager
Throws:
org.glite.ce.commonj.configuration.CommonConfigException - if XML file is not correct
Method Detail

getConfigurationElements

public java.lang.Object[] getConfigurationElements(java.lang.Class<?> category)
Returns an array of configuration objects registered for a given category The category specify the class type of the returned object.

Parameters:
category - is the class type for the registered object
Returns:
an array, empty but never null, of configuration objects

run

public void run()
Notifies the scheduled configuration events to the registered listeners If no events are scheduled the thread is blocked waiting for configuration changes. The thread may exit if illegal interrupted exception are thrown. The correct way to stop the thread is to call the shutdown method.

Specified by:
run in interface java.lang.Runnable

shutdown

public void shutdown()
Stops the notification thread.


addListener

public void addListener(ConfigurationListener lsnr)
Registers a new configuration listener. Attempting to call this method from inside the the notify method of the listener generates an IllegalStateException.

Parameters:
lsnr - is the listener to be registered

removeListener

public void removeListener(ConfigurationListener lsnr)
Removes a registered configuration listener. Attempting to call this method from inside the the notify method of the listener generates an IllegalStateException.

Parameters:
lsnr - is the listener to be removed