uk.org.iscream.cms.server.core
Class ConfigurationManagerServant

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by uk.org.iscream.cms.server.core.ConfigurationManagerPOA
          extended by uk.org.iscream.cms.server.core.ConfigurationManagerServant
All Implemented Interfaces:
InvokeHandler, ConfigurationManagerOperations

 class ConfigurationManagerServant
extends ConfigurationManagerPOA

This class is essentially a Configuration factory. This class implements the Configurator IDL and allows other classes in the system ot obtain their Configuration On construction it requires a reference to the RootPOA to allow it to create Configuration objects to be returned. It also relies on the System.properties to set internal values.

Version:
$Id: ConfigurationManagerServant.java,v 1.26 2004/08/01 10:40:54 tdb Exp $
Author:
$Author: tdb $

Field Summary
private  String _configPath
          The root path to all configurations
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  Configuration _systemConfig
          An instance of the system config
private  String _systemConfigFile
          The name of the file that contains the system configuration
private  Properties _systemConfigHolder
          The system config file represented by a properties object.
 String REVISION
          The current CVS revision of this class
 
Constructor Summary
ConfigurationManagerServant()
          Creates a new ConfiguratorServant This class uses the System.properties to set internal values
 
Method Summary
private  Configuration buildConfiguration(String fileList)
          Build the properties as a Configuration to be returned to the caller
 Configuration getConfiguration(String source)
          Returns a Configuration object which contains the configuration data requested by the calling object.
private  LinkedList getGroupMembership(String source)
          Parses the system configuration file for group membership entries.
private  String getIncludedFiles(String currentFile, String readFiles)
          This is a recursive function private to this class.
static boolean groupMatch(String source, String group)
          Checks that a given source is matched within the given list of hosts.
private  boolean hasDuplicate(String file, String fileList)
          This simple method checks to see if a given file exists in the given list.
 boolean isModified(String fileList, long lastModified)
          When passed a file list and a current value for the lastModified of the current configuration, this method compares the value to the actual value of the configuration files to determine whether or not the configuration has been modified.
private  void loadSystemConfig()
          Opens and loads the system configuration into the local reference _systemConfig
 String toString()
          Overrides the Object.toString() method to provide clean logging (every class should have this).
 
Methods inherited from class uk.org.iscream.cms.server.core.ConfigurationManagerPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public final String REVISION
The current CVS revision of this class

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


_configPath

private String _configPath
The root path to all configurations


_systemConfigFile

private String _systemConfigFile
The name of the file that contains the system configuration


_systemConfig

private Configuration _systemConfig
An instance of the system config


_systemConfigHolder

private Properties _systemConfigHolder
The system config file represented by a properties object.

Constructor Detail

ConfigurationManagerServant

ConfigurationManagerServant()
Creates a new ConfiguratorServant This class uses the System.properties to set internal values

Method Detail

getConfiguration

public Configuration getConfiguration(String source)
Returns a Configuration object which contains the configuration data requested by the calling object. This method will look in the systemConfig file for an entry for this "source", if there is no entry it returns a refernce to the system config. If there are any errors in reading the configuration, it returns null, the caller is expected to be able to handle this. This method also checks to see if the system.conf file has been updated and reloads its reference if needed.

Parameters:
source - the configuration required
Returns:
the Configuration

isModified

public boolean isModified(String fileList,
                          long lastModified)
When passed a file list and a current value for the lastModified of the current configuration, this method compares the value to the actual value of the configuration files to determine whether or not the configuration has been modified.

Parameters:
fileList - a list of files that the caller uses for configuration
lastModified - the last modified date of the callers configuration
Returns:
whether or not the configuration has been modified

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 Object
Returns:
the name of this class and its CVS revision

getIncludedFiles

private String getIncludedFiles(String currentFile,
                                String readFiles)
                         throws IOException,
                                FileNotFoundException,
                                Exception
This is a recursive function private to this class. It constructs a hierarchy of files as a ";" serperated string which can be used to read in the configuration. This function calls itself.

Parameters:
currentFile - the current file to be processed
readFiles - used for recursion purposes only, these are the files it has read so far
Returns:
the current list that has been constructed
Throws:
IOException - if there is trouble reading the file
FileNotFoundException - is there is trouble finding the file
CircularIncludeException - this is if a circular include is detected
Exception

hasDuplicate

private boolean hasDuplicate(String file,
                             String fileList)
This simple method checks to see if a given file exists in the given list.

Parameters:
file - the file to check the list for
fileList - the list to check
Returns:
if the given file appeard in the list

loadSystemConfig

private void loadSystemConfig()
Opens and loads the system configuration into the local reference _systemConfig


getGroupMembership

private LinkedList getGroupMembership(String source)
Parses the system configuration file for group membership entries. It looks for all entries of group. which contain the given source name

Parameters:
source - the source to find membership for
Returns:
the list of groups that this source is a member of

groupMatch

public static boolean groupMatch(String source,
                                 String group)
Checks that a given source is matched within the given list of hosts. For example:

Given "stue5de.ukc.ac.uk"
And "raptor.ukc.ac.uk;stue*.ukc.ac.uk

This method would return true as there is a match. This method will also match if the source is exactly matched within the group of hosts (ie. no wildcard).

Parameters:
source - the string to look for
group - the group to search for a match
Returns:
if there is a match

buildConfiguration

private Configuration buildConfiguration(String fileList)
Build the properties as a Configuration to be returned to the caller

Parameters:
fileList - the list of files to build the configuration from
Returns:
the built Configuration


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