|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.feide.moria.configuration.ConfigurationManager
public final class ConfigurationManager
The configuration manager's task is to load and monitor the configuration
files for changes. Each module (authorization, web, store and directory)
has a configuration file which is read and passed as a Properties object
to the module at startup. The authorization module does its own file
parsing, so for that module the Properties object just contains the
name of the configuration file, which is then read and parsed by the
authorization module.
If a configuration file is changed, the entire file is reread and the
updated configuration is passed to the corresponding module.
The constructor requires the no.feide.moria.configuration.cm
property to be set, and the property has to point to the configuration file
for the ConfigurationManager module. The file can be referenced by either
full file path or as a resource in the classpath.
The
configuration file has to contain properties that point to the other modules'
properties files. These files can be referenced by either full file path or
as a resource in the classpath. The
no.feide.moria.configuration.fileListenerIntervalSeconds
attribute specifies the interval between each file poll.
# Example content for ConfigurationManager properties no.feide.moria.configuration.fileListenerIntervalSeconds=1 no.feide.moria.configuration.sm=/sm-test-valid.properties no.feide.moria.configuration.dm=/dm-test-valid.properties no.feide.moria.configuration.am=/am-data.xmlWhen a configuration file is changed, the content is read into a properties object which is sent to the MoriaController.
MoriaController
Nested Class Summary | |
---|---|
(package private) class |
ConfigurationManager.FileListenerTask
This class is used to monitor the configuration files. |
Field Summary | |
---|---|
private no.feide.moria.log.MessageLogger |
messageLogger
For logging events that do not throw exceptions to the layer above. |
static java.lang.String |
MODULE_AM
Name of the Authorization module, used in configuration properties. |
private static java.lang.String |
MODULE_CM
Name of the Configuration module, used in configuration properties. |
static java.lang.String |
MODULE_DM
Name of the Directory module, used in configuration properties. |
static java.lang.String |
MODULE_SM
Name of the Store module, used in configuration properties. |
static java.lang.String |
MODULE_WEB
Name of the Web module, used in configuration properties. |
private static java.lang.String[] |
NEEDS_LISTENER
List of the modules that have configuration to watch. |
private static java.lang.String |
PROPS_PREFIX
Attribute name prefix for file name properties. |
private java.util.Timer |
timer
Timer for the configuration files. |
private static java.lang.String |
TIMER_DELAY
Attribute name for timer delay. |
private java.util.HashMap |
timerEntries
Storage for all timers. |
Constructor Summary | |
---|---|
ConfigurationManager()
Constructor. |
Method Summary | |
---|---|
private void |
addFileChangeListener(java.lang.String fileName,
java.lang.String module,
int intervalSec)
Monitor a file. |
void |
destroy()
Destructor. |
private void |
fileChangeEvent(java.lang.String module,
java.io.File configurationFile)
Send changed configuration to MoriaController . |
private static java.io.File |
fileForURI(java.lang.String fileURI)
Resolves a fileURI to a File object. |
(package private) int |
numFileListeners()
Number of active file listeners. |
private static java.util.Properties |
readProperties(java.lang.String fileURI)
Read properties from file. |
private void |
removeFileChangeListener(java.lang.String fileName)
Stop monitoring file. |
void |
stop()
Remove all file listeners. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final no.feide.moria.log.MessageLogger messageLogger
public static final java.lang.String MODULE_SM
public static final java.lang.String MODULE_DM
public static final java.lang.String MODULE_AM
private static final java.lang.String MODULE_CM
public static final java.lang.String MODULE_WEB
private static final java.lang.String TIMER_DELAY
private static final java.lang.String PROPS_PREFIX
private static final java.lang.String[] NEEDS_LISTENER
private final java.util.Timer timer
private final java.util.HashMap timerEntries
Constructor Detail |
---|
public ConfigurationManager() throws ConfigurationManagerException
System.properties
) and starts file
listeners for all modules' configuration files.
BaseConfigException
- If the system property pointing to the base configuration
file is not a non-empty string.
ConfigurationManagerException
- If there are any problems with the configuration file.Method Detail |
---|
public void stop()
public void destroy()
stop()
.
stop()
int numFileListeners()
private static java.util.Properties readProperties(java.lang.String fileURI) throws java.io.IOException
IOException
or
IllegalArgumentException
is thrown.
fileURI
- The reference to the properties file.
java.io.IOException
- If something goes wrong during file read.
java.lang.IllegalArgumentException
- If fileURI
is not a non-empty string.private void addFileChangeListener(java.lang.String fileName, java.lang.String module, int intervalSec) throws java.io.FileNotFoundException
FileNotFoundException
is thrown.
fileName
- Full path or relative (classpath) path to the properties file.module
- The module the configuration file belongs to.intervalSec
- Polling period in seconds.
java.io.FileNotFoundException
- If the file is not found.private void removeFileChangeListener(java.lang.String fileName)
fileName
- The file name to stop monitoring.private void fileChangeEvent(java.lang.String module, java.io.File configurationFile)
MoriaController
.
module
- The module the configuration file belongs to.configurationFile
- A File
object representing the changed file.MoriaController.setConfig(java.lang.String, java.util.Properties)
private static java.io.File fileForURI(java.lang.String fileURI) throws java.io.FileNotFoundException
File
object.
fileURI
- Reference to the file (full path or relative within the
classpath).
File
object referenced by the fileURI.
java.io.FileNotFoundException
- If the fileURI cannot be resolved to a readable file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |