org.logicalcobwebs.proxool.configuration
Class XMLConfigurator
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.logicalcobwebs.proxool.configuration.XMLConfigurator
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
public class XMLConfigurator
- extends org.xml.sax.helpers.DefaultHandler
A SAX 2 ContentHandler that can configure Proxool from an XML source.
This is just a ContentHandler, so you must associate it with a SAX parser for it to actually do anything.
If you have JAXP available JAXPConfigurator
will do this for you.
Properties that you pass on to the delegate driver have to be treated specially. They
must be contained within a <driver-properties> element.
See the Proxool properties for documentation
on the available configuration properties.
Example configuration:
<proxool>
<alias>apple</alias>
<driver-url>jdbc:hsqldb:.</driver-url>
<driver-class>org.hsqldb.jdbcDriver</driver-class>
<driver-properties>
<property name="user" value="abc" />
<property name="password" value="def" />
</driver-properties>
<house-keeping-sleep-time>40000</house-keeping-sleep-time>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
<maximum-connection-count>10</maximum-connection-count>
<minimum-connection-count>3</minimum-connection-count>
<maximum-connection-lifetime>18000000</maximum-connection-lifetime> <!-- 5 hours -->
<simultaneous-build-throttle>5</simultaneous-build-throttle>
<recently-started-threshold>40000</recently-started-threshold>
<overload-without-refusal-lifetime>50000</overload-without-refusal-lifetime>
<maximum-active-time>60000</maximum-active-time>
<verbose>true</verbose>
<trace>true</trace>
<fatal-sql-exception>ORA-1234</fatal-sql-exception>
<prototype-count>2</prototype-count>
</proxool>
When the parser reaches the end of the <proxool> element the pool
is automatically registered. You can contain the <proxool> element
in any other elements as you wish. And the <proxool> element can
occur as many times as you wish. This allows you to use an XML file that
configures your whole application as the source. This configurator will
ignore everything apart from the elements contained within the <proxool>
element.
Validation
A couple of additional steps are required if you want your SAX parser to validate your Proxool xml confguration:
-
Put your proxool configuration elements inside a root
proxool-config
element.
The document must adhere to the Proxool dtd.
-
Add a
DOCTYPE
entry to your xml with a system id containing the absolute url to the Proxool
dtd. The Proxool jar contains a copy of the Proxool dtd in the confguration package. You can reference that with
a jar url like this:
<!DOCTYPE proxool-config SYSTEM "jar:file:///C:/Proxool/lib/proxool.jar!/org/logicalcobwebs/proxool/configuration/proxool.dtd">
-
Configure your parser to be validating. In the
JAXPConfigurator
this is done by passing true
as
the second arghument to any of the configure
methods.
This class is not thread safe.
- Version:
- $Revision: 1.17 $, $Date: 2003/03/05 23:28:56 $
- Author:
- billhorsman, $Author: billhorsman $ (current maintainer)
Method Summary |
void |
characters(char[] chars,
int start,
int length)
|
void |
endElement(java.lang.String uri,
java.lang.String lname,
java.lang.String qname)
|
void |
error(org.xml.sax.SAXParseException e)
|
void |
fatalError(org.xml.sax.SAXParseException e)
|
void |
startElement(java.lang.String uri,
java.lang.String lname,
java.lang.String qname,
org.xml.sax.Attributes attributes)
|
void |
warning(org.xml.sax.SAXParseException e)
|
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XMLConfigurator
public XMLConfigurator()
startElement
public void startElement(java.lang.String uri,
java.lang.String lname,
java.lang.String qname,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
- Specified by:
startElement
in interface org.xml.sax.ContentHandler
- Overrides:
startElement
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
characters
public void characters(char[] chars,
int start,
int length)
throws org.xml.sax.SAXException
- Specified by:
characters
in interface org.xml.sax.ContentHandler
- Overrides:
characters
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- See Also:
ContentHandler.characters(char[], int, int)
endElement
public void endElement(java.lang.String uri,
java.lang.String lname,
java.lang.String qname)
throws org.xml.sax.SAXException
- Specified by:
endElement
in interface org.xml.sax.ContentHandler
- Overrides:
endElement
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
warning
public void warning(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
- Specified by:
warning
in interface org.xml.sax.ErrorHandler
- Overrides:
warning
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- See Also:
ErrorHandler.warning(SAXParseException)
error
public void error(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
- Specified by:
error
in interface org.xml.sax.ErrorHandler
- Overrides:
error
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- See Also:
ErrorHandler.error(SAXParseException)
fatalError
public void fatalError(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
- Specified by:
fatalError
in interface org.xml.sax.ErrorHandler
- Overrides:
fatalError
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
- See Also:
ErrorHandler.fatalError(SAXParseException)