|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.xml.config.XmlConfig
public class XmlConfig
The XmlConfig class is a generic xml configuration reader, supporting features like referred configuration blocks, accessing system property values and program invocation parameters (args of the main method).
| Nested Class Summary | |
|---|---|
static class |
XmlConfig.ResolveKey
Key elements be used in {...} brackets, will be resolved by the corresponding content. |
static class |
XmlConfig.XmlAttribute
Predefined and recognized xml attributes. |
static class |
XmlConfig.XmlElement
Predefined and recognized xml elements |
| Field Summary | |
|---|---|
protected String[] |
mArgs
|
protected Document |
mDocument
|
protected Date |
mTimestamp
|
static String |
NO_APP_NAME
|
| Constructor Summary | |
|---|---|
protected |
XmlConfig(String appName,
Document xmlDoc)
|
protected |
XmlConfig(String appName,
Document xmlDoc,
String[] args)
|
| Method Summary | |
|---|---|
static XmlConfig |
fromXmlDocument(Document doc)
Parses the given document and returns an XmlConfig instance. |
static XmlConfig |
fromXmlDocument(File file)
Parses the given document and returns an XmlConfig instance. |
static XmlConfig |
fromXmlDocument(Reader reader)
Parses the given document and returns an XmlConfig instance. |
String |
getAppName()
|
protected String |
getArg(int index)
|
protected int |
getArgCount()
|
Element |
getConfig(String name)
|
Element |
getDefaultConfig()
|
Properties |
getLoggingProperties()
Returns the logging properties read from the logging element, or null if no logging properties found in the xml config. |
Properties |
getLoggingProperties(String configName)
Returns the logging properties read from the logging element, or null if no logging properties found in the xml config. |
protected List<Element> |
getReferredElementContent(String name,
String path)
|
protected String |
getResolvedAttributeValue(Attribute att,
String path,
String resolveKey)
|
protected Element |
getRootElement()
|
static XmlConfig |
getXmlConfig(File xmlFile)
|
static XmlConfig |
getXmlConfig(File xmlFile,
String[] args)
|
static XmlConfig |
getXmlConfig(InputStream xmlFile)
|
static XmlConfig |
getXmlConfig(InputStream xmlFile,
String[] args)
|
static XmlConfig |
getXmlConfig(Reader xmlFile)
|
static XmlConfig |
getXmlConfig(String appName,
File xmlFile)
|
static XmlConfig |
getXmlConfig(String appName,
File xmlFile,
String[] args)
|
static XmlConfig |
getXmlConfig(String appName,
InputStream xmlFile)
|
static XmlConfig |
getXmlConfig(String appName,
InputStream xmlFile,
String[] args)
|
static XmlConfig |
getXmlConfig(String appName,
Reader xmlFile)
|
void |
initLogManagerConfiguration()
Initializes the log manager configuration with logging configuration from the the default config. |
void |
initLogManagerConfiguration(String configName)
Initializes the log manager configuration with logging configuration from the the specified config. |
void |
printUsage(PrintStream stream,
String usageName)
|
protected List<Element> |
resolve(Element element,
String path)
|
protected void |
resolveAttributeValue(Attribute att,
String path)
|
void |
setAppName(String appName)
|
void |
setDefaultConfig(String name)
|
Document |
toXmlDocument()
Returns a copy of the underlying xml document, including main arguments if any have been specified. |
void |
writeTo(OutputStream out)
Writes this xml config to the given output stream |
void |
writeTo(Writer writer)
Writes this xml config to the given writer |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String NO_APP_NAME
protected final Document mDocument
protected final String[] mArgs
protected final Date mTimestamp
| Constructor Detail |
|---|
protected XmlConfig(String appName,
Document xmlDoc)
protected XmlConfig(String appName,
Document xmlDoc,
String[] args)
| Method Detail |
|---|
public static XmlConfig getXmlConfig(File xmlFile)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(Reader xmlFile)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(InputStream xmlFile)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(String appName,
File xmlFile)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(String appName,
Reader xmlFile)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(String appName,
InputStream xmlFile)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(File xmlFile,
String[] args)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(InputStream xmlFile,
String[] args)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(String appName,
File xmlFile,
String[] args)
throws DocumentException
DocumentException
public static XmlConfig getXmlConfig(String appName,
InputStream xmlFile,
String[] args)
throws DocumentException
DocumentExceptionpublic void writeTo(OutputStream out)
public void writeTo(Writer writer)
public Document toXmlDocument()
public static XmlConfig fromXmlDocument(File file)
throws DocumentException
toXmlDocument().
DocumentException - if a dom4j xml exception occurs
public static XmlConfig fromXmlDocument(Reader reader)
throws DocumentException
toXmlDocument().
DocumentException - if a dom4j xml exception occurspublic static XmlConfig fromXmlDocument(Document doc)
toXmlDocument().
protected int getArgCount()
protected String getArg(int index)
protected Element getRootElement()
public String getAppName()
public void setAppName(String appName)
public void setDefaultConfig(String name)
public Element getDefaultConfig()
throws XmlConfigException
XmlConfigException
public Element getConfig(String name)
throws XmlConfigException
XmlConfigException
protected List<Element> resolve(Element element,
String path)
throws XmlConfigException
XmlConfigException
protected void resolveAttributeValue(Attribute att,
String path)
throws XmlConfigException
XmlConfigException
protected String getResolvedAttributeValue(Attribute att,
String path,
String resolveKey)
throws XmlConfigException
XmlConfigException
protected List<Element> getReferredElementContent(String name,
String path)
throws XmlConfigException,
MissingReferableException
XmlConfigException
MissingReferableException
public void initLogManagerConfiguration()
throws XmlConfigException
default config. Calls
LogManager.readConfiguration(InputStream) with
properties read from the logging element.
The logging element is expected to look like this:
...
XmlConfigException - if an xml configuration error occurs
public void initLogManagerConfiguration(String configName)
throws XmlConfigException
config. Calls
LogManager.readConfiguration(InputStream) with
properties read from the logging element.
The logging element is expected to look like this:
...
configName - the config to use, corresponds to
getConfig(String)
XmlConfigException - if an xml configuration error occurs
public Properties getLoggingProperties()
throws XmlConfigException
null if no logging properties found in the xml config.
The logging element is expected to look like this:
...
XmlConfigException - if an xml configuration error occurs
public Properties getLoggingProperties(String configName)
throws XmlConfigException
null if no logging properties found in the xml config.
The logging element is expected to look like this:
...
configName - the config to use, corresponds to
getConfig(String)
XmlConfigException - if an xml configuration error occurs
public void printUsage(PrintStream stream,
String usageName)
throws XmlConfigException
XmlConfigException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||