de.novanic.eventservice.config
Class EventServiceConfigurationFactory

java.lang.Object
  extended by de.novanic.eventservice.config.EventServiceConfigurationFactory

public class EventServiceConfigurationFactory
extends java.lang.Object

EventServiceConfigurationFactory can be used to create an instance of EventServiceConfiguration. There a various ConfigurationLoader strategies to initilize the configuration. DefaultConfigurationLoader is used at last, when no configuration could be found.

There are three pre-registered ConfigurationLoaders at various levels.
1) Level ConfigLevelFactory.DEFAULT (5000) - PropertyConfigurationLoader
2) Level ConfigLevelFactory.DEFAULT (5000) - WebDescriptorConfigurationLoader
3) Level ConfigLevelFactory.HIGHEST (10000) - DefaultConfigurationLoader

That means when a property file is in the classpath, the property file is used for the configuration. When no property file is available, the web-descriptor is used. When no servlet-parameters are registered in the web-descriptor, the default configuration is used. To manipulate that sequence and to register custom configuration loaders addConfigurationLoader(de.novanic.eventservice.config.level.ConfigLevel, de.novanic.eventservice.config.loader.ConfigurationLoader) and other modifier methods of that class can be used.

Author:
sstrohschein
Date: 23.10.2008
Time: 14:36:49

Method Summary
 void addConfigurationLoader(ConfigLevel aLevel, ConfigurationLoader aConfigurationLoader)
          Adds a ConfigurationLoader (in the queue before the default configuration loaders).
 void addCustomConfigurationLoader(ConfigurationLoader aConfigurationLoader)
          Adds a custom ConfigurationLoader (in the queue before the default configuration loaders).
static EventServiceConfigurationFactory getInstance()
          This method should be used to create an instance of EventServiceConfigurationFactory.
 EventServiceConfiguration loadEventServiceConfiguration()
          Loads the EventServiceConfiguration with various ConfigurationLoader strategies.
 EventServiceConfiguration loadEventServiceConfiguration(java.lang.String aPropertyName)
          Loads the EventServiceConfiguration with various ConfigurationLoader strategies.
 void removeConfigurationLoader(ConfigurationLoader aConfigurationLoader)
          Removes a ConfigurationLoader.
 void replaceConfigurationLoader(ConfigLevel aLevel, ConfigurationLoader aConfigurationLoader)
          Replaces a configuration loader at the specified configuration level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static EventServiceConfigurationFactory getInstance()
This method should be used to create an instance of EventServiceConfigurationFactory. EventServiceConfigurationFactory is a singleton, so this method returns always the same instance of EventServiceConfigurationFactory.

Returns:
EventServiceConfigurationFactory (singleton)

loadEventServiceConfiguration

public EventServiceConfiguration loadEventServiceConfiguration(java.lang.String aPropertyName)
Loads the EventServiceConfiguration with various ConfigurationLoader strategies.

Parameters:
aPropertyName - properties file if another properties file is preferred as the default properties file" (see description of PropertyConfigurationLoader).
Returns:
the configuration (EventServiceConfiguration)
Throws:
ConfigurationException - thrown when a configuration is available, but can't be loaded

loadEventServiceConfiguration

public EventServiceConfiguration loadEventServiceConfiguration()
Loads the EventServiceConfiguration with various ConfigurationLoader strategies.

Returns:
the configuration (EventServiceConfiguration)
Throws:
ConfigurationException - thrown when a configuration is available, but can't be loaded

addCustomConfigurationLoader

public void addCustomConfigurationLoader(ConfigurationLoader aConfigurationLoader)
Adds a custom ConfigurationLoader (in the queue before the default configuration loaders).

Parameters:
aConfigurationLoader - custom ConfigurationLoader

addConfigurationLoader

public void addConfigurationLoader(ConfigLevel aLevel,
                                   ConfigurationLoader aConfigurationLoader)
Adds a ConfigurationLoader (in the queue before the default configuration loaders).

Parameters:
aLevel - ConfigLevel to specify the priority/level for the ConfigurationLoader
aConfigurationLoader - custom ConfigurationLoader

removeConfigurationLoader

public void removeConfigurationLoader(ConfigurationLoader aConfigurationLoader)
Removes a ConfigurationLoader.

Parameters:
aConfigurationLoader - ConfigurationLoader to remove from the queue

replaceConfigurationLoader

public void replaceConfigurationLoader(ConfigLevel aLevel,
                                       ConfigurationLoader aConfigurationLoader)
Replaces a configuration loader at the specified configuration level.

Parameters:
aLevel - configuration level to search the ConfigurationLoader
aConfigurationLoader - ConfigurationLoader to add