Package org.apache.catalina.core

Examples of org.apache.catalina.core.StandardHost


        Debug.logInfo("createHost(" + engine + ", " + hostName + ")", module);
        if (tomcat == null) {
            throw new ContainerException("Cannot create Host without Tomcat instance!");
        }

        Host host = new StandardHost();
        host.setAppBase(CATALINA_HOSTS_HOME);
        host.setName(hostName);
        host.setDeployOnStartup(false);
        host.setBackgroundProcessorDelay(5);
        host.setAutoDeploy(false);
        host.setRealm(engine.getRealm());
        hosts.put(engine.getName() + hostName, host);

        return host;
    }
View Full Code Here


            }
        }

        if (host instanceof StandardHost) {
            // set the catalina's work directory to the host
            StandardHost standardHost = (StandardHost) host;
            standardHost.setWorkDir(new File(System.getProperty(Globals.CATALINA_HOME_PROP)
                    , "work" + File.separator + engine.getName() + File.separator + host.getName()).getAbsolutePath());
        }

        return new Callable<Context>() {
            public Context call() throws ContainerException, LifecycleException {
View Full Code Here

            engine.setBaseDir("");
            engine.setDefaultHost("localhost");
            engine.setName("engine/" + portNumber);

            // Create a host
            StandardHost host = new StandardHost();
            host.setAppBase("");
            host.setName("localhost");
            engine.addChild(host);

            // Create the root context
            StandardContext context = new StandardContext();
            final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
            context.setLoader(new TuscanyLoader(tccl));
            // context.setParentClassLoader(tccl.getParent());
            context.setDocBase("");
            context.setPath("");
            ContextConfig config = new ContextConfig();
            ((Lifecycle)context).addLifecycleListener(config);
            host.addChild(context);

            // Install an HTTP connector
            Connector connector;
            try {
                engine.start();
View Full Code Here

                    }
                }
            }
        }
       
        StandardHost host = new StandardHost();
        host.setAppBase(applicationBase);
        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.setCopyXML(copyXML);
       
        // Add new host
        try {
            engine.addChild(host);
        } catch (Exception e) {
View Full Code Here

            Container container = service.getContainer();
            if (container instanceof StandardEngine) {
                StandardEngine engine = (StandardEngine)container;
                for (Container child : engine.findChildren()) {
                    if (child instanceof StandardHost) {
                        StandardHost host = (StandardHost)child;
                        String appBase = host.getAppBase();

                        // determine the host dir (normally webapps)
                        File hostDir = new File(appBase);
                        if (!hostDir.isAbsolute()) {
                            hostDir = new File(catalinaBase, appBase);
View Full Code Here

        this.host = host;
    }
   
    public Host getHost() {
        if (host == null) {
            host = new StandardHost();
            host.setName(hostname);

            getEngine().addChild( host );
        }
        return host;
View Full Code Here

        if( log.isDebugEnabled() )
            log.debug("Creating host '" + name + "' with appBase '" +
                       appBase + "'");

        StandardHost host = new StandardHost();

        host.setAppBase(appBase);
        host.setName(name);

        return (host);

    }
View Full Code Here

        if (debug >= 1)
            logger.log("Creating host '" + name + "' with appBase '" +
                       appBase + "'");

        StandardHost host = new StandardHost();

        host.setAppBase(appBase);
        host.setDebug(debug);
        host.setName(name);

        return (host);

    }
View Full Code Here

        // Start the instance
        tomcat.start();

        // Set the attributes
        StandardHost host = (StandardHost) tomcat.getHost();
        host.setDeployXML(deployXML);
        host.setCopyXML(copyXML);
        host.setUnpackWARs(unpackWARs);

        // Trigger automatic deployment
        host.backgroundProcess();

        // Test the results
        Context ctxt = (Context) tomcat.getHost().findChild(APP_NAME.getPath());
        if (resultState == null) {
            Assert.assertNull(ctxt);
        } else {
            Assert.assertNotNull(ctxt);
            Assert.assertEquals(resultState, ctxt.getState());
            Assert.assertEquals(cookieName, ctxt.getSessionCookieName());
        }

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

        File war = new File(
                host.getAppBaseFile(), APP_NAME.getBaseName() + ".war");
        Assert.assertEquals(
                Boolean.valueOf(resultWar), Boolean.valueOf(war.isFile()));

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

            boolean startExternalDir, boolean startWar, boolean startDir,
            int toDelete, boolean resultXml, boolean resultWar,
            boolean resultDir, String resultCookieName) 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(true);
        }

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

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

        // Remove the specified file
        switch (toDelete) {
            case XML:
                ExpandWar.delete(xml);
                break;
            case EXT:
                ExpandWar.delete(ext);
                break;
            case WAR:
                ExpandWar.delete(war);
                break;
            case DIR:
                ExpandWar.delete(dir);
                break;
            default:
                Assert.fail();
        }

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

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

        // Check the results
        // External WAR and DIR should only be deleted if the test is testing
        // behaviour when the external resource is deleted
        if (toDelete == EXT) {
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.