|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.config.XMLConfiguration
Provides a XML-based tool for constructing and configuring server applications.
A Dwarf-based application consisting of group of servers and services can be
described using the XML language. This class then loads and parses the given XML
configuration data and instantiates and configures the whole server application
via the getService()
method.
A sample code using the XMLConfiguration class:
public static void main(String[] args) throws Exception { // load the XML configuration data XMLConfiguration config = new XMLConfiguration("file:conf/tutorial.xml"); // instantiate the server application MainServer s = (MainServer)config.getService(); // initialize and start the application s.init(null); s.start(); }
Constructor Summary | |
XMLConfiguration(org.w3c.dom.Document document)
Creates a new XMLConfiguration instance. |
|
XMLConfiguration(java.lang.String url)
Creates a new XMLConfiguration instance. |
Method Summary | |
org.w3c.dom.Document |
getDocument()
Returns the XML configuration data as a DOM object. |
int |
getObjectCount()
Returns the total number of services created by the getService() method. |
Service |
getService()
Creates a service instance from the XML configuration data. |
static void |
setAttribute(java.lang.Object obj,
java.lang.String name,
java.lang.String value)
Sets the object's attribute. |
static void |
setValidation(boolean value)
Enables or disables validation of the XML data. |
static void |
setVerbosity(boolean value)
Enables or disables verbose operation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XMLConfiguration(java.lang.String url) throws XMLConfigurationException
It loads and parses the given XML document. If the validation is enabled, the XML
document will be validated against its DTD. Validation is enabled by default and can be
turned on or off via the static setValidation(boolean)
method.
url
- the URL of the XML configuration data
XMLConfigurationException
- if an error occured during the loading of the XML datapublic XMLConfiguration(org.w3c.dom.Document document) throws XMLConfigurationException
The document argument must reference a valid XML configuration data as described by its DTD.
document
- the XML configuration data
XMLConfigurationException
- if an error occuredMethod Detail |
public Service getService() throws XMLConfigurationException
It returns a service instance referenced by the top-level <service> tag in the XML configuration document.
XMLConfigurationException
- if an error occuredpublic static void setAttribute(java.lang.Object obj, java.lang.String name, java.lang.String value) throws java.lang.Exception
This method sets the object's attribute through the traditional setter method. A call to setAttribute(service, "attribute", "value") is valid if the object referenced by the service argument declares a public setAttribute method with an argument of one of the following types:
InetHost
- see the documentation for the classInetHostSet
- see the documentation for the classStringProperties
- see the documentation for the class
obj
- the objectname
- the attribute namevalue
- the attribute value
java.lang.Exception
- if the setting failspublic static void setVerbosity(boolean value)
If enabled, a detailed information about every XML element processed by the
getService()
method is printed to the standard output stream.
The verbose operation is disabled by default.
value
- true to enable verbose operationgetService()
public static void setValidation(boolean value)
If enabled, the XML document will be validated against its DTD.
The validation is enabled by default.
value
- true to enable validationpublic org.w3c.dom.Document getDocument()
public int getObjectCount()
getService()
method.
getService()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |