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);
}
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;
}
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);
}
}
}
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);
}
}
}
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);
}
Aggregations