| java.lang.Object org.cougaar.util.ConfigFinder
All known Subclasses: org.cougaar.util.jar.JarConfigFinder,
ConfigFinder | public class ConfigFinder (Code) | | ConfigFinder provides utilitites to search for a named file in
several specified locations, returning the first location where a
file by that name is found.
Files are found and opened by the open() method. open() tries to
find the file using each of the elements of org.cougaar.config.path. The
elements of org.cougaar.config.path are separated by semicolons and
interpreted as URLs. The URLs in org.cougaar.config.path are interpreted
relative to the directory specified by org.cougaar.install.path. Several
special tokens may appear in these URLs:
$RUNTIME signifies <org.cougaar.runtime.path>
$SOCIETY signifies <org.cougaar.society.path>
$INSTALL signifies <org.cougaar.install.path>
$CONFIG signifies <org.cougaar.config>
$CWD signifies <user.dir>
$HOME signifies <user.home>
$MOD signifies the name of a Cougaar module - a sub-directory of $INSTALL
The default value for org.cougaar.config.path is defined in the static
variable DEFAULT_CONFIG_PATH:
$CWD;\
$RUNTIME/configs/$CONFIG;\
$RUNTIME/configs/common;\
$SOCIETY/configs/$CONFIG;\
$SOCIETY/configs/common;\
$INSTALL/configs/$CONFIG;\
$INSTALL/configs/common
If a value is specified for org.cougaar.config.path that ends with a
semicolon, the above default is appended to the specified
value. The URLs in org.cougaar.config.path are interpreted relative to
$INSTALL. URLs may be absolute in which case some or all of the
base URL may be ignored.
By default, $MOD is not set. However, when an object requests
a ConfigFinder, it may specify a String value for $MOD. If specified,
the search path used is augmented, adding 9 directories to the start
of the search path:
- $RUNTIME/$MOD/configs/$CONFIG
- $RUNTIME/$MOD/configs
- $RUNTIME/$MOD/data/$CONFIG
- $RUNTIME/$MOD/data
- $SOCIETY/$MOD/configs/$CONFIG
- $SOCIETY/$MOD/configs
- $SOCIETY/$MOD/data/$CONFIG
- $SOCIETY/$MOD/data
- $INSTALL/$MOD/configs/$CONFIG
- $INSTALL/$MOD/configs
- $INSTALL/$MOD/data/$CONFIG
- $INSTALL/$MOD/data
Enable INFO level logging on org.cougaar.core.util.ConfigFinder to turn on
additional information on usage of ConfigFinder.
|
Field Summary | |
final protected HashMap | urlCache Cache of the String to URL mappings found. |
Constructor Summary | |
public | ConfigFinder() | public | ConfigFinder(String configpath) | public | ConfigFinder(String module, String configpath) | public | ConfigFinder(String configpath, Map props) | public | ConfigFinder(String module, String configpath, Map props) Construct a ConfigFinder that will first search within
the specified module, and then in the directories on the
given search path, using the given Property substitutions.
When searching the given module, we search the following 8
directories (if defined) before any other directories:
- $RUNTIME/$module/configs/$CONFIG
- $RUNTIME/$module/configs
- $RUNTIME/$module/data/$CONFIG
- $RUNTIME/$module/data
- $SOCIETY/$module/configs/$CONFIG
- $SOCIETY/$module/configs
- $SOCIETY/$module/data/$CONFIG
- $SOCIETY/$module/data
- $INSTALL/$module/configs/$CONFIG
- $INSTALL/$module/configs
- $INSTALL/$module/data/$CONFIG
- $INSTALL/$module/data
Parameters: module - name of the module to use for module-specific configs. |
urlCache | final protected HashMap urlCache(Code) | | Cache of the String to URL mappings found.
|
ConfigFinder | public ConfigFinder()(Code) | | Alias for ConfigFinder(null, null, null)
|
ConfigFinder | public ConfigFinder(String configpath)(Code) | | Alias for ConfigFinder(null, path, null)
|
ConfigFinder | public ConfigFinder(String module, String configpath)(Code) | | Alias for ConfigFinder(module, configpath, null)
|
ConfigFinder | public ConfigFinder(String configpath, Map props)(Code) | | Alias for ConfigFinder(null, configpath, props)
|
ConfigFinder | public ConfigFinder(String module, String configpath, Map props)(Code) | | Construct a ConfigFinder that will first search within
the specified module, and then in the directories on the
given search path, using the given Property substitutions.
When searching the given module, we search the following 8
directories (if defined) before any other directories:
- $RUNTIME/$module/configs/$CONFIG
- $RUNTIME/$module/configs
- $RUNTIME/$module/data/$CONFIG
- $RUNTIME/$module/data
- $SOCIETY/$module/configs/$CONFIG
- $SOCIETY/$module/configs
- $SOCIETY/$module/data/$CONFIG
- $SOCIETY/$module/data
- $INSTALL/$module/configs/$CONFIG
- $INSTALL/$module/configs
- $INSTALL/$module/data/$CONFIG
- $INSTALL/$module/data
Parameters: module - name of the module to use for module-specific configs. If null, no module-specific paths are added. Parameters: configpath - configuration path string. If null, defaults to Configuration.getConfigPath(); Parameters: props - properties to use for configpath variable substitutions. |
find | public URL find(String aURL) throws IOException(Code) | | Attempt to find the URL which would be opened by the open method.
Note that this must actually attempt to open the various URLs
under consideration, so this is not an inexpensive operation.
|
getConfigPath | public List getConfigPath()(Code) | | get the config path as an unmodifiable List of URL instances
which describes, in order, the set of base locations searched by
this instance of the ConfigFinder.
Contrast with Configuration.getConfigPath() which returns the
vm's default path.
|
getConfigResolver | protected ConfigResolver getConfigResolver()(Code) | | |
getInstance | public static ConfigFinder getInstance()(Code) | | Return the default static instance of the ConfigFinder,
configured using the system properties.
|
getInstance | public static ConfigFinder getInstance(String module)(Code) | | Return a new ConfigFinder that uses the system properties
for most configuration details, adding the four module-specific
directories to the front of the search path.
|
getLogger | final protected synchronized Logger getLogger()(Code) | | |
locateFile | public File locateFile(String aFilename)(Code) | | Locate an actual file in the config path. This will skip over
elements of org.cougaar.config.path that are not file: urls.
|
open | public InputStream open(String aURL) throws IOException(Code) | | Opens an InputStream to access the named file. The file is sought
in all the places specified in configPath.
throws: IOException - if the resource cannot be found. |
parseXMLConfigFile | protected Document parseXMLConfigFile(InputStream isstream, String xmlfile)(Code) | | parse an XML stream in the context of the current configuration environment.
This means that embedded references to relative XML objects must be resolved
via the configfinder rather than the stream itself.
|
resolveName | public URL resolveName(String logicalName) throws MalformedURLException(Code) | | Resolve a logical reference to a URL, e.g.
will convert "$INSTALL/configs/common/foo.txt" to
"file:/opt/cougaar/20030331/configs/common/foo.txt"
or somesuch.
null if unresolvable. |
substituteProperties | final protected String substituteProperties(String s)(Code) | | Do variable expansion/substitution on the argument.
Essentially calls Configuration.substituteProperties(s, myproperties);
|
|
|