Refine search
private XmlErrorHandler tldScanStream(InputStream resourceStream) throws IOException { InputSource source = new InputSource(resourceStream); XmlErrorHandler result = new XmlErrorHandler(); synchronized (tldDigester) { try { tldDigester.setErrorHandler(result); tldDigester.push(this); tldDigester.parse(source); } catch (SAXException s) { // Hack - makes exception handling simpler throw new IOException(s); } finally { tldDigester.reset(); } return result; } }
/** * @return a configured <code>Digester</code> to use for processing * the XML input file, creating a new one if necessary. */ protected synchronized Digester getDigester() { if (digester == null) { digester = new Digester(); digester.setValidating(false); try { digester.setFeature( "http://apache.org/xml/features/allow-java-encodings", true); } catch (Exception e) { log.warn(sm.getString("memoryRealm.xmlFeatureEncoding"), e); } digester.addRuleSet(new MemoryRuleSet()); } return digester; }
/** * Create the digester which will be used to parse context config files. */ protected static Digester createDigester(String contextClassName) { Digester digester = new Digester(); digester.setValidating(false); // Add object creation rule digester.addObjectCreate("Context", contextClassName, "className"); // Set the properties on that object (it doesn't matter if extra // properties are set) digester.addSetProperties("Context"); return (digester); }
private void addRuleInstances(Digester digester, String pattern, String methodName) { digester.addObjectCreate(pattern, null /* MUST be specified in the element */, "className"); digester.addSetProperties(pattern); digester.addSetNext(pattern, methodName, "org.apache.catalina.CredentialHandler"); } }
@Override public void addRuleInstances(Digester digester) { digester.addCallMethod(PREFIX, "addPlugin", 2); digester.addCallParam(PREFIX + "/tag-class", 0); digester.addCallParam(PREFIX + "/plugin-class", 1); } }
if (log.isDebugEnabled()) log.debug("Processing context [" + context.getName() + "] configuration file [" + contextXml + "]"); source = new InputSource(contextXml.toString()); stream = contextXml.openStream(); } catch (Exception e) { log.error(sm.getString("contextConfig.contextMissing", contextXml) , e); source.setByteStream(stream); digester.setClassLoader(this.getClass().getClassLoader()); digester.setUseContextClassLoader(false); digester.push(context.getParent()); digester.push(context); XmlErrorHandler errorHandler = new XmlErrorHandler(); digester.setErrorHandler(errorHandler); digester.parse(source); if (errorHandler.getWarnings().size() > 0 || errorHandler.getErrors().size() > 0) { errorHandler.logFindings(log, contextXml.toString()); ok = false; log.error(sm.getString("contextConfig.contextParse", context.getName()), e); log.error(sm.getString("contextConfig.defaultPosition", "" + e.getLineNumber(), "" + e.getColumnNumber()));
public void parse(URL url) throws IOException, SAXException { try (InputStream is = url.openStream()) { XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); digester.push(this); InputSource source = new InputSource(url.toExternalForm()); source.setByteStream(is); digester.parse(source); if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) { handler.logFindings(log, source.getSystemId()); if (!handler.getErrors().isEmpty()) { // throw the first to indicate there was a error during processing throw handler.getErrors().iterator().next(); } } } finally { digester.reset(); } }
try (FileInputStream fis = new FileInputStream(file)) { InputSource is = new InputSource(file.toURI().toURL().toString()); is.setByteStream(fis); digester.push(this); digester.parse(is); } catch (Exception e) { log.error(sm.getString("catalina.stopError"), e); System.exit(1); s.stop(); } catch (LifecycleException e) { log.error(sm.getString("catalina.stopError"), e); log.error(sm.getString("catalina.stopServer.connectException", s.getAddress(), String.valueOf(s.getPortWithOffset()), String.valueOf(s.getPort()), String.valueOf(s.getPortOffset())));
InputSource inputSource = new InputSource(resource.getURI().toURL().toString()); inputSource.setByteStream(inputStream); digester.push(this); digester.parse(inputSource); } catch (Exception e) { if (file == null) { log.warn(sm.getString("catalina.configFail", getConfigFile() + "] or [server-embed.xml"), e); } else { log.warn(sm.getString("catalina.configFail", file.getAbsolutePath()), e); if (file.exists() && !file.canRead()) { log.warn(sm.getString("catalina.incorrectPermissions"));
InputSource is = new InputSource(url.toExternalForm()); is.setByteStream(stream); contextDigester.push(context); try contextDigester.parse(is); log.error("Parse error in context.xml for " + context.getName(), e); contextDigester.reset(); try log.error("Error closing context.xml for " + context.getName(), e); log.debug("Done processing " + Constants.ApplicationContextXml + " descriptor");
new BufferedInputStream(new FileInputStream(file)); InputSource is = new InputSource(file.toURI().toURL().toExternalForm()); is.setByteStream(stream); digester.parse(is); handleOutput("web.xml validated"); } catch (Exception e) {
this.lastModified = resource.getURI().toURL().openConnection().getLastModified(); Digester digester = new Digester(); try { digester.setFeature( "http://apache.org/xml/features/allow-java-encodings", true); } catch (Exception e) { log.warn(sm.getString("memoryUserDatabase.xmlFeatureEncoding"), e); digester.addFactoryCreate("tomcat-users/group", new MemoryGroupCreationFactory(this), true); digester.addFactoryCreate("tomcat-users/role", new MemoryRoleCreationFactory(this), true); digester.addFactoryCreate("tomcat-users/user", new MemoryUserCreationFactory(this), true); digester.parse(resource.getInputStream()); } catch (IOException ioe) { log.error(sm.getString("memoryUserDatabase.fileNotFound", pathName)); } catch (Exception e) {
/** * Process the beginning of this element. * * @param attributes The attribute list of this element */ public void begin(Attributes attributes) throws Exception { // Identify the name of the class to instantiate String realClassName = className; if (attributeName != null) { String value = attributes.getValue(attributeName); if (value != null) { realClassName = value; } } if (digester.log.isDebugEnabled()) { digester.log.debug("[ObjectCreateRule]{" + digester.match + "}New " + realClassName); } // Instantiate the new object and push it on the context stack Class clazz = digester.getClassLoader().loadClass(realClassName); Object instance = clazz.newInstance(); digester.push(instance); }
@Override public void begin(String namespace, String name, Attributes attributes) throws Exception { SSLHostConfig sslHostConfig = (SSLHostConfig)digester.peek(); Type type; String typeValue = attributes.getValue("type"); if (typeValue == null || typeValue.length() == 0) { type = Type.UNDEFINED; } else { type = Type.valueOf(typeValue); } SSLHostConfigCertificate certificate = new SSLHostConfigCertificate(sslHostConfig, type); digester.push(certificate); }
public TaglibXml parse(TldResourcePath path) throws IOException, SAXException { try (InputStream is = path.openStream()) { XmlErrorHandler handler = new XmlErrorHandler(); digester.setErrorHandler(handler); TaglibXml taglibXml = new TaglibXml(); digester.push(taglibXml); InputSource source = new InputSource(path.toExternalForm()); source.setByteStream(is); digester.parse(source); if (!handler.getWarnings().isEmpty() || !handler.getErrors().isEmpty()) { handler.logFindings(log, source.getSystemId()); if (!handler.getErrors().isEmpty()) { // throw the first to indicate there was a error during processing throw handler.getErrors().iterator().next(); } } return taglibXml; } finally { digester.reset(); } }
digester.setClassLoader(Thread.currentThread().getContextClassLoader()); File file = configFile(); try { InputSource is = new InputSource("file://" + file.getAbsolutePath()); FileInputStream fis = new FileInputStream(file); is.setByteStream(fis); digester.push(this); digester.parse(is); fis.close(); } catch (Exception e) {
public void begin(Attributes attributes) throws Exception { // Look up the required parent class loader Container container = (Container) digester.peek(); ClassLoader parentClassLoader = container.getParentClassLoader(); // Instantiate a new Loader implementation object String className = loaderClass; if (attributeName != null) { String value = attributes.getValue(attributeName); if (value != null) className = value; } Class<?> clazz = Class.forName(className); Class types[] = { ClassLoader.class }; Object args[] = { parentClassLoader }; Constructor constructor = clazz.getDeclaredConstructor(types); Loader loader = (Loader) constructor.newInstance(args); // Push the new loader onto the stack digester.push(loader); if (digester.getDebug() >= 1) digester.log("new " + loader.getClass().getName()); }
@Override public void begin(String namespace, String name, Attributes attributes) throws Exception { ServletDef servletDef = new ServletDef(); digester.push(servletDef); if (digester.getLogger().isDebugEnabled()) digester.getLogger().debug("new " + servletDef.getClass().getName()); }
try (InputStream is = ConfigFileLoader.getInputStream(pathName)) { if (log.isDebugEnabled()) { log.debug(sm.getString("memoryRealm.loadPath", pathName)); try { synchronized (digester) { digester.push(this); digester.parse(is); throw new LifecycleException(sm.getString("memoryRealm.readXml"), e); } finally { digester.reset(); throw new LifecycleException(sm.getString("memoryRealm.loadExist", pathName), ioe);