public class ConfigManager extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static String |
C_ProtocolClassPath |
protected Map |
myConfigMap |
protected Config |
myConfigroot |
protected String |
myConfigrootPath |
protected String |
myConfigRootRessouceName |
protected static ConfigManager |
singleton |
| Constructor and Description |
|---|
ConfigManager(String aConfigRootRessouceName)
Creates a new ConfigManager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cacheConfig(Config aConfig,
String aConfigName)
put the config into the cache
|
void |
clearCache()
remove all cached configs from the cache
|
static ConfigManager |
createForClasspath() |
protected XMLReader |
createParser()
initialize lazy and return the receiver's script instance
ready to be used.
|
Config |
getCachedConfig(String aConfigName) |
Config |
getConfig(String configname)
get or read the config named configname.
|
Config |
getConfig(String configname,
boolean allowNullReturn) |
Config |
getConfig(String aConfigname,
String aPath)
return the config with the given name from the cache.
|
Config |
getConfig(String aConfigName,
String aPath,
boolean isRelativeFlag)
return the config with the given name from the cache.
|
Config |
getConfigRoot() |
String |
getConfigRootPath() |
Config |
getConfigUncached(String configname)
the same as
this#getConfig(java.lang.String) but the
config is read from file and not cached. |
static ConfigManager |
getDefault() |
Config |
parseConfig(String aConfigXMLString) |
protected void |
parseResource(XMLReader aParser,
String aPath)
parse either from a file or the classpath
|
protected void |
parseString(XMLReader aParser,
String aConfigXMLString)
parse xml in the given string
|
Config |
readConfig(String aPath)
open and parse the file name given in path.
|
Config |
readConfig(String aPath,
boolean isRelativeFlag)
open and parse the file name given in path.
|
protected String |
readConfigrootPath() |
protected String |
readConfigrootPath(String aResourceName) |
static String |
readRessource(ClassLoader aClassLoader,
String aResourceName) |
static String |
resolvePath(String theResPath) |
void |
setConfigRootPath(String aConfigRootPath)
directly set the config root path.
|
static URL |
toURL(String path) |
static List<URL> |
toURLs(String path) |
void |
uncacheConfig(Config aConfig)
remove the config from the cache
|
String |
writeConfig(Config aConfig) |
void |
writeConfig(Config aConfig,
PrintWriter aPrintWriter) |
public static final String C_ProtocolClassPath
protected static ConfigManager singleton
protected final String myConfigRootRessouceName
protected Config myConfigroot
protected String myConfigrootPath
protected Map myConfigMap
public ConfigManager(String aConfigRootRessouceName)
aConfigRootRessouceName - the resource name (file) in the classpath that contains
the absolute config root path. If the resource cannot be found, the config manager tries
to access a system property with the same name. If such a system property exists,
its value is used as the config root path.
The default configrootressourcename is "configroot.ini".public static ConfigManager createForClasspath()
public static ConfigManager getDefault()
public Config readConfig(String aPath, boolean isRelativeFlag)
protected void parseString(XMLReader aParser, String aConfigXMLString) throws IOException, SAXException
aParser - - the parse to useaConfigXMLString - - the xml to parseIOExceptionSAXExceptionprotected void parseResource(XMLReader aParser, String aPath) throws IOException, SAXException
IOExceptionSAXExceptionpublic static URL toURL(String path) throws MalformedURLException
MalformedURLExceptionpublic static List<URL> toURLs(String path) throws IOException
IOExceptionprotected XMLReader createParser()
public Config readConfig(String aPath)
public void writeConfig(Config aConfig, PrintWriter aPrintWriter) throws IOException
IOExceptionpublic String writeConfig(Config aConfig) throws IOException
IOExceptionpublic Config getConfig(String aConfigname, String aPath)
public Config getConfig(String aConfigName, String aPath, boolean isRelativeFlag)
isRelativeFlag - - is true when the path is relative to configroot, so that
the absolute path will be created. - is false, when the path should not be modified.public Config getCachedConfig(String aConfigName)
public Config getConfig(String configname)
IllegalArgumentException - if the config is unknownpublic Config getConfigUncached(String configname)
this#getConfig(java.lang.String) but the
config is read from file and not cached.configname - public Config getConfigRoot()
public void cacheConfig(Config aConfig, String aConfigName)
public void uncacheConfig(Config aConfig)
public void clearCache()
public String getConfigRootPath()
public void setConfigRootPath(String aConfigRootPath)
protected String readConfigrootPath()
public static String readRessource(ClassLoader aClassLoader, String aResourceName)
Copyright © 2008–2018. All rights reserved.