Package org.apache.catalina.core

Examples of org.apache.catalina.core.StandardHost


            int toModify, boolean resultXml, boolean resultWar,
            boolean resultDir, String resultCookieName, int resultAction,
            LifecycleState resultState) throws Exception {

        Tomcat tomcat = getTomcatInstance();
        StandardHost host = (StandardHost) tomcat.getHost();

        // Init
        File xml = null;
        File ext = null;
        File war = null;
        File dir = null;

        if (startXml && !startExternalWar && !startExternalDir) {
            xml = createXmlInConfigBaseForAppbase();
        }
        if (startExternalWar) {
            ext = createWar(WAR_XML_SOURCE, false);
            xml = createXmlInConfigBaseForExternal(ext);
        }
        if (startExternalDir) {
            ext = createDirInAppbase(true);
            xml = createXmlInConfigBaseForExternal(ext);
        }
        if (startWar) {
            war = createWar(WAR_XML_SOURCE, true);
        }
        if (startDir) {
            dir = createDirInAppbase(true);
        }

        if ((startWar || startExternalWar) && !startDir) {
            host.setUnpackWARs(false);
        }

        // Deploy the files we copied
        tomcat.start();
        host.backgroundProcess();

        // Update the last modified time. Add a few seconds to make sure that
        // the OS reports a change in modification time.
        switch (toModify) {
            case XML:
                if (xml == null) {
                    Assert.fail();
                } else {
                    xml.setLastModified(System.currentTimeMillis() + 5000);
                }
                break;
            case EXT:
                if (ext == null) {
                    Assert.fail();
                } else {
                    ext.setLastModified(System.currentTimeMillis() + 5000);
                }
                break;
            case WAR:
                if (war == null) {
                    Assert.fail();
                } else {
                    war.setLastModified(System.currentTimeMillis() + 5000);
                }
                break;
            case DIR:
                if (dir == null) {
                    Assert.fail();
                } else {
                    dir.setLastModified(System.currentTimeMillis() + 5000);
                }
                break;
            default:
                Assert.fail();
        }

        Context oldContext = (Context) host.findChild(APP_NAME.getName());
        StateTracker tracker = new StateTracker();
        oldContext.addLifecycleListener(tracker);

        // Trigger an auto-deployment cycle
        host.backgroundProcess();

        Context newContext = (Context) host.findChild(APP_NAME.getName());

        // Check the results
        if (resultXml) {
            if (xml == null) {
                Assert.fail();
View Full Code Here


            boolean resultWar, boolean resultDir, String resultCookieName,
            int resultAction, LifecycleState state)
            throws Exception {

        Tomcat tomcat = getTomcatInstance();
        StandardHost host = (StandardHost) tomcat.getHost();

        // Init
        File xml = null;
        File ext = null;
        File war = null;
        File dir = null;

        if (startXml && !startExternalWar && !startExternalDir) {
            xml = createXmlInConfigBaseForAppbase();
        }
        if (startExternalWar) {
            ext = createWar(WAR_XML_SOURCE, false);
            xml = createXmlInConfigBaseForExternal(ext);
        }
        if (startExternalDir) {
            ext = createDirInExternal(true);
            xml = createXmlInConfigBaseForExternal(ext);
        }
        if (startWar) {
            war = createWar(WAR_XML_SOURCE, true);
        }
        if (startDir) {
            dir = createDirInAppbase(toAdd != DIR_XML);
        }

        if ((startWar || startExternalWar) && !startDir) {
            host.setUnpackWARs(false);
        }

        host.setCopyXML(copyXML);
        host.setDeployXML(deployXML);

        // Deploy the files we copied
        tomcat.start();
        host.backgroundProcess();

        // Change the specified file
        switch (toAdd) {
            case XML:
                if (xml == null) {
                    xml = createXmlInConfigBaseForAppbase();
                } else {
                    Assert.fail();
                }
                break;
            case EXT:
                if (ext == null && xml == null) {
                    ext = createWar(WAR_XML_SOURCE, false);
                    xml = createXmlInConfigBaseForExternal(ext);
                } else {
                    Assert.fail();
                }
                break;
            case WAR:
                if (war == null) {
                    war = createWar(WAR_XML_SOURCE, true);
                } else {
                    Assert.fail();
                }
                break;
            case DIR:
                if (dir == null) {
                    dir = createDirInAppbase(true);
                } else {
                    Assert.fail();
                }
                break;
            case DIR_XML:
                dir = createDirXmlInAppbase();
                xml = getXmlInConfigBaseForAppbase();
                break;
            default:
                Assert.fail();
        }

        Context oldContext = (Context) host.findChild(APP_NAME.getName());
        StateTracker tracker = new StateTracker();
        oldContext.addLifecycleListener(tracker);

        // Trigger an auto-deployment cycle
        host.backgroundProcess();

        Context newContext = (Context) host.findChild(APP_NAME.getName());

        // Check the results
        if (resultXml) {
            if (xml == null) {
                Assert.fail();
View Full Code Here

    private void doTestUnpackWAR(boolean unpackWARs, boolean unpackWAR,
            boolean external, boolean resultDir) throws Exception {

        Tomcat tomcat = getTomcatInstance();
        StandardHost host = (StandardHost) tomcat.getHost();

        host.setUnpackWARs(unpackWARs);

        tomcat.start();

        File war;
        if (unpackWAR) {
            war = createWar(WAR_XML_UNPACKWAR_TRUE_SOURCE, !external);
        } else {
            war = createWar(WAR_XML_UNPACKWAR_FALSE_SOURCE, !external);
        }
        if (external) {
            createXmlInConfigBaseForExternal(war);
        }

        host.backgroundProcess();

        File dir = new File(host.getAppBase(), APP_NAME.getBaseName());
        Assert.assertEquals(
                Boolean.valueOf(resultDir), Boolean.valueOf(dir.isDirectory()));
    }
View Full Code Here

    private void testBrokenAppWithAntiLocking(boolean unpackWARs)
            throws Exception {

        Tomcat tomcat = getTomcatInstance();
        StandardHost host = (StandardHost) tomcat.getHost();

        host.setUnpackWARs(unpackWARs);

        File war = createWar(WAR_BROKEN_SOURCE, false);
        createXmlInConfigBaseForExternal(war, true);

        File dir = new File(host.getAppBaseFile(), APP_NAME.getBaseName());

        tomcat.start();

        // Simulate deploy on start-up
        tomcat.getHost().backgroundProcess();
View Full Code Here

    private void doTestCopyXML(boolean copyXmlHost, boolean copyXmlWar,
            boolean external, boolean resultXml) throws Exception {

        Tomcat tomcat = getTomcatInstance();
        StandardHost host = (StandardHost) tomcat.getHost();

        host.setCopyXML(copyXmlHost);

        tomcat.start();

        File war;
        if (copyXmlWar) {
            war = createWar(WAR_XML_COPYXML_TRUE_SOURCE, !external);
        } else {
            war = createWar(WAR_XML_COPYXML_FALSE_SOURCE, !external);
        }
        if (external) {
            createXmlInConfigBaseForExternal(war);
        }

        host.backgroundProcess();

        File xml = new File(host.getConfigBaseFile(),
                APP_NAME.getBaseName() + ".xml");
        Assert.assertEquals(
                Boolean.valueOf(resultXml), Boolean.valueOf(xml.isFile()));

        Context context = (Context) host.findChild(APP_NAME.getName());
        if (external) {
            Assert.assertEquals(XML_COOKIE_NAME,
                    context.getSessionCookieName());
        } else {
            Assert.assertEquals(WAR_COOKIE_NAME,
View Full Code Here

        Tomcat tomcat = getTomcatInstance();

        Host host = tomcat.getHost();
        if (host instanceof StandardHost) {
            StandardHost standardHost = (StandardHost) host;
            standardHost.setContextClass(TesterContext.class.getName());
        }

        // Copy the WAR file
        File war = new File(host.getAppBaseFile(),
                APP_NAME.getBaseName() + ".war");
View Full Code Here

                    }
                }
            }
        }
       
        StandardHost host = new StandardHost();
        host.setAppBase(appBase);
        host.setName(name);

        host.addLifecycleListener(new HostConfig());

        // Add host aliases
        if ((aliases != null) && !("".equals(aliases))) {
            StringTokenizer tok = new StringTokenizer(aliases, ",");
            while (tok.hasMoreTokens()) {
                host.addAlias(tok.nextToken());
            }
        }
        host.setAutoDeploy(autoDeploy);
        host.setDeployOnStartup(deployOnStartup);
        host.setDeployXML(deployXML);
        host.setUnpackWARs(unpackWARs);
        host.setXmlNamespaceAware(xmlNamespaceAware);
        host.setXmlValidation(xmlValidation);
       
        // Add new host
        try {
            engine.addChild(host);
        } catch (Exception e) {
View Full Code Here

            try {
                StandardContext ctx=(StandardContext)this.getContainer();
                Engine eng=(Engine)ctx.getParent().getParent();
                domain=ctx.getEngineName();
                distributable = ctx.getDistributable();
                StandardHost hst=(StandardHost)ctx.getParent();
                String path = ctx.getPath();
                if (path.equals("")) {
                    path = "/";
                }  
                oname=new ObjectName(domain + ":type=Manager,path="
                + path + ",host=" + hst.getName());
                Registry.getRegistry(null, null).registerComponent(this, oname, null );
            } catch (Exception e) {
                log.error("Error registering ",e);
            }
        }
View Full Code Here

            try {
                StandardContext ctx=(StandardContext)this.getContainer();
                Engine eng=(Engine)ctx.getParent().getParent();
                domain=ctx.getEngineName();
                distributable = ctx.getDistributable();
                StandardHost hst=(StandardHost)ctx.getParent();
                String path = ctx.getPath();
                if (path.equals("")) {
                    path = "/";
                }  
                oname=new ObjectName(domain + ":type=Manager,path="
                + path + ",host=" + hst.getName());
                Registry.getRegistry(null, null).registerComponent(this, oname, null );
            } catch (Exception e) {
                log.error("Error registering ",e);
            }
        }
View Full Code Here

     *                if an exception occurs while storing
     */
    public void storeChilds(PrintWriter aWriter, int indent, Object aHost,
            StoreDescription parentDesc) throws Exception {
        if (aHost instanceof StandardHost) {
            StandardHost host = (StandardHost) aHost;
            // Store nested <Listener> elements
            if (host instanceof Lifecycle) {
                LifecycleListener listeners[] = ((Lifecycle) host)
                        .findLifecycleListeners();
                storeElementArray(aWriter, indent, listeners);
            }

            // Store nested <Alias> elements
            String aliases[] = host.findAliases();
            getStoreAppender().printTagArray(aWriter, "Alias", indent + 2,
                    aliases);

            // Store nested <Realm> element
            Realm realm = host.getRealm();
            if (realm != null) {
                Realm parentRealm = null;
                if (host.getParent() != null) {
                    parentRealm = host.getParent().getRealm();
                }
                if (realm != parentRealm) {
                    storeElement(aWriter, indent, realm);
                }
            }

            // Store nested <Valve> elements
            if (host instanceof Pipeline) {
                Valve valves[] = ((Pipeline) host).getValves();
                storeElementArray(aWriter, indent, valves);
            }

            // store all <Cluster> elements
            Cluster cluster = host.getCluster();
            if (cluster != null) {
                storeElement(aWriter, indent, cluster);
            }

            // store all <Context> elements
            Container children[] = host.findChildren();
            storeElementArray(aWriter, indent, children);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.catalina.core.StandardHost

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.