List of usage examples for org.apache.commons.digester WithDefaultsRulesWrapper addDefault
public void addDefault(Rule rule)
From source file:org.ajax4jsf.renderkit.compiler.HtmlCompiler.java
/** * Constructor with initialisation.//ww w .j a v a 2 s . c o m */ public HtmlCompiler() { WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new RulesBase()); // Add default rules to process plain tags. rules.addDefault(new PlainElementCreateRule()); rules.addDefault(new SetNextRule(CHILD_METHOD)); digestr.setDocumentLocator(new LocatorImpl()); digestr.setRules(rules); digestr.setValidating(false); digestr.setNamespaceAware(false); digestr.setUseContextClassLoader(true); // Concrete renderer method call rules. setCustomRules(digestr); }
From source file:org.xchain.framework.digester.AnnotationRuleSet.java
public void addRuleInstances(Digester digester) { // log what we are attempting to do. // set up the namespace in the digester. digester.setNamespaceAware(true);/*from ww w .j a v a 2 s . c o m*/ // add the place holder rule used to pass mappings when there is not an element to pass them on... // TODO: add code for the place holder command. LifecycleContext lifecycleContext = Lifecycle.getLifecycleContext(); for (NamespaceContext namespaceContext : lifecycleContext.getNamespaceContextMap().values()) { digester.setRuleNamespaceURI(namespaceContext.getNamespaceUri()); for (Class classObject : namespaceContext.getCatalogList()) { // for catalogs that we find, we need to add a create rule, a properties rule, a set next rule, and a registration rule. addRulesForCatalog(digester, classObject, lifecycleContext); } for (Class classObject : namespaceContext.getCommandList()) { // for commands that we find, we need to add a create rule, a properties rule, a set next rule, and a registration rule. addRulesForCommand(digester, lifecycleContext, systemId, classObject); } } WithDefaultsRulesWrapper defaults = new WithDefaultsRulesWrapper(digester.getRules()); defaults.addDefault(new UnknownElementRule()); digester.setRules(defaults); }
From source file:org.xchain.tools.monitoring.MonitoringMojo.java
private void mergeWarMonitoringInfo(MonitoringInfo monitoringInfo, File file) throws MojoExecutionException { JarFile artifactJar = null;/* ww w . java2 s . c o m*/ JarEntry monitoringInfoEntry = null; InputStream in = null; try { getLog().info("Getting monitoring info from file " + file.toString()); artifactJar = new JarFile(file); monitoringInfoEntry = artifactJar.getJarEntry("WEB-INF/classes/META-INF/monitoring-info.xml"); if (monitoringInfoEntry != null) { in = artifactJar.getInputStream(monitoringInfoEntry); // digest the xml file and get all of the entries. Digester digester = new Digester(); digester.push(monitoringInfo); digester.addRuleSet(new MonitoringInfoRuleSet()); WithDefaultsRulesWrapper wrapper = new WithDefaultsRulesWrapper(digester.getRules()); wrapper.addDefault(new LoggingRule()); digester.setRules(wrapper); digester.parse(in); } else { getLog().info("Monitoring info file not found in " + file.toString()); } } catch (SAXException se) { throw new MojoExecutionException("Could not parse a monitoring-info.xml file.", se); } catch (IOException ioe) { throw new MojoExecutionException("Could not open jar file.", ioe); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { getLog().warn("Could not close a jar entry input stream.", ioe); } } try { artifactJar.close(); } catch (IOException ioe) { getLog().warn("Could not close a jar.", ioe); } } }