Example usage for org.apache.commons.digester Digester setDebug

List of usage examples for org.apache.commons.digester Digester setDebug

Introduction

In this page you can find the example usage for org.apache.commons.digester Digester setDebug.

Prototype

@Deprecated
public void setDebug(int debug) 

Source Link

Document

Set the debugging detail level of our currently enabled logger.

Usage

From source file:catalina.core.StandardHostDeployer.java

/**
 * <p>Install a new web application, whose context configuration file
 * (consisting of a <code>&lt;Context&gt;</code> element) and (optional)
 * web application archive are at the specified URLs.</p>
 *
 * If this application is successfully installed, a ContainerEvent of type
 * <code>PRE_INSTALL_EVENT</code> will be sent to registered listeners
 * before the associated Context is started, and a ContainerEvent of type
 * <code>INSTALL_EVENT</code> will be sent to all registered listeners
 * after the associated Context is started, with the newly created
 * <code>Context</code> as an argument.
 *
 * @param config A URL that points to the context configuration descriptor
 *  to be used for configuring the new Context
 * @param war A URL of type "jar:" that points to a WAR file, or type
 *  "file:" that points to an unpacked directory structure containing
 *  the web application to be installed, or <code>null</code> to use
 *  the <code>docBase</code> attribute from the configuration descriptor
 *
 * @exception IllegalArgumentException if one of the specified URLs is
 *  null//from   www .  j  a v a 2  s .co m
 * @exception IllegalStateException if the context path specified in the
 *  context configuration file is already attached to an existing web
 *  application
 * @exception IOException if an input/output error was encountered
 *  during installation
 */
public synchronized void install(URL config, URL war) throws IOException {

    // Validate the format and state of our arguments
    if (config == null)
        throw new IllegalArgumentException(sm.getString("standardHost.configRequired"));

    if (!host.isDeployXML())
        throw new IllegalArgumentException(sm.getString("standardHost.configNotAllowed"));

    // Calculate the document base for the new web application (if needed)
    String docBase = null; // Optional override for value in config file
    if (war != null) {
        String url = war.toString();
        host.log(sm.getString("standardHost.installingWAR", url));
        // Calculate the WAR file absolute pathname
        if (url.startsWith("jar:")) {
            url = url.substring(4, url.length() - 2);
        }
        if (url.startsWith("file://"))
            docBase = url.substring(7);
        else if (url.startsWith("file:"))
            docBase = url.substring(5);
        else
            throw new IllegalArgumentException(sm.getString("standardHost.warURL", url));

    }

    // Install the new web application
    this.context = null;
    this.overrideDocBase = docBase;
    InputStream stream = null;
    try {
        stream = config.openStream();
        Digester digester = createDigester();
        digester.setDebug(host.getDebug());
        digester.clear();
        digester.push(this);
        digester.parse(stream);
        stream.close();
        stream = null;
    } catch (Exception e) {
        host.log(sm.getString("standardHost.installError", docBase), e);
        throw new IOException(e.toString());
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (Throwable t) {
                ;
            }
        }
    }

}

From source file:catalina.startup.Catalina.java

/**
 * Create and configure the Digester we will be using for shutdown.
 *//*from w w w .  j av  a 2s.c o m*/
protected Digester createStopDigester() {

    // Initialize the digester
    Digester digester = new Digester();
    if (debug)
        digester.setDebug(999);

    // Configure the rules we need for shutting down
    digester.addObjectCreate("Server", "org.apache.catalina.core.StandardServer", "className");
    digester.addSetProperties("Server");
    digester.addSetNext("Server", "setServer", "org.apache.catalina.Server");

    return (digester);

}

From source file:catalina.startup.Catalina.java

/**
 * Create and configure the Digester we will be using for startup.
 */// w  w w  . j  a va 2s.c  om
protected Digester createStartDigester() {

    // Initialize the digester
    Digester digester = new Digester();
    if (debug)
        digester.setDebug(999);
    digester.setValidating(false);

    // Configure the actions we will be using
    digester.addObjectCreate("Server", "org.apache.catalina.core.StandardServer", "className");
    digester.addSetProperties("Server");
    digester.addSetNext("Server", "setServer", "org.apache.catalina.Server");

    digester.addObjectCreate("Server/GlobalNamingResources", "org.apache.catalina.deploy.NamingResources");
    digester.addSetProperties("Server/GlobalNamingResources");
    digester.addSetNext("Server/GlobalNamingResources", "setGlobalNamingResources",
            "org.apache.catalina.deploy.NamingResources");

    digester.addObjectCreate("Server/Listener", null, // MUST be specified in the element
            "className");
    digester.addSetProperties("Server/Listener");
    digester.addSetNext("Server/Listener", "addLifecycleListener", "org.apache.catalina.LifecycleListener");

    digester.addObjectCreate("Server/Service", "org.apache.catalina.core.StandardService", "className");
    digester.addSetProperties("Server/Service");
    digester.addSetNext("Server/Service", "addService", "org.apache.catalina.Service");

    digester.addObjectCreate("Server/Service/Listener", null, // MUST be specified in the element
            "className");
    digester.addSetProperties("Server/Service/Listener");
    digester.addSetNext("Server/Service/Listener", "addLifecycleListener",
            "org.apache.catalina.LifecycleListener");

    digester.addObjectCreate("Server/Service/Connector", "org.apache.catalina.connector.http.HttpConnector",
            "className");
    digester.addSetProperties("Server/Service/Connector");
    digester.addSetNext("Server/Service/Connector", "addConnector", "org.apache.catalina.Connector");

    digester.addObjectCreate("Server/Service/Connector/Factory",
            "org.apache.catalina.net.DefaultServerSocketFactory", "className");
    digester.addSetProperties("Server/Service/Connector/Factory");
    digester.addSetNext("Server/Service/Connector/Factory", "setFactory",
            "org.apache.catalina.net.ServerSocketFactory");

    digester.addObjectCreate("Server/Service/Connector/Listener", null, // MUST be specified in the element
            "className");
    digester.addSetProperties("Server/Service/Connector/Listener");
    digester.addSetNext("Server/Service/Connector/Listener", "addLifecycleListener",
            "org.apache.catalina.LifecycleListener");

    // Add RuleSets for nested elements
    digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/"));
    digester.addRuleSet(new EngineRuleSet("Server/Service/"));
    digester.addRuleSet(new HostRuleSet("Server/Service/Engine/"));
    digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Default"));
    digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/DefaultContext/"));
    digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/Default"));
    digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/DefaultContext/"));
    digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/"));
    digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/"));

    digester.addRule("Server/Service/Engine", new SetParentClassLoaderRule(digester, parentClassLoader));

    return (digester);

}