Search in sources :

Example 61 with StandardHost

use of org.apache.catalina.core.StandardHost in project ofbiz-framework by apache.

the class CatalinaContainer method init.

@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
    this.name = name;
    ContainerConfig.Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
    Property engineConfig = retrieveTomcatEngineConfig(configuration);
    // tomcat setup
    tomcat = prepareTomcatServer(configuration, engineConfig);
    Engine engine = prepareTomcatEngine(tomcat, engineConfig);
    Host host = prepareHost(tomcat, null);
    // add realm and valve for Tomcat SSO
    if (EntityUtilProperties.propertyValueEquals("security", "security.login.tomcat.sso", "true")) {
        boolean useEncryption = EntityUtilProperties.propertyValueEquals("security", "password.encrypt", "true");
        OFBizRealm ofBizRealm = new OFBizRealm();
        if (useEncryption) {
            ofBizRealm.setCredentialHandler(new HashedCredentialHandler());
        } else {
            ofBizRealm.setCredentialHandler(new SimpleCredentialHandler());
        }
        host.setRealm(ofBizRealm);
        ((StandardHost) host).addValve(new SingleSignOn());
    }
    // clustering, valves and connectors setup
    Property clusterProps = prepareTomcatClustering(host, engineConfig);
    prepareTomcatEngineValves(engineConfig).forEach(valve -> ((StandardEngine) engine).addValve(valve));
    prepareTomcatConnectors(configuration).forEach(connector -> tomcat.getService().addConnector(connector));
    loadWebapps(tomcat, configuration, clusterProps);
}
Also used : ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) StandardHost(org.apache.catalina.core.StandardHost) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) Host(org.apache.catalina.Host) StandardHost(org.apache.catalina.core.StandardHost) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) SingleSignOn(org.apache.catalina.authenticator.SingleSignOn)

Example 62 with StandardHost

use of org.apache.catalina.core.StandardHost in project ofbiz-framework by apache.

the class CatalinaContainer method prepareVirtualHost.

private Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts) {
    // assume that the first virtual-host will be the default; additional virtual-hosts will be aliases
    String hostName = virtualHosts.get(0);
    Host host;
    Engine engine = tomcat.getEngine();
    org.apache.catalina.Container childContainer = engine.findChild(hostName);
    if (childContainer instanceof Host) {
        host = (Host) childContainer;
    } else {
        host = new StandardHost();
        host.setName(hostName);
        engine.addChild(host);
    }
    virtualHosts.stream().filter(virtualHost -> virtualHost != hostName).forEach(virtualHost -> host.addAlias(virtualHost));
    return host;
}
Also used : URL(java.net.URL) FilterMap(org.apache.tomcat.util.descriptor.web.FilterMap) NamingException(javax.naming.NamingException) SingleSignOn(org.apache.catalina.authenticator.SingleSignOn) ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) Future(java.util.concurrent.Future) Host(org.apache.catalina.Host) Document(org.w3c.dom.Document) Map(java.util.Map) FlexibleLocation(org.apache.ofbiz.base.location.FlexibleLocation) Configuration(org.apache.ofbiz.base.container.ContainerConfig.Configuration) RequestDumperFilter(org.apache.catalina.filters.RequestDumperFilter) InitialContext(javax.naming.InitialContext) LifecycleException(org.apache.catalina.LifecycleException) WebappLoader(org.apache.catalina.loader.WebappLoader) NioReceiver(org.apache.catalina.tribes.transport.nio.NioReceiver) Set(java.util.Set) StandardServer(org.apache.catalina.core.StandardServer) Collectors(java.util.stream.Collectors) ReplicationTransmitter(org.apache.catalina.tribes.transport.ReplicationTransmitter) ReplicationValve(org.apache.catalina.ha.tcp.ReplicationValve) Start(org.apache.ofbiz.base.start.Start) ServerInfo(org.apache.catalina.util.ServerInfo) List(java.util.List) StandardRoot(org.apache.catalina.webresources.StandardRoot) ContextConfig(org.apache.catalina.startup.ContextConfig) SAXException(org.xml.sax.SAXException) StandardContext(org.apache.catalina.core.StandardContext) SimpleTcpCluster(org.apache.catalina.ha.tcp.SimpleTcpCluster) MultiPointSender(org.apache.catalina.tribes.transport.MultiPointSender) StandardEngine(org.apache.catalina.core.StandardEngine) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) Valve(org.apache.catalina.Valve) Callable(java.util.concurrent.Callable) Connector(org.apache.catalina.connector.Connector) ContainerException(org.apache.ofbiz.base.container.ContainerException) UtilValidate(org.apache.ofbiz.base.util.UtilValidate) Engine(org.apache.catalina.Engine) StandardHost(org.apache.catalina.core.StandardHost) IntrospectionUtils(org.apache.tomcat.util.IntrospectionUtils) ArrayList(java.util.ArrayList) JarScanner(org.apache.tomcat.JarScanner) HashSet(java.util.HashSet) ClusterManager(org.apache.catalina.ha.ClusterManager) AccessLogValve(org.apache.catalina.valves.AccessLogValve) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) EntityUtilProperties(org.apache.ofbiz.entity.util.EntityUtilProperties) StartupCommand(org.apache.ofbiz.base.start.StartupCommand) FilterDef(org.apache.tomcat.util.descriptor.web.FilterDef) Globals(org.apache.catalina.Globals) IOException(java.io.IOException) Context(org.apache.catalina.Context) File(java.io.File) ExecutionPool(org.apache.ofbiz.base.concurrent.ExecutionPool) UtilXml(org.apache.ofbiz.base.util.UtilXml) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) Tomcat(org.apache.catalina.startup.Tomcat) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) McastService(org.apache.catalina.tribes.membership.McastService) Debug(org.apache.ofbiz.base.util.Debug) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) Collections(java.util.Collections) Container(org.apache.ofbiz.base.container.Container) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) StandardHost(org.apache.catalina.core.StandardHost) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine)

