Package com.ibm.di.server
Class FileConfig
- java.lang.Object
-
- com.ibm.di.server.FileConfig
-
public class FileConfig extends java.lang.ObjectThis class parses configurations from .inf files. The parsed configurations are being accumulated in the state of the FileConfig object. (Some time ago, this class was used to load TDI configurations (configurations were stored in .inf format rather than in XML). That is why some of the features (such as encryption) exist.) The configurations are represented by TreeMap objects and are organized into a hierarchy. The hierarchy is composed by embedding TreeMap objects as values inside other TreeMap objects. Navigation through the configuration hierarchy is performed via the key names. Several keys can be combined to form a compound key, which identifies a configuration (i.e. TreeMap object) in the hierarchy. The individual parts of a compound key are delimited by a forward slash : '/'. For example: "connectors/ibmdi.URLConnector/connectorConfig". There are some predefined keys for objects in the configuration hierarchy. These predefined keys are used to logically organize configurations into categories such as Connectors, Parsers, Forms, ... The predefined keys are available as String constants (C_CONNECTOR, C_PARSER, C_FORMDEF, ...) in the FileConfig class.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringC_CONNECTORConnector configurations are stored under this key.static java.lang.StringC_FORMDEFForm configurations are stored under this key.static java.lang.StringC_INCLUDEIncludes configurations are stored under this key.static java.lang.StringC_INCLUDEFILESIncludes configurations are stored under this key.static java.lang.StringC_JAVALIBRARIESJava libraries configurations are stored under this key.static java.lang.StringC_JAVAPROPERTIESJava properties configurations are stored under this key.static java.lang.StringC_LIBRARIESLibrary configurations are stored under this key.static java.lang.StringC_LISTENERListener configurations are stored under this key.static java.lang.StringC_MBUSMessage bus configurations are stored under this key.static java.lang.StringC_PARSERParserTypes configurations are stored under this key.static java.lang.StringC_PROPERTIESProperties configurations are stored under this key.static java.lang.StringC_SCRIPTSScript configurations are stored under this key.static java.lang.StringC_SECURITYSecurity configurations are stored under this key.static java.lang.StringC_SHAREDCONNShared Connector configurations are stored under this key.static java.lang.StringC_TASKAssemblyLine configurations are stored under this key.static java.lang.StringC_TRIGGERTrigger configurations are stored under this key.booleandontOverwriteConfigWhether newly read configurations are allowed to overwrite previously stored configurations.java.util.VectorincludedFilesAll include configuration files (the absolute file system paths).booleanisIncludeWhether the configuration currently being parsed is read from an include configuration file.java.lang.StringpasswordPassword (key) for decrypting the configuration input stream/file.
-
Constructor Summary
Constructors Constructor Description FileConfig(java.lang.String path)Constructor for the FileConfig object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(java.util.TreeMap h, java.lang.String name)Reads attribute values from the configuration stream which is currently open for reading.voidaddMap(java.util.TreeMap h, java.lang.String name)Adds an empty TreeMap to the specified TreeMap under the specified key name.voidaddSection(java.util.TreeMap config, java.lang.String name)Parses a configuration section (TreeMap) from the configuration stream which is currently open for reading.voidaddVector(java.util.TreeMap h, java.lang.String name)Reads a configuration Vector from the configuration stream which is currenlty open for reading.booleanfireError(java.lang.Exception error)The method tells whether a specified error should be raised or is internally handled.java.util.TreeMapgetConfig(java.lang.String key)Gets the config attribute of the FileConfig objectjava.lang.StringgetConfigPath()Gets the configPath attribute of the FileConfig objectjava.util.TreeMapgetConnector(java.lang.String name)Gets the connector attribute of the FileConfig objectjava.util.TreeMapgetForm(java.lang.String name)Gets the form attribute of the FileConfig objectjava.util.TreeMapgetInclude(java.lang.String name)Gets the include attribute of the FileConfig objectjava.util.VectorgetIncludes()Gets the includes attribute of the FileConfig objectjava.lang.ObjectgetKey(java.util.TreeMap map, java.lang.String key)Gets the key attribute of the FileConfig objectjava.util.TreeMapgetLibrary(java.lang.String name)Gets the library attribute of the FileConfig objectjava.lang.StringgetLine()Gets the line attribute of the FileConfig objectjava.util.TreeMapgetListener(java.lang.String name)Gets the listener attribute of the FileConfig objectjava.util.TreeMapgetParser(java.lang.String name)Gets the parser attribute of the FileConfig objectjava.util.TreeMapgetProperty(java.lang.String type)Gets the property attribute of the FileConfig objectjava.util.TreeMapgetScript(java.lang.String name)Gets the script attribute of the FileConfig objectjava.util.TreeMapgetTables()Gets the tables attribute of the FileConfig objectjava.util.TreeMapgetTask(java.lang.String name)Gets the task attribute of the FileConfig objectjava.lang.StringgetVersion()Returns the version string.voidincludeFile(java.lang.String path, boolean overwrite)Parses the configurations from the specified include file.voidincludeFiles(boolean first)Parses the configurations from the include files, which are currently accumulated for reading.java.util.TreeMaploadConfig()Parses the currently set configuration file.java.util.TreeMaploadConfig(byte[] data)Parses the specified configuration data.java.util.TreeMaploadConfig(java.io.BufferedReader input)Parses the specified configuration input stream.java.util.TreeMaploadConfig(java.lang.String urlPath)Parses the specified configuration file.java.util.TreeMaploadConfig2(java.lang.String urlPath)Parses the specified configuration data.java.util.TreeMaploadConfig3()Parses the configuration stream, which is currently open for reading.voidloadEncrypted()A NOOP method.voidopenInputFile(java.lang.String path)Opens the specified configuration file for reading.voidremoveIncludedComponents()Removes included components from our tables.voidsaveArray(java.io.BufferedWriter out, java.lang.String prefix, java.util.TreeMap cf)Writes the contents of the specified configuration TreeMap into the specified output stream.voidsaveConfig()Writes the internally accumulated configurations to the currently set configuration file.voidsaveConfig(java.io.BufferedWriter out)Writes the internally accumulated configurations to the specified output stream.voidsaveConfig(java.io.BufferedWriter out, java.lang.String type, java.util.TreeMap cf)Writes the configurations from the specified TreeMap into the specified output stream.voidsaveConfig(java.io.OutputStream output)Saves the configuration to an output stream.voidsaveConfig(java.util.TreeMap config)Overwrites the currently set configuration file with the configurations from the specified TreeMap.voidsaveConfig(java.util.TreeMap config, java.lang.String path)Overwrites the specified file with the configurations from the specified TreeMap.voidsaveVector(java.io.BufferedWriter out, java.lang.String prefix, java.util.Vector v)Writes the specified Vector with configurations to the specified output stream.voidsetConfig(java.lang.String key, java.lang.Object data)Sets the config attribute of the FileConfig objectvoidsetConfigPath(java.lang.String path)Sets the configPath attribute of the FileConfig objectvoidsetErrorListener(ErrorListener listener)Sets the errorListener attribute of the FileConfig objectvoidsetImport(java.util.Vector v)Sets the import attribute of the FileConfig objectvoidsetPassword(java.lang.String pwd)Sets the password attribute of the FileConfig objectvoidsetTables(java.util.TreeMap tables)Sets the tables attribute of the FileConfig objectvoidsetVersion(java.lang.String version)Sets the version string.
-
-
-
Field Detail
-
C_TASK
public static final java.lang.String C_TASK
AssemblyLine configurations are stored under this key.- See Also:
- Constant Field Values
-
C_CONNECTOR
public static final java.lang.String C_CONNECTOR
Connector configurations are stored under this key.- See Also:
- Constant Field Values
-
C_TRIGGER
public static final java.lang.String C_TRIGGER
Trigger configurations are stored under this key.- See Also:
- Constant Field Values
-
C_LISTENER
public static final java.lang.String C_LISTENER
Listener configurations are stored under this key.- See Also:
- Constant Field Values
-
C_LIBRARIES
public static final java.lang.String C_LIBRARIES
Library configurations are stored under this key.- See Also:
- Constant Field Values
-
C_PROPERTIES
public static final java.lang.String C_PROPERTIES
Properties configurations are stored under this key.- See Also:
- Constant Field Values
-
C_PARSER
public static final java.lang.String C_PARSER
ParserTypes configurations are stored under this key.- See Also:
- Constant Field Values
-
C_SCRIPTS
public static final java.lang.String C_SCRIPTS
Script configurations are stored under this key.- See Also:
- Constant Field Values
-
C_FORMDEF
public static final java.lang.String C_FORMDEF
Form configurations are stored under this key.- See Also:
- Constant Field Values
-
C_JAVAPROPERTIES
public static final java.lang.String C_JAVAPROPERTIES
Java properties configurations are stored under this key.- See Also:
- Constant Field Values
-
C_JAVALIBRARIES
public static final java.lang.String C_JAVALIBRARIES
Java libraries configurations are stored under this key.- See Also:
- Constant Field Values
-
C_MBUS
public static final java.lang.String C_MBUS
Message bus configurations are stored under this key.- See Also:
- Constant Field Values
-
C_INCLUDE
public static final java.lang.String C_INCLUDE
Includes configurations are stored under this key.- See Also:
- Constant Field Values
-
C_SECURITY
public static final java.lang.String C_SECURITY
Security configurations are stored under this key.- See Also:
- Constant Field Values
-
C_SHAREDCONN
public static final java.lang.String C_SHAREDCONN
Shared Connector configurations are stored under this key.- See Also:
- Constant Field Values
-
C_INCLUDEFILES
public static final java.lang.String C_INCLUDEFILES
Includes configurations are stored under this key.- See Also:
- Constant Field Values
-
password
public java.lang.String password
Password (key) for decrypting the configuration input stream/file. Must be null if the stream is not encrypted.
-
dontOverwriteConfig
public boolean dontOverwriteConfig
Whether newly read configurations are allowed to overwrite previously stored configurations.
-
isInclude
public boolean isInclude
Whether the configuration currently being parsed is read from an include configuration file.
-
includedFiles
public java.util.Vector includedFiles
All include configuration files (the absolute file system paths).
-
-
Constructor Detail
-
FileConfig
public FileConfig(java.lang.String path) throws java.io.IOExceptionConstructor for the FileConfig object- Parameters:
path- the file system path or URL for the configuration file (the file is not actually parsed at this time)- Throws:
java.io.IOException- a problem while constructing the object
-
-
Method Detail
-
getVersion
public java.lang.String getVersion()
Returns the version string.- Returns:
- a string representing the version
-
setVersion
public void setVersion(java.lang.String version)
Sets the version string.- Parameters:
version- a new version string to be set
-
setPassword
public void setPassword(java.lang.String pwd)
Sets the password attribute of the FileConfig object- Parameters:
pwd- The new password value
-
setErrorListener
public void setErrorListener(ErrorListener listener)
Sets the errorListener attribute of the FileConfig object- Parameters:
listener- The new errorListener value
-
setConfig
public void setConfig(java.lang.String key, java.lang.Object data)Sets the config attribute of the FileConfig object- Parameters:
key- The new config valuedata- The new config value
-
setConfigPath
public void setConfigPath(java.lang.String path)
Sets the configPath attribute of the FileConfig object- Parameters:
path- The new configPath value
-
setTables
public void setTables(java.util.TreeMap tables)
Sets the tables attribute of the FileConfig object- Parameters:
tables- The new tables value
-
setImport
public void setImport(java.util.Vector v)
Sets the import attribute of the FileConfig object- Parameters:
v- The new import value
-
getConfig
public java.util.TreeMap getConfig(java.lang.String key)
Gets the config attribute of the FileConfig object- Parameters:
key- compound key, which identifies an object in the configuration hierarchy- Returns:
- The config value
-
getConfigPath
public java.lang.String getConfigPath()
Gets the configPath attribute of the FileConfig object- Returns:
- The configPath value
-
getTables
public java.util.TreeMap getTables()
Gets the tables attribute of the FileConfig object- Returns:
- The tables value
-
getLine
public java.lang.String getLine() throws java.io.IOExceptionGets the line attribute of the FileConfig object- Returns:
- The line value
- Throws:
java.io.IOException- problem while reading the current line from the configuration file
-
getTask
public java.util.TreeMap getTask(java.lang.String name)
Gets the task attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired AssemblyLine configuration object- Returns:
- The task value
-
getIncludes
public java.util.Vector getIncludes()
Gets the includes attribute of the FileConfig object- Returns:
- The includes value
-
getConnector
public java.util.TreeMap getConnector(java.lang.String name)
Gets the connector attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Connector configuration object- Returns:
- The connector value
-
getParser
public java.util.TreeMap getParser(java.lang.String name)
Gets the parser attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Parser configuration object- Returns:
- The parser value
-
getLibrary
public java.util.TreeMap getLibrary(java.lang.String name)
Gets the library attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Library configuration object- Returns:
- The library value
-
getListener
public java.util.TreeMap getListener(java.lang.String name)
Gets the listener attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Listener configuration object- Returns:
- The listener value
-
getScript
public java.util.TreeMap getScript(java.lang.String name)
Gets the script attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Script configuration object- Returns:
- The script value
-
getProperty
public java.util.TreeMap getProperty(java.lang.String type)
Gets the property attribute of the FileConfig object- Parameters:
type- the key (simple key, not a compound one) of the desired Properties configuration object- Returns:
- The property value
-
getForm
public java.util.TreeMap getForm(java.lang.String name)
Gets the form attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Form configuration object- Returns:
- The form value
-
getInclude
public java.util.TreeMap getInclude(java.lang.String name)
Gets the include attribute of the FileConfig object- Parameters:
name- the key (simple key, not a compound one) of the desired Includes configuration object- Returns:
- The include value
-
getKey
public java.lang.Object getKey(java.util.TreeMap map, java.lang.String key)Gets the key attribute of the FileConfig object- Parameters:
map- the root configuration object of the configuration hierarchykey- a compound key, which identifies the searched configuration object in the hierarchy- Returns:
- The key value
-
loadConfig
public java.util.TreeMap loadConfig() throws java.lang.ExceptionParses the currently set configuration file. The configurations are accumulated in the state of the FileConfig object.- Returns:
- the accumulated configurations in the state of the FileConfig object
- Throws:
java.lang.Exception- problem while parsing the configuration file
-
openInputFile
public void openInputFile(java.lang.String path) throws java.lang.ExceptionOpens the specified configuration file for reading. If the file is encrypted, the password must be already set.- Parameters:
path- file system path or URL for the configuration file; if the parameter is set to "", the configuration will be read from the standard input - Throws:
java.lang.Exception- problem while opening the configuration file for reading
-
loadConfig
public java.util.TreeMap loadConfig(java.lang.String urlPath) throws java.lang.ExceptionParses the specified configuration file. Configurations are accumulated in the state of the FileConfig object.- Parameters:
urlPath- file system path or URL for the configuration file if the parameter is set to "", the configuration will be read from the standard input - Returns:
- the accumulated configurations in the state of the FileConfig object
- Throws:
java.lang.Exception- problem while parsing the configuration file
-
loadConfig
public java.util.TreeMap loadConfig(java.io.BufferedReader input) throws java.lang.ExceptionParses the specified configuration input stream. Configurations are accumulated in the state of the FileConfig object.- Parameters:
input- the configuration input stream- Returns:
- the accumulated configurations in the state of the FileConfig object
- Throws:
java.lang.Exception- problem while parsing the configuration input stream
-
loadConfig
public java.util.TreeMap loadConfig(byte[] data) throws java.lang.ExceptionParses the specified configuration data. Configurations are accumulated in the state of the FileConfig object.- Parameters:
data- the configuration data- Returns:
- the accumulated configurations in the state of the FileConfig object
- Throws:
java.lang.Exception- problem while parsing the configuration data
-
loadConfig2
public java.util.TreeMap loadConfig2(java.lang.String urlPath) throws java.lang.ExceptionParses the specified configuration data. Configurations are accumulated in the state of the FileConfig object.- Parameters:
urlPath- file system path or URL for the configuration file; if the parameter is set to "", the configuration will be read from the standard input - Returns:
- the accumulated configurations in the state of the FileConfig object
- Throws:
java.lang.Exception- problem while parsing the configuration file
-
loadConfig3
public java.util.TreeMap loadConfig3() throws java.lang.ExceptionParses the configuration stream, which is currently open for reading. Configurations are accumulated in the state of the FileConfig object.- Returns:
- the accumulated configurations in the state of the FileConfig object
- Throws:
java.lang.Exception- problem while parsing the configuration file
-
includeFiles
public void includeFiles(boolean first) throws java.lang.ExceptionParses the configurations from the include files, which are currently accumulated for reading. Configurations are accumulated in the state of the FileConfig object.- Parameters:
first- whether this is the first include file for the currently parsed configuration stream- Throws:
java.lang.Exception- problem while parsing the configurations
-
includeFile
public void includeFile(java.lang.String path, boolean overwrite) throws java.lang.ExceptionParses the configurations from the specified include file. Configurations are accumulated in the state of the FileConfig object.- Parameters:
path- the include configuration fileoverwrite- whether to overwrite existing configurations- Throws:
java.lang.Exception- problem while parsing the configurations
-
addSection
public void addSection(java.util.TreeMap config, java.lang.String name) throws java.io.IOExceptionParses a configuration section (TreeMap) from the configuration stream which is currently open for reading. The read configuration section is added in the specified TreeMap under the specified key name.- Parameters:
config- the TreeMap where the parsed section will be addedname- key name for the parsed section- Throws:
java.io.IOException- problem while parsing the configurations
-
addVector
public void addVector(java.util.TreeMap h, java.lang.String name) throws java.io.IOExceptionReads a configuration Vector from the configuration stream which is currenlty open for reading. The read Vector with configuration objects is added to the specified TreeMap under the specified key name.- Parameters:
h- the TreeMap configuration object, where the parsed Vector with configurations will be addedname- the key name for the configurations Vector- Throws:
java.io.IOException- problem while parsing the configurations
-
addMap
public void addMap(java.util.TreeMap h, java.lang.String name) throws java.io.IOExceptionAdds an empty TreeMap to the specified TreeMap under the specified key name.- Parameters:
h- the TreeMap where where the addition will happenname- the key name- Throws:
java.io.IOException- problem
-
addAttribute
public void addAttribute(java.util.TreeMap h, java.lang.String name) throws java.io.IOExceptionReads attribute values from the configuration stream which is currently open for reading. The read values are placed in a Vector and added to the specified TreeMap under the specified key name (the name of the attribute).- Parameters:
h- the TreeMap where the attrbute will be addedname- the name of the attribute- Throws:
java.io.IOException- problem while parsing the configurations
-
saveConfig
public void saveConfig() throws java.lang.ExceptionWrites the internally accumulated configurations to the currently set configuration file.- Throws:
java.lang.Exception- if a problem occurs
-
saveConfig
public void saveConfig(java.io.OutputStream output) throws java.io.IOExceptionSaves the configuration to an output stream. An EOF marker is also written. This method is used by the guiRunner in the miadmin tool.- Parameters:
output- the output stream- Throws:
java.io.IOException- problem while writing the configurations
-
saveConfig
public void saveConfig(java.util.TreeMap config, java.lang.String path) throws java.io.IOExceptionOverwrites the specified file with the configurations from the specified TreeMap.- Parameters:
config- the configuration TreeMappath- the file path- Throws:
java.io.IOException- problem while writing the configurations
-
saveConfig
public void saveConfig(java.io.BufferedWriter out) throws java.io.IOExceptionWrites the internally accumulated configurations to the specified output stream.- Parameters:
out- the output stream- Throws:
java.io.IOException- problem while writing the configurations
-
saveConfig
public void saveConfig(java.util.TreeMap config) throws java.io.IOExceptionOverwrites the currently set configuration file with the configurations from the specified TreeMap.- Parameters:
config- the configuration TreeMap- Throws:
java.io.IOException- problem while writing the configurations
-
saveConfig
public void saveConfig(java.io.BufferedWriter out, java.lang.String type, java.util.TreeMap cf) throws java.io.IOExceptionWrites the configurations from the specified TreeMap into the specified output stream. The specified TreeMap is supposed be a top-most container which hold configurations for a single category (AssemblyLines, Connectors, Forms,...).- Parameters:
out- the output streamtype- the name of the categorycf- the configurations TreeMap- Throws:
java.io.IOException- problem while writing the configurations
-
saveVector
public void saveVector(java.io.BufferedWriter out, java.lang.String prefix, java.util.Vector v) throws java.io.IOExceptionWrites the specified Vector with configurations to the specified output stream.- Parameters:
out- the output streamprefix- indentation prefixv- the configuration Vector- Throws:
java.io.IOException- problem while writing the configurations
-
saveArray
public void saveArray(java.io.BufferedWriter out, java.lang.String prefix, java.util.TreeMap cf) throws java.io.IOExceptionWrites the contents of the specified configuration TreeMap into the specified output stream. The specified TreeMap is not supposed to be a top-most container for configurations from a category (AssemblyLines, Connectors, Forms,...).- Parameters:
out- the output streamprefix- indentation prefixcf- the configuration TreeMap- Throws:
java.io.IOException- problem while writing the configurations
-
loadEncrypted
public void loadEncrypted() throws java.io.IOExceptionA NOOP method.- Throws:
java.io.IOException- problem
-
fireError
public boolean fireError(java.lang.Exception error) throws java.lang.ExceptionThe method tells whether a specified error should be raised or is internally handled.- Parameters:
error- the error object- Returns:
- true if the error should not be raised
- Throws:
java.lang.Exception- problem
-
removeIncludedComponents
public void removeIncludedComponents()
Removes included components from our tables.
-
-