org.apache.tomcat.util.digester.RuleSet Java Examples

The following examples show how to use org.apache.tomcat.util.digester.RuleSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Catalina.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Cluster support is optional. The JARs may have been removed.
 */
private void addClusterRuleSet(Digester digester, String prefix) {
    Class<?> clazz = null;
    Constructor<?> constructor = null;
    try {
        clazz = Class.forName("org.apache.catalina.ha.ClusterRuleSet");
        constructor = clazz.getConstructor(String.class);
        RuleSet ruleSet = (RuleSet) constructor.newInstance(prefix);
        digester.addRuleSet(ruleSet);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("catalina.noCluster",
                    e.getClass().getName() + ": " +  e.getMessage()), e);
        } else if (log.isInfoEnabled()) {
            log.info(sm.getString("catalina.noCluster",
                    e.getClass().getName() + ": " +  e.getMessage()));
        }
    }
}
 
Example #2
Source File: ContextConfig.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Create (if necessary) and return a Digester configured to process the
 * context configuration descriptor for an application.
 * @return the digester for context.xml files
 */
protected Digester createContextDigester() {
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.setRulesValidation(true);
    Map<Class<?>, List<String>> fakeAttributes = new HashMap<>();
    List<String> objectAttrs = new ArrayList<>();
    objectAttrs.add("className");
    fakeAttributes.put(Object.class, objectAttrs);
    // Ignore attribute added by Eclipse for its internal tracking
    List<String> contextAttrs = new ArrayList<>();
    contextAttrs.add("source");
    fakeAttributes.put(StandardContext.class, contextAttrs);
    digester.setFakeAttributes(fakeAttributes);
    RuleSet contextRuleSet = new ContextRuleSet("", false);
    digester.addRuleSet(contextRuleSet);
    RuleSet namingRuleSet = new NamingRuleSet("Context/");
    digester.addRuleSet(namingRuleSet);
    return digester;
}
 
Example #3
Source File: DigesterFactory.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Create a <code>Digester</code> parser.
 * @param xmlValidation turn on/off xml validation
 * @param xmlNamespaceAware turn on/off namespace validation
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 * @param blockExternal turn on/off the blocking of external resources
 * @return a new digester
 */
public static Digester newDigester(boolean xmlValidation,
                                   boolean xmlNamespaceAware,
                                   RuleSet rule,
                                   boolean blockExternal) {
    Digester digester = new Digester();
    digester.setNamespaceAware(xmlNamespaceAware);
    digester.setValidating(xmlValidation);
    digester.setUseContextClassLoader(true);
    EntityResolver2 resolver = new LocalResolver(SERVLET_API_PUBLIC_IDS,
            SERVLET_API_SYSTEM_IDS, blockExternal);
    digester.setEntityResolver(resolver);
    if (rule != null) {
        digester.addRuleSet(rule);
    }

    return digester;
}
 
Example #4
Source File: Catalina.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Cluster support is optional. The JARs may have been removed.
 */
private void addClusterRuleSet(Digester digester, String prefix) {
    Class<?> clazz = null;
    Constructor<?> constructor = null;
    try {
        clazz = Class.forName("org.apache.catalina.ha.ClusterRuleSet");
        constructor = clazz.getConstructor(String.class);
        RuleSet ruleSet = (RuleSet) constructor.newInstance(prefix);
        digester.addRuleSet(ruleSet);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("catalina.noCluster",
                    e.getClass().getName() + ": " +  e.getMessage()), e);
        } else if (log.isInfoEnabled()) {
            log.info(sm.getString("catalina.noCluster",
                    e.getClass().getName() + ": " +  e.getMessage()));
        }
    }
}
 
Example #5
Source File: ContextConfig.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Create (if necessary) and return a Digester configured to process the
 * context configuration descriptor for an application.
 */
protected Digester createContextDigester() {
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.setRulesValidation(true);
    HashMap<Class<?>, List<String>> fakeAttributes =
        new HashMap<Class<?>, List<String>>();
    ArrayList<String> attrs = new ArrayList<String>();
    attrs.add("className");
    fakeAttributes.put(Object.class, attrs);
    digester.setFakeAttributes(fakeAttributes);
    RuleSet contextRuleSet = new ContextRuleSet("", false);
    digester.addRuleSet(contextRuleSet);
    RuleSet namingRuleSet = new NamingRuleSet("Context/");
    digester.addRuleSet(namingRuleSet);
    return digester;
}
 
Example #6
Source File: DigesterFactory.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Create a <code>Digester</code> parser.
 * @param xmlValidation turn on/off xml validation
 * @param xmlNamespaceAware turn on/off namespace validation
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 */
public static Digester newDigester(boolean xmlValidation,
                                   boolean xmlNamespaceAware,
                                   RuleSet rule) {
    Digester digester = new Digester();
    digester.setNamespaceAware(xmlNamespaceAware);
    digester.setValidating(xmlValidation);
    digester.setUseContextClassLoader(true);

    SchemaResolver schemaResolver = new SchemaResolver(digester);
    registerLocalSchema(schemaResolver);
    
    digester.setEntityResolver(schemaResolver);
    if ( rule != null ) {
        digester.addRuleSet(rule);
    }

    return (digester);
}
 
