Java 类org.apache.catalina.Deployer 实例源码

项目:jerrydog    文件:HostConfig.java   
/**
 * Deploy applications for any directories or WAR files that are found
 * in our "application root" directory.
 */
protected void deployApps() {

    if (!(host instanceof Deployer))
        return;
    if (debug >= 1)
        log(sm.getString("hostConfig.deploying"));

    File appBase = appBase();
    if (!appBase.exists() || !appBase.isDirectory())
        return;
    String files[] = appBase.list();

    deployDescriptors(appBase, files);
    deployWARs(appBase, files);
    deployDirectories(appBase, files);

}
项目:jerrydog    文件:HostConfig.java   
/**
 * Undeploy all deployed applications.
 */
protected void undeployApps() {

    if (!(host instanceof Deployer))
        return;
    if (debug >= 1)
        log(sm.getString("hostConfig.undeploying"));

    String contextPaths[] = ((Deployer) host).findDeployedApps();
    for (int i = 0; i < contextPaths.length; i++) {
        if (debug >= 1)
            log(sm.getString("hostConfig.undeploy", contextPaths[i]));
        try {
            ((Deployer) host).remove(contextPaths[i]);
        } catch (Throwable t) {
            log(sm.getString("hostConfig.undeploy.error",
                             contextPaths[i]), t);
        }
    }

}
项目:HowTomcatWorks    文件:HostConfig.java   
/**
 * Deploy applications for any directories or WAR files that are found
 * in our "application root" directory.
 */
protected void deployApps() {

    if (!(host instanceof Deployer))
        return;
    if (debug >= 1)
        log(sm.getString("hostConfig.deploying"));

    File appBase = appBase();
    if (!appBase.exists() || !appBase.isDirectory())
        return;
    String files[] = appBase.list();

    deployDescriptors(appBase, files);
    deployWARs(appBase, files);
    deployDirectories(appBase, files);

}
项目:HowTomcatWorks    文件:HostConfig.java   
/**
 * Undeploy all deployed applications.
 */
protected void undeployApps() {

    if (!(host instanceof Deployer))
        return;
    if (debug >= 1)
        log(sm.getString("hostConfig.undeploying"));

    String contextPaths[] = ((Deployer) host).findDeployedApps();
    for (int i = 0; i < contextPaths.length; i++) {
        if (debug >= 1)
            log(sm.getString("hostConfig.undeploy", contextPaths[i]));
        try {
            ((Deployer) host).remove(contextPaths[i]);
        } catch (Throwable t) {
            log(sm.getString("hostConfig.undeploy.error",
                             contextPaths[i]), t);
        }
    }

}
项目:psi-probe-plus    文件:Tomcat50ContainerAdaptor.java   
public void setWrapper(Wrapper wrapper) {
    if (wrapper != null) {
        this.deployer = (Deployer) wrapper.getParent().getParent();
        ((Host)this.deployer).getPipeline().addValve(valve);
    } else if (deployer != null ){
        ((Host)this.deployer).getPipeline().removeValve(valve);
    }
}
项目:jerrydog    文件:HostConfig.java   
/**
 * Deploy XML context descriptors.
 */
protected void deployDescriptors(File appBase, String[] files) {

    if (!deployXML)
       return;

    for (int i = 0; i < files.length; i++) {

        if (files[i].equalsIgnoreCase("META-INF"))
            continue;
        if (files[i].equalsIgnoreCase("WEB-INF"))
            continue;
        if (deployed.contains(files[i]))
            continue;
        File dir = new File(appBase, files[i]);
        if (files[i].toLowerCase().endsWith(".xml")) {

            deployed.add(files[i]);

            // Calculate the context path and make sure it is unique
            String file = files[i].substring(0, files[i].length() - 4);
            String contextPath = "/" + file;
            if (file.equals("ROOT")) {
                contextPath = "";
            }
            if (host.findChild(contextPath) != null) {
                continue;
            }

            // Assume this is a configuration descriptor and deploy it
            log(sm.getString("hostConfig.deployDescriptor", files[i]));
            try {
                URL config =
                    new URL("file", null, dir.getCanonicalPath());
                ((Deployer) host).install(config, null);
            } catch (Throwable t) {
                log(sm.getString("hostConfig.deployDescriptor.error",
                                 files[i]), t);
            }

        }

    }

}
项目:jerrydog    文件:HostConfig.java   
/**
 * Deploy directories.
 */
