uk.org.iscream.cms.server.componentmanager
Class ConfigurationProxy

java.lang.Object
  extended by java.lang.Thread
      extended by uk.org.iscream.cms.server.componentmanager.ConfigurationProxy
All Implemented Interfaces:
Runnable

public class ConfigurationProxy
extends Thread

A Configuration Proxy hold configurations caches and maintains configurations obtained from the Configuration Manager. It also has support for checking for updates in configurations, if a change is detected, it reloads all the changed configurations. This is done by a thread which runs every ConfigurationProxy.updateTime seconds. This is a singleton class, and should be used by all classes that wish to gain a configuration from the server, as it then allows them to be dynamically reconfigured.

Version:
$Id: ConfigurationProxy.java,v 1.19 2004/08/01 10:40:50 tdb Exp $
Author:
$Author: tdb $

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  HashMap _configCache
          Holds a list of configuration cache's for every configuration that has been requested of this proxy.
private  ConfigurationManager _confman
          This holds a reference to the configuration manager
private static ConfigurationProxy _instance
          A reference to the single instance of this class
private  Logger _logger
          This holds a reference to the system logger that is being used.
private  String _name
          This is the friendly identifier of the component this class is running in.
private  ReferenceManager _refman
          A reference to the reference manager in use
private  boolean _running
          Holds the current state of the configuration proxy's thread
 int DEFAULT_REFRESH_TIME
          The default time to refresh the configurations - 60 seconds.
static String REVISION
          The current CVS revision of this class
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private ConfigurationProxy()
          Construct a ConfigurationProxy Then starts the auto-updating part (the thread) running.
 
Method Summary
 String getFileList(String configName)
          This method obtains the configuration from the configuration cache, if the configuration isn't in the cache, it adds it.
static ConfigurationProxy getInstance()
          Return a reference to the single class.
 long getLastModified(String configName)
          This method obtains the configuration from the configuration cache, if the configuration isn't in the cache, it adds it.
 String getProperty(String configName, String propertyName)
          This method obtains the configuration from the configuration cache, if the configuration isn't in the cache, it adds it.
 void run()
          This method runs and waits for a period defined by ConfigurationProxy.updateTime.
 String toString()
          Overrides the Object.toString() method to provide clean logging (every class should have this).
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

DEFAULT_REFRESH_TIME

public final int DEFAULT_REFRESH_TIME
The default time to refresh the configurations - 60 seconds.

See Also:
Constant Field Values

_name

private String _name
This is the friendly identifier of the component this class is running in. eg, a Filter may be called "filter1", If this class does not have an owning component, a name from the configuration can be placed here. This name could also be changed to null for utility classes.


_logger

private Logger _logger
This holds a reference to the system logger that is being used.


_refman

private ReferenceManager _refman
A reference to the reference manager in use


_confman

private ConfigurationManager _confman
This holds a reference to the configuration manager


_configCache

private HashMap _configCache
Holds a list of configuration cache's for every configuration that has been requested of this proxy.


_running

private boolean _running
Holds the current state of the configuration proxy's thread


_instance

private static ConfigurationProxy _instance
A reference to the single instance of this class

Constructor Detail

ConfigurationProxy

private ConfigurationProxy()
Construct a ConfigurationProxy Then starts the auto-updating part (the thread) running.

Method Detail

getInstance

public static ConfigurationProxy getInstance()
Return a reference to the single class. Construct it if it does not already exist, otherwise just return the reference.


run

public void run()
This method runs and waits for a period defined by ConfigurationProxy.updateTime. Each time it checks all the configuratons it has loaded to see if their configurations have changed. If they have, it refreshes the cache with the new configuration and then instructs the old one to be disconnected from the ORB so that it can be garbage collected.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

getProperty

public String getProperty(String configName,
                          String propertyName)
                   throws PropertyNotFoundException
This method obtains the configuration from the configuration cache, if the configuration isn't in the cache, it adds it. It then asks the configuration for the requested property name, and then returns that to the caller.

Parameters:
configName - the name of the configuration
propertyName - the name of the property to obtain
Returns:
the value of the requested property
Throws:
PropertyNotFoundException

getFileList

public String getFileList(String configName)
This method obtains the configuration from the configuration cache, if the configuration isn't in the cache, it adds it. It then returns the file list used to build that configuration.

Parameters:
configName - the name of the configuration
Returns:
the semi-coma separated list of filenames

getLastModified

public long getLastModified(String configName)
This method obtains the configuration from the configuration cache, if the configuration isn't in the cache, it adds it. It then returns the time in milliseconds of the most last modified date of the most recently modified file in the configurations file list.

Parameters:
configName - the name of the configuration
Returns:
the time in millis

toString

public String toString()
Overrides the Object.toString() method to provide clean logging (every class should have this). This uses the uk.org.iscream.cms.util.FormatName class to format the toString()

Overrides:
toString in class Thread
Returns:
the name of this class and its CVS revision


Copyright © 2000-2003 i-scream. All Rights Reserved.