org.objectweb.cjdbc.controller.xml
Class ControllerParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.objectweb.cjdbc.controller.xml.ControllerParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ControllerParser
extends org.xml.sax.helpers.DefaultHandler

Allows to parse an XML content containing the description of the controller confirming to C-JDBC-controller.dtd.

Version:
1.0
Author:
Emmanuel Cecchet , Nicolas Modrzyk

Field Summary
private  ControllerFactory config
          C-JDBC controller to setup.
private  Controller controller
           
private  java.lang.String controllerIP
           
(package private) static Trace logger
          Logger instance.
private  ReportManager manager
           
private  boolean parseAccept
           
private  org.xml.sax.XMLReader parser
          XML parser.
private  ControllerSecurityManager security
           
private  SSLConfiguration ssl
           
 
Constructor Summary
ControllerParser(ControllerFactory configure)
          Creates a new ControllerParser instance.
 
Method Summary
private  void configureClient(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_CLIENT element.
private  void configureConsole(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_CONSOLE element.
private  void configureController(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_CONTROLLER element.
private  void configureHttpJmxAdaptor(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_HTTP_JMX_ADAPTOR element.
private  void configureIpRange(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_IPRANGE element.
private  void configureReport(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_REPORT element.
private  void configureRmiJmxAdaptor(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_RMI_JMX_ADAPTOR element.
private  void configureSSL(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_SSL element.
private  void configureVirtualDatabase(org.xml.sax.Attributes atts)
          Configure a ControllerXmlTags.ELT_VIRTUAL_DATABASE element.
 void endDocument()
          Finalizes parsing of a document.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String name)
          DatabasesParser for end of element.
 void error(org.xml.sax.SAXParseException e)
          Handles notification of a recoverable parser error.
 void fatalError(org.xml.sax.SAXParseException e)
          Handles notification of a non-recoverable parser error.
 void readXML(java.io.FileReader fileReader, boolean validateBeforeParsing)
          Parses an XML formatted file according to C-JDBC-controller DTD.
 void readXML(java.lang.String xml)
          Parses an XML content according to C-JDBC-controller DTD.
 void readXML(java.lang.String xml, boolean validateBeforeParsing)
          Parses an XML formatted string according to C-JDBC-controller DTD.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          Allows to parse the document with a local copy of the DTD whatever the original DOCTYPE found.
 void startDocument()
          Initializes parsing of a document.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts)
          Analyzes an element first line.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static Trace logger
Logger instance.


parser

private org.xml.sax.XMLReader parser
XML parser.


config

private ControllerFactory config
C-JDBC controller to setup.


security

private ControllerSecurityManager security

controller

private Controller controller

parseAccept

private boolean parseAccept

ssl

private SSLConfiguration ssl

controllerIP

private java.lang.String controllerIP

manager

private ReportManager manager
Constructor Detail

ControllerParser

public ControllerParser(ControllerFactory configure)
                 throws java.lang.Exception
Creates a new ControllerParser instance. This method Instanciates also a new ControllerHandler.

Parameters:
configure - a ControllerFactory object that contains the configuration to update with values from xml parsing
Throws:
java.lang.Exception - if an error occurs
Method Detail

readXML

public void readXML(java.lang.String xml)
             throws java.io.IOException,
                    org.xml.sax.SAXException
Parses an XML content according to C-JDBC-controller DTD.

Parameters:
xml - a String containing the XML content to parse
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs

readXML

public void readXML(java.lang.String xml,
                    boolean validateBeforeParsing)
             throws java.io.IOException,
                    org.xml.sax.SAXException
Parses an XML formatted string according to C-JDBC-controller DTD.

Parameters:
xml - a String reference to the xml to parse
validateBeforeParsing - if validation should be checked before parsing
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs

readXML

public void readXML(java.io.FileReader fileReader,
                    boolean validateBeforeParsing)
             throws java.io.IOException,
                    org.xml.sax.SAXException
Parses an XML formatted file according to C-JDBC-controller DTD.

Parameters:
fileReader - a FileReader reference to the xml to parse
validateBeforeParsing - if validation should be checked before parsing
Throws:
org.xml.sax.SAXException - if an error occurs
java.io.IOException - if an error occurs

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Handles notification of a non-recoverable parser error.

Parameters:
e - the warning information encoded as an exception.
Throws:
org.xml.sax.SAXException - any SAX exception, possibly wrapping another exception.

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Handles notification of a recoverable parser error.

Parameters:
e - the warning information encoded as an exception.
Throws:
org.xml.sax.SAXException - any SAX exception, possibly wrapping another exception

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
Allows to parse the document with a local copy of the DTD whatever the original DOCTYPE found. Warning, this method is called only if the XML document contains a DOCTYPE.

Throws:
org.xml.sax.SAXException
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Initializes parsing of a document.

Throws:
org.xml.sax.SAXException - unspecialized error

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Finalizes parsing of a document.

Throws:
org.xml.sax.SAXException - unspecialized error

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Analyzes an element first line.

Parameters:
uri - name space URI
localName - local name
name - element raw name
atts - element attributes
Throws:
org.xml.sax.SAXException - if an error occurs

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String name)
                throws org.xml.sax.SAXException
DatabasesParser for end of element.

Parameters:
uri - name space URI
localName - local name
name - element raw name
Throws:
org.xml.sax.SAXException - if an error occurs

configureClient

private void configureClient(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_CLIENT element.

Parameters:
atts - the parser attributes

configureConsole

private void configureConsole(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_CONSOLE element.

Parameters:
atts - the parser attributes

configureController

private void configureController(org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXException
Configure a ControllerXmlTags.ELT_CONTROLLER element.

Parameters:
atts - the parser attributes
Throws:
org.xml.sax.SAXException - if an error occurs

configureHttpJmxAdaptor

private void configureHttpJmxAdaptor(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_HTTP_JMX_ADAPTOR element.

Parameters:
atts - the parser attributes

configureIpRange

private void configureIpRange(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_IPRANGE element.

Parameters:
atts - the parser attributes

configureReport

private void configureReport(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_REPORT element.

Parameters:
atts - the parser attributes

configureRmiJmxAdaptor

private void configureRmiJmxAdaptor(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_RMI_JMX_ADAPTOR element.

Parameters:
atts - the parser attributes

configureSSL

private void configureSSL(org.xml.sax.Attributes atts)
Configure a ControllerXmlTags.ELT_SSL element.

Parameters:
atts - the parser attributes

configureVirtualDatabase

private void configureVirtualDatabase(org.xml.sax.Attributes atts)
                               throws org.xml.sax.SAXException
Configure a ControllerXmlTags.ELT_VIRTUAL_DATABASE element.

Parameters:
atts - the parser attributes
Throws:
org.xml.sax.SAXException - if an error occurs


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.