protected void deployDirectories(File appBase, String[] files) {

    for (int i = 0; i < files.length; i++) {

        if (files[i].equalsIgnoreCase("META-INF"))
            continue;
        if (files[i].equalsIgnoreCase("WEB-INF"))
            continue;
        if (deployed.contains(files[i]))
            continue;
        File dir = new File(appBase, files[i]);
        if (dir.isDirectory()) {

            deployed.add(files[i]);

            // Make sure there is an application configuration directory
            // This is needed if the Context appBase is the same as the
            // web server document root to make sure only web applications
            // are deployed and not directories for web space.
            File webInf = new File(dir, "/WEB-INF");
            if (!webInf.exists() || !webInf.isDirectory() ||
                !webInf.canRead())
                continue;

            // Calculate the context path and make sure it is unique
            String contextPath = "/" + files[i];
            if (files[i].equals("ROOT"))
                contextPath = "";
            if (host.findChild(contextPath) != null)
                continue;

            // Deploy the application in this directory
            log(sm.getString("hostConfig.deployDir", files[i]));
            try {
                URL url = new URL("file", null, dir.getCanonicalPath());
                ((Deployer) host).install(contextPath, url);
            } catch (Throwable t) {
                log(sm.getString("hostConfig.deployDir.error", files[i]),
                    t);
            }

        }

    }

}
项目:HowTomcatWorks    文件:HostConfig.java   
/**
 * Deploy XML context descriptors.
 */
protected void deployDescriptors(File appBase, String[] files) {

    if (!deployXML)
       return;

    for (int i = 0; i < files.length; i++) {

        if (files[i].equalsIgnoreCase("META-INF"))
            continue;
        if (files[i].equalsIgnoreCase("WEB-INF"))
            continue;
        if (deployed.contains(files[i]))
            continue;
        File dir = new File(appBase, files[i]);
        if (files[i].toLowerCase().endsWith(".xml")) {

            deployed.add(files[i]);

            // Calculate the context path and make sure it is unique
            String file = files[i].substring(0, files[i].length() - 4);
            String contextPath = "/" + file;
            if (file.equals("ROOT")) {
                contextPath = "";
            }
            if (host.findChild(contextPath) != null) {
                continue;
            }

            // Assume this is a configuration descriptor and deploy it
            log(sm.getString("hostConfig.deployDescriptor", files[i]));
            try {
                URL config =
                    new URL("file", null, dir.getCanonicalPath());
                ((Deployer) host).install(config, null);
            } catch (Throwable t) {
                log(sm.getString("hostConfig.deployDescriptor.error",
                                 files[i]), t);
            }

        }

    }

}
项目:HowTomcatWorks    文件:HostConfig.java   
/**
 * Deploy directories.
 */
protected void deployDirectories(File appBase, String[] files) {

    for (int i = 0; i < files.length; i++) {

        if (files[i].equalsIgnoreCase("META-INF"))
            continue;
        if (files[i].equalsIgnoreCase("WEB-INF"))
            continue;
        if (deployed.contains(files[i]))
            continue;
        File dir = new File(appBase, files[i]);
        if (dir.isDirectory()) {

            deployed.add(files[i]);

            // Make sure there is an application configuration directory
            // This is needed if the Context appBase is the same as the
            // web server document root to make sure only web applications
            // are deployed and not directories for web space.
            File webInf = new File(dir, "/WEB-INF");
            if (!webInf.exists() || !webInf.isDirectory() ||
                !webInf.canRead())
                continue;

            // Calculate the context path and make sure it is unique
            String contextPath = "/" + files[i];
            if (files[i].equals("ROOT"))
                contextPath = "";
            if (host.findChild(contextPath) != null)
                continue;

            // Deploy the application in this directory
            log(sm.getString("hostConfig.deployDir", files[i]));
            try {
                URL url = new URL("file", null, dir.getCanonicalPath());
                ((Deployer) host).install(contextPath, url);
            } catch (Throwable t) {
                log(sm.getString("hostConfig.deployDir.error", files[i]),
                    t);
            }

        }

    }

}