Public Member Functions | |
ControllerParser (ControllerFactory configure) throws Exception | |
void | readXML (String xml) throws IOException, SAXException |
void | readXML (String xml, boolean validateBeforeParsing) throws IOException, SAXException |
void | readXML (FileReader fileReader, boolean validateBeforeParsing) throws IOException, SAXException |
void | fatalError (SAXParseException e) throws SAXException |
void | error (SAXParseException e) throws SAXException |
InputSource | resolveEntity (String publicId, String systemId) throws SAXException |
void | startDocument () throws SAXException |
void | endDocument () throws SAXException |
void | startElement (String uri, String localName, String name, Attributes atts) throws SAXException |
void | endElement (String uri, String localName, String name) throws SAXException |
Static Package Attributes | |
Trace | logger |
Definition at line 67 of file ControllerParser.java.
|
Creates a new
Definition at line 94 of file ControllerParser.java. 00095 { 00096 this.config = configure; 00097 this.controller = configure.getController(); 00098 00099 // Instantiate a new parser 00100 parser = XMLReaderFactory.createXMLReader(); 00101 00102 // Activate validation 00103 parser.setFeature("http://xml.org/sax/features/validation", true); 00104 00105 // Install error handler 00106 parser.setErrorHandler(this); 00107 00108 // Install document handler 00109 parser.setContentHandler(this); 00110 00111 // Install local entity resolver 00112 parser.setEntityResolver(this); 00113 }
|
|
Finalizes parsing of a document.
Definition at line 282 of file ControllerParser.java. 00283 { 00284 logger.info(Translate.get("controller.xml.done")); 00285 }
|
|
DatabasesParser for end of element.
Definition at line 360 of file ControllerParser.java. References org.objectweb.cjdbc.common.xml.XmlValidator.error(). 00362 { 00363 // We need information on what configuration are for jmx 00364 if (name.equalsIgnoreCase(ControllerXmlTags.ELT_JMX)) 00365 { 00366 try 00367 { 00368 config.setUpJmx(); 00369 } 00370 catch (JmxException jmxEx) 00371 { 00372 logger.error(Translate.get("controller.xml.jmx.setup.failed", jmxEx 00373 .getMessage()), jmxEx); 00374 } 00375 } 00376 if (name.equalsIgnoreCase(ControllerXmlTags.ELT_SECURITY)) 00377 { 00378 security.setSslConfig(ssl); 00379 ssl = null; 00380 config.setUpSecurity(security); 00381 } 00382 if (name.equalsIgnoreCase(ControllerXmlTags.ELT_RMI_JMX_ADAPTOR)) 00383 { 00384 if (ssl != null) 00385 { 00386 config.put(JmxConstants.CONNECTOR_RMI_SSL, ssl); 00387 ssl = null; 00388 } 00389 } 00390 if (name.equalsIgnoreCase(ControllerXmlTags.ELT_CONTROLLER)) 00391 { 00392 // Be sure no settings are used for report 00393 if (manager == null) 00394 { 00395 manager = new ReportManager(controller); 00396 manager.setSettings(null); 00397 controller.setReport(manager); 00398 } 00399 } 00400 logger.debug(Translate.get("controller.xml.parsing.end", name)); 00401 }
|
|
Handles notification of a recoverable parser error.
Definition at line 235 of file ControllerParser.java. References org.objectweb.cjdbc.common.xml.XmlValidator.error(). 00236 { 00237 logger.error(Translate.get("controller.xml.parsing.error", new String[]{ 00238 e.getPublicId(), String.valueOf(e.getLineNumber()), 00239 String.valueOf(e.getColumnNumber()), e.getMessage()})); 00240 throw e; 00241 }
|
|
Handles notification of a non-recoverable parser error.
Definition at line 220 of file ControllerParser.java. References org.objectweb.cjdbc.common.xml.XmlValidator.error(), and org.objectweb.cjdbc.controller.xml.ControllerParser.logger. 00221 { 00222 logger.error(Translate.get("controller.xml.parsing.fatal", new String[]{ 00223 e.getPublicId(), String.valueOf(e.getLineNumber()), 00224 String.valueOf(e.getColumnNumber()), e.getMessage()})); 00225 throw e; 00226 }
|
|
Parses an XML formatted file according to C-JDBC-controller DTD.
Definition at line 187 of file ControllerParser.java. References org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(). 00189 { 00190 if (fileReader != null) 00191 { 00192 00193 // Read the file 00194 BufferedReader in = new BufferedReader(fileReader); 00195 StringBuffer xml = new StringBuffer(); 00196 String line; 00197 do 00198 { 00199 line = in.readLine(); 00200 if (line != null) 00201 xml.append(line.trim()); 00202 } 00203 while (line != null); 00204 00205 readXML(xml.toString(), validateBeforeParsing); 00206 } 00207 else 00208 { 00209 throw new IOException("Input was null in input source."); 00210 } 00211 }
|
|
Parses an XML formatted string according to C-JDBC-controller DTD.
Definition at line 141 of file ControllerParser.java. References org.objectweb.cjdbc.common.xml.XmlValidator.error(), org.objectweb.cjdbc.common.xml.XmlValidator.getExceptions(), org.objectweb.cjdbc.common.xml.XmlValidator.getWarnings(), org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid, org.objectweb.cjdbc.common.xml.XmlValidator.isValid(), org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid, org.objectweb.cjdbc.controller.xml.ControllerParser.logger, and org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(). 00143 { 00144 if (validateBeforeParsing) 00145 { 00146 XmlValidator validator = new XmlValidator( 00147 ControllerConstants.C_JDBC_CONTROLLER_DTD_FILE, xml.toString()); 00148 if (logger.isDebugEnabled()) 00149 { 00150 if (validator.isDtdValid()) 00151 logger.debug(Translate.get("controller.xml.dtd.validated")); 00152 if (validator.isXmlValid()) 00153 logger.debug(Translate.get("controller.xml.document.validated")); 00154 } 00155 00156 if (validator.getWarnings().size() > 0) 00157 { 00158 ArrayList warnings = validator.getWarnings(); 00159 for (int i = 0; i < warnings.size(); i++) 00160 logger.warn(Translate.get("virtualdatabase.xml.parsing.warning", 00161 warnings.get(i))); 00162 } 00163 00164 if (!validator.isDtdValid()) 00165 logger.error(Translate.get("controller.xml.dtd.not.validated")); 00166 if (!validator.isXmlValid()) 00167 logger.error(Translate.get("controller.xml.document.not.validated")); 00168 00169 ArrayList errors = validator.getExceptions(); 00170 for (int i = 0; i < errors.size(); i++) 00171 logger.error(((Exception) errors.get(i)).getMessage()); 00172 00173 if (!validator.isValid()) 00174 throw new SAXException(ExceptionTypes.XML_DOCUMENT_INVALID); 00175 } 00176 readXML(xml); 00177 }
|
|
Parses an XML content according to C-JDBC-controller DTD.
Definition at line 122 of file ControllerParser.java. Referenced by org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(), and org.objectweb.cjdbc.controller.core.ControllerFactory.setUpByXml(). 00123 { 00124 if (xml != null) 00125 { 00126 InputSource input = new InputSource(new StringReader(xml)); 00127 parser.parse(input); 00128 } 00129 else 00130 throw new IOException("Input was null in input source."); 00131 }
|
|
Allows to parse the document with a local copy of the DTD whatever the original
Definition at line 251 of file ControllerParser.java. 00253 { 00254 logger.debug(Translate.get("controller.xml.dtd.using", 00255 ControllerConstants.C_JDBC_CONTROLLER_DTD_FILE)); 00256 InputStream stream = ControllerParser.class.getResourceAsStream("/" 00257 + ControllerConstants.C_JDBC_CONTROLLER_DTD_FILE); 00258 if (stream == null) 00259 { 00260 throw new SAXException(Translate.get("controller.xml.dtd.not.found", 00261 ControllerConstants.C_JDBC_CONTROLLER_DTD_FILE)); 00262 } 00263 00264 return new InputSource(stream); 00265 }
|
|
Initializes parsing of a document.
Definition at line 272 of file ControllerParser.java. 00273 { 00274 logger.debug(Translate.get("controller.xml.parsing.document")); 00275 }
|
|
Analyzes an element first line.
Definition at line 296 of file ControllerParser.java. 00298 { 00299 logger.debug(Translate.get("controller.xml.parsing.start", name)); 00300 if (name.equalsIgnoreCase(ControllerXmlTags.ELT_CONTROLLER)) 00301 configureController(atts); 00302 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_INTERNATIONALIZATION)) 00303 { 00304 Locale.setDefault(new Locale(atts 00305 .getValue(ControllerXmlTags.ATT_LANGUAGE), "")); 00306 } 00307 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_REPORT)) 00308 configureReport(atts); 00309 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_JMX)) 00310 { 00311 config.put(ControllerFactory.JMX_ENABLE, "true"); 00312 } 00313 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_HTTP_JMX_ADAPTOR)) 00314 configureHttpJmxAdaptor(atts); 00315 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_RMI_JMX_ADAPTOR)) 00316 configureRmiJmxAdaptor(atts); 00317 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_SSL)) 00318 configureSSL(atts); 00319 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_VIRTUAL_DATABASE)) 00320 configureVirtualDatabase(atts); 00321 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_SECURITY)) 00322 { 00323 security = new ControllerSecurityManager(); 00324 boolean connect = new Boolean(atts 00325 .getValue(ControllerXmlTags.ATT_DEFAULT_CONNECT)).booleanValue(); 00326 security.setDefaultConnect(connect); 00327 } 00328 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_JAR)) 00329 { 00330 boolean allow = new Boolean(atts 00331 .getValue(ControllerXmlTags.ATT_JAR_ALLOW_DRIVER)).booleanValue(); 00332 security.setAllowAdditionalDriver(allow); 00333 } 00334 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_CLIENT)) 00335 configureClient(atts); 00336 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_CONSOLE)) 00337 configureConsole(atts); 00338 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_ACCEPT)) 00339 parseAccept = true; 00340 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_BLOCK)) 00341 parseAccept = false; 00342 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_HOSTNAME)) 00343 security.addHostToSecureList(atts.getValue(ControllerXmlTags.ATT_VALUE), 00344 parseAccept); 00345 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_IPADDRESS)) 00346 security.addHostToSecureList(atts.getValue(ControllerXmlTags.ATT_VALUE), 00347 parseAccept); 00348 else if (name.equalsIgnoreCase(ControllerXmlTags.ELT_IPRANGE)) 00349 configureIpRange(atts); 00350 }
|
|
Initial value: Trace .getLogger(ControllerParser.class .getName()) Definition at line 70 of file ControllerParser.java. Referenced by org.objectweb.cjdbc.controller.xml.ControllerParser.fatalError(), and org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(). |