org.aselect.system.configmanager
Class ConfigManager

java.lang.Object
  extended by org.aselect.system.configmanager.ConfigManager
Direct Known Subclasses:
ASelectAgentConfigManager, ASelectConfigManager, AuthSPConfigManager

public class ConfigManager
extends java.lang.Object

A common configuration manager.

Description:
The ConfigManager offers an interface to the configuration, which can be used by all A-Select components. It's set up like a factory to resolve the right ConfigHandler.

The ConfigManager offers an interface to the ConfigHandler that is created during initialization.

Concurrency issues:
-

Author:
Alfa & Ariss

Constructor Summary
ConfigManager()
          Default constructor.
 
Method Summary
 java.lang.Object getNextSection(java.lang.Object oSection)
          Returns the next section with the same type that is direclty located after the given section.
 java.lang.String getParam(java.lang.Object oSection, java.lang.String sConfigItem)
          Returns a String that contains the requested configuration parameter.
 java.lang.Object getSection(java.lang.Object oRootSection, java.lang.String sSectionType)
          Returns a sub-section from the configuration of the given root section specified by the given type.
 java.lang.Object getSection(java.lang.Object oRootSection, java.lang.String sSectionType, java.lang.String sSectionID)
          Returns a sub-section from the configuration of the given root-section.
 void importConfig(java.io.File fConfig)
          Deprecated. All config should be stored in only one config file.
 void init(java.lang.String sDriverName, java.lang.String sUser, java.lang.String sPassword, java.lang.String sDatabaseURL, java.lang.String sDatabaseTable, java.lang.String sConfigId, SystemLogger oSystemLogger)
          Initialize the ConfigManager for use with a database.
 void init(java.lang.String sConfigFile, SystemLogger oSystemLogger)
          Initialize the ConfigManager for use with a config file.
 boolean removeSection(java.lang.Object oRootSection, java.lang.String sSectionType)
          Removes a specified configuration section.
 boolean removeSection(java.lang.Object oRootSection, java.lang.String sSectionType, java.lang.String sSectionID)
          Removes a configuration section specified by section ID.
 void saveConfig()
          Saves the configuration as is known by the ConfigHandler.
 boolean setParam(java.lang.Object oSection, java.lang.String sConfigItem, java.lang.String sConfigValue, boolean bMandatory)
          Adds a config parameter to the given section.
 java.lang.Object setSection(java.lang.Object oRootSection, java.lang.String sSectionType)
          Adds an empty configuration section of the specified sectionType of the rootSection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigManager

public ConfigManager()
Default constructor.

Description:
Default constructor which initializes class variables.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Method Detail

init

public void init(java.lang.String sConfigFile,
                 SystemLogger oSystemLogger)
          throws ASelectConfigException
Initialize the ConfigManager for use with a config file.

Description:
The ConfigManager will create an ConfigHandler with file support.

Concurrency issues:
Only one ConfigHandler per ConfigManager will be created.

Preconditions:
The oSystemLogger object must be initialized.

Postconditions:
-

Parameters:
sConfigFile - String that contains the full path and filename of the configuration file.
oSystemLogger - SystemLogger initialized SystemLogger Object.
Throws:
ASelectConfigException - If initialization fails.

init

public void init(java.lang.String sDriverName,
                 java.lang.String sUser,
                 java.lang.String sPassword,
                 java.lang.String sDatabaseURL,
                 java.lang.String sDatabaseTable,
                 java.lang.String sConfigId,
                 SystemLogger oSystemLogger)
          throws ASelectConfigException
Initialize the ConfigManager for use with a database.

Description:
The initialize function for storage of the config file in a database.

Concurrency issues:
-

Preconditions:
The oSystemLogger object must be initialized.

Postconditions:
-

Parameters:
sDriverName - JDBC Driver name
sUser - JDBC Username
sPassword - Password for sUser to access JDBC database
sDatabaseURL - URL to JDBC database
sDatabaseTable - Name of table that contains the A-Select config
sConfigId - Unique ID of the configuration in the table.
oSystemLogger - SystemLogger initialized SystemLogger Object.
Throws:
ASelectConfigException - If initialization fails.

getSection

public java.lang.Object getSection(java.lang.Object oRootSection,
                                   java.lang.String sSectionType,
                                   java.lang.String sSectionID)
                            throws ASelectConfigException
Returns a sub-section from the configuration of the given root-section.

Description:
The returned sub-section is of the given type and has the given section ID. The root section can be null: the first section will be returned. The requested section ID must be a String containing one '=' character (syntax: [param]=[value]).

Concurrency issues:
-

