Java Code Examples for org.apache.tomcat.util.digester.Digester#setValidating()

The following examples show how to use org.apache.tomcat.util.digester.Digester#setValidating() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
Source File: HostConfig.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Create the digester which will be used to parse context config files.
 * @param contextClassName The class which will be used to create the
 *  context instance
 * @return the digester
 */
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;
}
 
Example 10
Source File: StoreLoader.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Create and configure the Digester we will be using for setup store
 * registry.
 * @return the XML digester that will be used to parse the configuration
 */
protected static Digester createDigester() {
    long t1 = System.currentTimeMillis();
    // Initialize the digester
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.setClassLoader(StoreRegistry.class.getClassLoader());

    // Configure the actions we will be using
    digester.addObjectCreate("Registry",
            "org.apache.catalina.storeconfig.StoreRegistry", "className");
    digester.addSetProperties("Registry");
    digester
            .addObjectCreate("Registry/Description",
                    "org.apache.catalina.storeconfig.StoreDescription",
                    "className");
    digester.addSetProperties("Registry/Description");
    digester.addRule("Registry/Description", new StoreFactoryRule(
            "org.apache.catalina.storeconfig.StoreFactoryBase",
            "storeFactoryClass",
            "org.apache.catalina.storeconfig.StoreAppender",
            "storeAppenderClass"));
    digester.addSetNext("Registry/Description", "registerDescription",
            "org.apache.catalina.storeconfig.StoreDescription");
    digester.addCallMethod("Registry/Description/TransientAttribute",
            "addTransientAttribute", 0);
    digester.addCallMethod("Registry/Description/TransientChild",
            "addTransientChild", 0);

    long t2 = System.currentTimeMillis();
    if (log.isDebugEnabled())
        log.debug("Digester for server-registry.xml created " + (t2 - t1));
    return digester;

}
 
Example 11
Source File: HostConfig.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: HostConfig.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: MbeansDescriptorsDigesterSource.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
private static Digester createDigester() {

        Digester digester = new Digester();
        digester.setNamespaceAware(false);
        digester.setValidating(false);
        URL url = Registry.getRegistry(null, null).getClass().getResource
            ("/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd");
        digester.register
            ("-//Apache Software Foundation//DTD Model MBeans Configuration File",
                url.toString());

        // Configure the parsing rules
        digester.addObjectCreate
            ("mbeans-descriptors/mbean",
            "org.apache.tomcat.util.modeler.ManagedBean");
        digester.addSetProperties
            ("mbeans-descriptors/mbean");
        digester.addSetNext
            ("mbeans-descriptors/mbean",
                "add",
            "java.lang.Object");

        digester.addObjectCreate
            ("mbeans-descriptors/mbean/attribute",
            "org.apache.tomcat.util.modeler.AttributeInfo");
        digester.addSetProperties
            ("mbeans-descriptors/mbean/attribute");
        digester.addSetNext
            ("mbeans-descriptors/mbean/attribute",
                "addAttribute",
            "org.apache.tomcat.util.modeler.AttributeInfo");

        digester.addObjectCreate
            ("mbeans-descriptors/mbean/notification",
            "org.apache.tomcat.util.modeler.NotificationInfo");
        digester.addSetProperties
            ("mbeans-descriptors/mbean/notification");
        digester.addSetNext
            ("mbeans-descriptors/mbean/notification",
                "addNotification",
            "org.apache.tomcat.util.modeler.NotificationInfo");

        digester.addObjectCreate
            ("mbeans-descriptors/mbean/notification/descriptor/field",
            "org.apache.tomcat.util.modeler.FieldInfo");
        digester.addSetProperties
            ("mbeans-descriptors/mbean/notification/descriptor/field");
        digester.addSetNext
            ("mbeans-descriptors/mbean/notification/descriptor/field",
                "addField",
            "org.apache.tomcat.util.modeler.FieldInfo");

        digester.addCallMethod
            ("mbeans-descriptors/mbean/notification/notification-type",
                "addNotifType", 0);

        digester.addObjectCreate
            ("mbeans-descriptors/mbean/operation",
            "org.apache.tomcat.util.modeler.OperationInfo");
        digester.addSetProperties
            ("mbeans-descriptors/mbean/operation");
        digester.addSetNext
            ("mbeans-descriptors/mbean/operation",
                "addOperation",
            "org.apache.tomcat.util.modeler.OperationInfo");

        digester.addObjectCreate
            ("mbeans-descriptors/mbean/operation/descriptor/field",
            "org.apache.tomcat.util.modeler.FieldInfo");
        digester.addSetProperties
            ("mbeans-descriptors/mbean/operation/descriptor/field");
        digester.addSetNext
            ("mbeans-descriptors/mbean/operation/descriptor/field",
                "addField",
            "org.apache.tomcat.util.modeler.FieldInfo");

        digester.addObjectCreate
            ("mbeans-descriptors/mbean/operation/parameter",
            "org.apache.tomcat.util.modeler.ParameterInfo");
        digester.addSetProperties
            ("mbeans-descriptors/mbean/operation/parameter");
        digester.addSetNext
            ("mbeans-descriptors/mbean/operation/parameter",
                "addParameter",
            "org.apache.tomcat.util.modeler.ParameterInfo");

        return digester;

    }