Example 63 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomee by apache.

the class GlobalListenerSupport method engineRemoved.

/**
 * Engine is removed.
 *
 * @param engine tomcat engine
 */
private void engineRemoved(final StandardEngine engine) {
    for (final Container child : engine.findChildren()) {
        if (child instanceof StandardHost) {
            final StandardHost host = (StandardHost) child;
            hostRemoved(host);
        }
    }
}
Also used : Container(org.apache.catalina.Container) StandardHost(org.apache.catalina.core.StandardHost)

Example 64 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomee by apache.

the class GlobalListenerSupport method engineAdded.

/**
 * Engine is added.
 *
 * @param engine tomcat engine
 */
private void engineAdded(final StandardEngine engine) {
    addContextListener(engine);
    for (final Container child : engine.findChildren()) {
        if (child instanceof StandardHost) {
            final StandardHost host = (StandardHost) child;
            hostAdded(host);
        }
    }
}
Also used : Container(org.apache.catalina.Container) StandardHost(org.apache.catalina.core.StandardHost)

Example 65 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomee by apache.

the class TomEEUndeployTest method tomcatLifecycle.

@Test
public void tomcatLifecycle() throws Exception {
    container.start();
    assertEquals(0, webapps().length);
    final StandardHost standardHost = StandardHost.class.cast(TomcatHelper.getServer().findService("Tomcat").getContainer().findChild("localhost"));
    // not done in embedded but that's the way autodeploy works in normal tomcat
    final HostConfig listener = new HostConfig();
    standardHost.addLifecycleListener(listener);
    createWebapp(new File(WORK_DIR, "tomee/webapps/my-webapp"));
    listener.lifecycleEvent(new LifecycleEvent(standardHost, Lifecycle.START_EVENT, standardHost));
    assertEquals(1, webapps().length);
}
Also used : StandardHost(org.apache.catalina.core.StandardHost) HostConfig(org.apache.catalina.startup.HostConfig) LifecycleEvent(org.apache.catalina.LifecycleEvent) File(java.io.File) Test(org.junit.Test)

Aggregations

StandardHost (org.apache.catalina.core.StandardHost)90 File (java.io.File)48 Context (org.apache.catalina.Context)38 StandardContext (org.apache.catalina.core.StandardContext)36 Host (org.apache.catalina.Host)29 Test (org.junit.Test)26 Tomcat (org.apache.catalina.startup.Tomcat)16 Container (org.apache.catalina.Container)12 StandardEngine (org.apache.catalina.core.StandardEngine)12 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)12 IOException (java.io.IOException)10 URL (java.net.URL)8 Service (org.apache.catalina.Service)8 HostConfig (org.apache.catalina.startup.HostConfig)8 InitialContext (javax.naming.InitialContext)7 Engine (org.apache.catalina.Engine)7 InputStream (java.io.InputStream)6 ObjectName (javax.management.ObjectName)6 ReplicatedContext (org.apache.catalina.ha.context.ReplicatedContext)6 ArrayList (java.util.ArrayList)5