org.aselect.system.configmanager
Interface IConfigHandler

All Known Implementing Classes:
XMLConfigHandler

public interface IConfigHandler

Interface for all ConfigHandlers.

Description:
-

Concurrency issues:
-

Author:
Alfa & Ariss

Method Summary
 java.lang.Object getNextSection(java.lang.Object oSection)
          Returns the next 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 rootSection, java.lang.String sectionType)
          Get the first section.
 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.io.File fConfig)
          Initializes the ConfigHandler.
 void init(java.lang.String sUser, java.lang.String sPassword, java.lang.String sDatabaseURL, java.lang.String sDatabaseTable, java.lang.String sDriverName, java.lang.String sConfigId)
          Initializes the ConfigHandler.
 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)
          Get a sub-section.
 

Method Detail

init

void init(java.io.File fConfig)
          throws ASelectConfigException
Initializes the ConfigHandler.
br> Description:
Initializes the ConfigHandler using a File as source.

Concurrency issues:
-

Preconditions:
fConfig != null

Postconditions:
The IConfigHandler is initialized.

Parameters:
fConfig - The File that contains the configuration
Throws:
ASelectConfigException - If initialization fails.

init

void init(java.lang.String sUser,
          java.lang.String sPassword,
          java.lang.String sDatabaseURL,
          java.lang.String sDatabaseTable,
          java.lang.String sDriverName,
          java.lang.String sConfigId)
          throws ASelectConfigException
Initializes the ConfigHandler.

Description:
Initializes the ConfigHandler using a database as source.

Concurrency issues:
-

Preconditions:
Postconditions:
The IConfigHandler implementation is initialized.

Parameters:
sUser - Username that must be used to coneect to the database
sPassword - Password for the user that must be used to connect to the database
sDatabaseURL - URL to the database
sDatabaseTable - Database table in which the configuration is stored
sDriverName - The name of the driver that will be used to connect to the database
sConfigId - The ID of the configuration in which the specific configuration is located
Throws:
ASelectConfigException - If initialization fails.

getSection

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 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

java.lang.Object getSection(java.lang.Object rootSection,
                            java.lang.String sectionType)
                            throws ASelectConfigException
Get the first section.

Description:
get the first configuration section of the specified sectionType.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
rootSection - The root section.
sectionType - The type of section.
Returns:
First configuration section of the specified sectionType
Throws:
ASelectConfigException - If retrieving fails.

setSection

java.lang.Object setSection(java.lang.Object oRootSection,
                            java.lang.String sSectionType)
                            throws ASelectConfigException
Get a sub-section.

Description:
Returns a sub-section from the configuration of the given root section specified by the given type.

Concurrency issues:
-

Preconditions:
If the root section is null: the first section will be returned.

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 - Is setting session fails.

removeSection

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, otherwise false.
Throws:
ASelectConfigException - If removinf fails.

removeSection

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

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

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

java.lang.Object getNextSection(java.lang.Object oSection)
                                throws ASelectConfigException
Returns the next section.

Description:
Returns the next section with the same type that is direclty located after the given section. 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

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

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

Import configuration items into this configuration.

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

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.