Preconditions:
-

Postconditions:
If the section can't be found, an ASelectConfigException will be thrown.

Parameters:
oRootSection - The section in which the requested section is located.
sSectionType - The type of the section, in XML the XML tag name.
sSectionID - The id of a section (syntax: [param]=[value])
Returns:
Object that indicates a specific section within the configuration.
Throws:
ASelectConfigException - If retrieving fails.

getSection

public java.lang.Object getSection(java.lang.Object oRootSection,
                                   java.lang.String sSectionType)
                            throws ASelectConfigException
Returns a sub-section from the configuration of the given root section specified by the given type.

Description:
The root section can be null: the first section will be returned.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oRootSection - Section that is used to resulve the subsection
sSectionType - Type of the subsection that should be returned
Returns:
Object containing the subsection
Throws:
ASelectConfigException - If retrieving fails

setSection

public java.lang.Object setSection(java.lang.Object oRootSection,
                                   java.lang.String sSectionType)
                            throws ASelectConfigException
Adds an empty configuration section of the specified sectionType of the rootSection.

Description:
Must be used to create a new configuration section of a given section type.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oRootSection - Section to which the new section is added
sSectionType - Type of the section that will be added
Returns:
An empty section added to the supplied root section
Throws:
ASelectConfigException - If setting fails

removeSection

public boolean removeSection(java.lang.Object oRootSection,
                             java.lang.String sSectionType)
                      throws ASelectConfigException
Removes a specified configuration section.

Description:
Removes a section perminently from the configuration.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oRootSection - Section containing the section that must be removed
sSectionType - Type of the section that must be removed
Returns:
TRUE if section is successfully removed
Throws:
ASelectConfigException - If removing fails

removeSection

public boolean removeSection(java.lang.Object oRootSection,
                             java.lang.String sSectionType,
                             java.lang.String sSectionID)
                      throws ASelectConfigException
Removes a configuration section specified by section ID.

Description:
Removes a section, specified by section type and section ID, perminently from the configuration.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oRootSection - Section containing the section that must be removed
sSectionType - Type of the section that must be removed
sSectionID - ID of section that must be removed (syntax: [name]=[value])
Returns:
TRUE if section is successfully removed
Throws:
ASelectConfigException - if removing fails

getParam

public java.lang.String getParam(java.lang.Object oSection,
                                 java.lang.String sConfigItem)
                          throws ASelectConfigException
Returns a String that contains the requested configuration parameter.

Description:
The String that will be returned will be retrieved from the given config section and has the specified config item name.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oSection - Section from which contains the parameter
sConfigItem - The name of the config parameter
Returns:
String containing the requested config parameter
Throws:
ASelectConfigException - If retrieving fails

setParam

public boolean setParam(java.lang.Object oSection,
                        java.lang.String sConfigItem,
                        java.lang.String sConfigValue,
                        boolean bMandatory)
                 throws ASelectConfigException
Adds a config parameter to the given section.

Description:
Adds a config parameter to the given section in the configuration. The parameter has the name sConfigItem and the value sConfigValue . With the bMandatory attribute can be set if the config parameter is part of the required configuration.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oSection - The config section to which the parameter will be added
sConfigItem - Name of the config parameter that will be added
sConfigValue - Value of the config parameter that will be added
bMandatory - TRUE if config parameter is requered in the section
Returns:
TRUE if parameter is successfully added
Throws:
ASelectConfigException - If setting fails

getNextSection

public java.lang.Object getNextSection(java.lang.Object oSection)
                                throws ASelectConfigException
Returns the next section with the same type that is direclty located after the given section.

Description:
It will return null if no next section can be found.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
oSection - Section that has the same type as the section that must be returned
Returns:
Object That contains the next section
Throws:
ASelectConfigException - If retrieving fails

saveConfig

public void saveConfig()
                throws ASelectConfigException
Saves the configuration as is known by the ConfigHandler.

Description:
Writes the configuration to the physical storage. It will overwrite the existing configuration.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Throws:
ASelectConfigException - If saving fails

importConfig

public void importConfig(java.io.File fConfig)
                  throws ASelectConfigException
Deprecated. All config should be stored in only one config file.

Imports the configuration file within the configuration that is present in the ConfigHandler.

Description:
-

Concurrency issues:
-

Preconditions:
The ConfigManager must be initialized.

Postconditions:
-

Parameters:
fConfig - The configuration File that will be imported in the configuration that is known in the memory of the ConfigHandler
Throws:
ASelectConfigException - If importing fails


Copyright © 2008 SURFnet BV. All Rights Reserved.