Example #7
Source File: DigesterFactory.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Create a <code>Digester</code> parser.
 * @param xmlValidation turn on/off xml validation
 * @param xmlNamespaceAware turn on/off namespace validation
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 * @param blockExternal turn on/off the blocking of external resources
 */
public static Digester newDigester(boolean xmlValidation,
                                   boolean xmlNamespaceAware,
                                   RuleSet rule,
                                   boolean blockExternal) {
    Digester digester = new Digester();
    digester.setNamespaceAware(xmlNamespaceAware);
    digester.setValidating(xmlValidation);
    digester.setUseContextClassLoader(true);
    EntityResolver2 resolver = new LocalResolver(SERVLET_API_PUBLIC_IDS,
            SERVLET_API_SYSTEM_IDS, blockExternal);
    digester.setEntityResolver(resolver);
    if (rule != null) {
        digester.addRuleSet(rule);
    }

    return digester;
}
 
Example #8
Source File: Catalina.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Cluster support is optional. The JARs may have been removed.
 */
private void addClusterRuleSet(Digester digester, String prefix) {
    Class<?> clazz = null;
    Constructor<?> constructor = null;
    try {
        clazz = Class.forName("org.apache.catalina.ha.ClusterRuleSet");
        constructor = clazz.getConstructor(String.class);
        RuleSet ruleSet = (RuleSet) constructor.newInstance(prefix);
        digester.addRuleSet(ruleSet);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("catalina.noCluster",
                    e.getClass().getName() + ": " +  e.getMessage()), e);
        } else if (log.isInfoEnabled()) {
            log.info(sm.getString("catalina.noCluster",
                    e.getClass().getName() + ": " +  e.getMessage()));
        }
    }
}
 
Example #9
Source File: ContextConfig.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Create (if necessary) and return a Digester configured to process the
 * context configuration descriptor for an application.
 */
protected Digester createContextDigester() {
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.setRulesValidation(true);
    HashMap<Class<?>, List<String>> fakeAttributes =
        new HashMap<Class<?>, List<String>>();
    ArrayList<String> attrs = new ArrayList<String>();
    attrs.add("className");
    fakeAttributes.put(Object.class, attrs);
    digester.setFakeAttributes(fakeAttributes);
    RuleSet contextRuleSet = new ContextRuleSet("", false);
    digester.addRuleSet(contextRuleSet);
    RuleSet namingRuleSet = new NamingRuleSet("Context/");
    digester.addRuleSet(namingRuleSet);
    return digester;
}
 
Example #10
Source File: DigesterFactory.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Create a <code>Digester</code> parser.
 * @param xmlValidation turn on/off xml validation
 * @param xmlNamespaceAware turn on/off namespace validation
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 */
public static Digester newDigester(boolean xmlValidation,
                                   boolean xmlNamespaceAware,
                                   RuleSet rule) {
    Digester digester = new Digester();
    digester.setNamespaceAware(xmlNamespaceAware);
    digester.setValidating(xmlValidation);
    digester.setUseContextClassLoader(true);

    SchemaResolver schemaResolver = new SchemaResolver(digester);
    registerLocalSchema(schemaResolver);
    
    digester.setEntityResolver(schemaResolver);
    if ( rule != null ) {
        digester.addRuleSet(rule);
    }

    return (digester);
}
 
Example #11
Source File: DigesterFactory.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Create a <code>Digester</code> parser.
 * @param xmlValidation turn on/off xml validation
 * @param xmlNamespaceAware turn on/off namespace validation
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 * @param blockExternal turn on/off the blocking of external resources
 */
public static Digester newDigester(boolean xmlValidation,
                                   boolean xmlNamespaceAware,
                                   RuleSet rule,
                                   boolean blockExternal) {
    Digester digester = new Digester();
    digester.setNamespaceAware(xmlNamespaceAware);
    digester.setValidating(xmlValidation);
    digester.setUseContextClassLoader(true);
    EntityResolver2 resolver = new LocalResolver(SERVLET_API_PUBLIC_IDS,
            SERVLET_API_SYSTEM_IDS, blockExternal);
    digester.setEntityResolver(resolver);
    if (rule != null) {
        digester.addRuleSet(rule);
    }

    return digester;
}
 
Example #12
Source File: TldParser.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public TldParser(boolean namespaceAware, boolean validation, RuleSet ruleSet,
        boolean blockExternal) {
    digester = DigesterFactory.newDigester(
            validation, namespaceAware, ruleSet, blockExternal);
}
 
Example #13
Source File: DigesterFactory.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * Create a <code>Digester</code> parser with XML validation turned off.
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 *
 * @deprecated  Unused - will be removed in 8.0.x
 */
@Deprecated
public static Digester newDigester(RuleSet rule){
    return newDigester(false,false,rule);
}
 
Example #14
Source File: DigesterFactory.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * Create a <code>Digester</code> parser with XML validation turned off.
 * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
 *
 * @deprecated  Unused - will be removed in 8.0.x
 */
@Deprecated
public static Digester newDigester(RuleSet rule){
    return newDigester(false,false,rule);
}