com.ail.core.configure
Class AbstractConfigurationLoader

java.lang.Object
  extended by com.ail.core.configure.AbstractConfigurationLoader
Direct Known Subclasses:
EJBConfigurationLoader, FileConfigurationLoader, JDBCConfigurationLoader, WebServiceConfigurationLoader

public abstract class AbstractConfigurationLoader
extends java.lang.Object

This class is extended by classes capable of loading and saving configurations to/from some form of persistent store.

The handling of configurations is key to the operation of the Core system. To be as flexible as possible, this abstract class leaves the details of how configurations are loaded and stored to its concrete implementors. At runtime the loadLoader method is responsible for creating an instance of a concrete implementation of this class. That instance is then used by all core users in that VM to load/save their configurations.

That actual concrete implementation can be specified in the following ways (in decending order of preference):

  1. The system property com.ail.core.configure.loader. If defined the system will create an instance of the class it names. This instance is then used as the loader for the VM. On the command line you might specify this as follows:
      -Dcom.ail.core.configure.loader=com.ail.core.configure.EJBConfigurationLoader
    Additional arguments may be passed to the loader using properties with the following naming conversion:
      com.ail.core.configure.loaderParam.<paramName>.
    For example, the following System properties will select the connection pool loader, and pass it "java:/CodeDS" as the JNDI name for the pool to use:
      -Dcom.ail.core.configure.loader=com.ail.core.configure.ConnectionPoolConfigurationLoader
      -Dcom.ail.core.configure.loaderParam.jndiname=java:/CoreDS
  2. The system property com.ail.core.configure.loaderPropertiesFile. If this is found to be defined, the file it names is opened and the properties read from it. The file is expected to be in the same form as defined below.
  3. Environment entries in JNDI. The entry java:comp/env/ConfigurationLoader.classname and java:comp/env/ConfigurationLoader.params must be defined, and must be Strings. The former is taken to be the full name of the class to instantiate and use as the concrete loader. The latter is a semi-colon separated list of name=value parameters to initialize the concrete loader.
  4. The class resource file loader.properties. This property file must as a minimum define the property loaderClass with a value identifying the fully qualified class name of the implementation. Any additional properties defined in the file will be passed to the concrete implementation. For example, the JDBCConfigurationLoader expects a driver property.
Some (in fact most) of the concrete implementations require other parameters. See their javadocs (from See Also below) for more details.

Version:
$Revision: 1.5 $
See Also:
JDBCConfigurationLoader, EJBConfigurationLoader, ConnectionPoolConfigurationLoader, FileConfigurationLoader

Constructor Summary
AbstractConfigurationLoader()
           
 
Method Summary
abstract  void deleteConfigurationRepository()
          Delete the repository holding configuration information.
 java.util.Properties getLoaderParams()
          Return the configuration parameters associated with the loader.
abstract  java.util.Collection<java.lang.String> getNamespaces()
          Build and return a list of the namespaces currently being used.
abstract  java.util.Collection<ConfigurationSummary> getNamespacesHistorySummary(java.lang.String namespace)
          Build and return a list of the details of a namespaces versions.
abstract  java.util.Collection<ConfigurationSummary> getNamespacesSummary()
          Build and return a list of the details of the namespaces currently being used.
abstract  Configuration loadConfiguration(java.lang.String namespace, VersionEffectiveDate date)
          Fetch the configuration associated with a given namespace, and return them.
static AbstractConfigurationLoader loadLoader()
          Create an instance of the loader to be used.
abstract  void purgeAllConfigurations()
          Delete ALL configuration information.
abstract  void reset()
          When the configuration handler is asked to "reset", it passes that request onto the loader currently in user.
abstract  void saveConfiguration(java.lang.String namespace, Configuration config)
          Save (and update) the configuration associated with the specificed namespace.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConfigurationLoader

public AbstractConfigurationLoader()
Method Detail

loadLoader

public static AbstractConfigurationLoader loadLoader()
Create an instance of the loader to be used. The details of which loader, and what parameters to pass to it are loaded from the loader.properties file.

Returns:
The loader instance to use in this JVM.

getLoaderParams

public java.util.Properties getLoaderParams()
Return the configuration parameters associated with the loader.

Returns:
The properties from the loader.properties file.

loadConfiguration

public abstract Configuration loadConfiguration(java.lang.String namespace,
                                                VersionEffectiveDate date)
Fetch the configuration associated with a given namespace, and return them.

Parameters:
namespace - The namespace to load for.
date - The effective date to load the configuration for.
Returns:
loaded configuration.

saveConfiguration

public abstract void saveConfiguration(java.lang.String namespace,
                                       Configuration config)
                                throws ConfigurationUpdateCollisionError
Save (and update) the configuration associated with the specificed namespace.

Parameters:
namespace - The namespace to save to.
config - The configuration to save.
Throws:
ConfigurationUpdateCollisionError - If the configuration being written is stale (i.e. has be updated in persistent store since it was read).

getNamespaces

public abstract java.util.Collection<java.lang.String> getNamespaces()
Build and return a list of the namespaces currently being used. More specifically this includes only those that are stored and are current.

Returns:
A collection of namespace names as Strings.

getNamespacesSummary

public abstract java.util.Collection<ConfigurationSummary> getNamespacesSummary()
Build and return a list of the details of the namespaces currently being used. More specifically this includes only those that are stored and are current.

Returns:
A collection of instances of ConfigurationSummary..

getNamespacesHistorySummary

public abstract java.util.Collection<ConfigurationSummary> getNamespacesHistorySummary(java.lang.String namespace)
Build and return a list of the details of a namespaces versions.

Parameters:
namespace - The namespace to fetch the history for.
Returns:
A collection of instances of ConfigurationSummary..

reset

public abstract void reset()
When the configuration handler is asked to "reset", it passes that request onto the loader currently in user. The loader should reset any internal state in this method. "state" here means memory state only - the persisted configurations will not be altered.


purgeAllConfigurations

public abstract void purgeAllConfigurations()
Delete ALL configuration information. This will include all historical configuration information.

NOTE: ALL CONFIGURATION INFORMATION WILL BE LOST!


deleteConfigurationRepository

public abstract void deleteConfigurationRepository()
Delete the repository holding configuration information. This not only removes all configuration information purgeAllConfigurations() but also removes the repository itself.

NOTE: ALL CONFIGURATION INFORMATION WILL BE LOST!