host = new StandardHost(); host.setName(hostname); engine.addChild(host); if (!host.getAppBaseFile().mkdirs()) { throw new TomcatServiceException("failed to create app base file: " + host.getAppBaseFile()); ctx = (Context) Class.forName(host.getContextClass(), true, getClass().getClassLoader()) .getDeclaredConstructor().newInstance(); } catch (Exception e) { ctx.addLifecycleListener(ctxCfg); host.addChild(ctx);
/** * Return the name of the Container with which this Deployer is associated. */ public String getName() { return (host.getName()); }
final Container actualEngine = TomcatUtil.engine(expectedService, expectedHost.getName()); if (actualEngine != expectedEngine) { throw new TomcatServiceException( final Container[] contextChildren = expectedHost.findChildren(); if (contextChildren == null || Arrays.stream(contextChildren).noneMatch(c -> c == expectedContext)) { throw new TomcatServiceException("A configurator should never remove the default context.");
public static StandardContext createContext() { final StandardEngine engine = new StandardEngine(); engine.setService( new StandardService() ); final StandardContext context = new StandardContext(); context.setPath( "/" ); context.setSessionCookiePath( "/" ); final WebappLoader webappLoader = new WebappLoader() { @Override public ClassLoader getClassLoader() { return Thread.currentThread().getContextClassLoader(); } }; context.setLoader( webappLoader ); final StandardHost host = new StandardHost(); engine.addChild( host ); host.addChild( context ); return context; }
StandardHost host = new StandardHost(); host.setName(name); host.setAppBase(appBase); host.setAutoDeploy(autoDeploy); host.setDeployOnStartup(deployOnStartup); host.setDeployXML(deployXML); host.setUnpackWARs(unpackWARs); host.addLifecycleListener(hostConfig); return host.getObjectName().toString();
@Override public Host createHost(String name, String appBase) { if( log.isDebugEnabled() ) log.debug("Creating host '" + name + "' with appBase '" + appBase + "'"); StandardHost host = new StandardHost(); host.setAppBase(appBase); host.setName(name); return (host); }
/** * Create a standard host. * * @return host */ public Host createHost() { log.debug("Creating host"); StandardHost stdHost = new StandardHost(); stdHost.setAppBase(webappRoot); stdHost.setAutoDeploy(autoDeploy); if (domain == null) { stdHost.setName(name); } else { stdHost.setDomain(domain); //seems to require that the domain be appended to the name stdHost.setName(name + '.' + domain); } stdHost.setStartChildren(startChildren); stdHost.setUnpackWARs(unpackWARs); // See http://tomcat.apache.org/migration-7.html#Deployment stdHost.setCopyXML(true); return stdHost; }
public static Host addHostToEngine(String hostName) { String hostBaseDir = CarbonUtils.getCarbonRepository() + "/webapps/"; CarbonTomcatService carbonTomcatService = DataHolder.getInstance().getCarbonTomcatService(); // adding virtual host to tomcat engine Engine engine = carbonTomcatService.getTomcat().getEngine(); StandardHost host = new StandardHost(); host.setAppBase(hostBaseDir); host.setName(hostName); host.setUnpackWARs(false); host.addValve(new CarbonContextCreatorValve()); host.addValve(new CompositeValve()); engine.addChild(host); log.info("host added to the tomcat: " + host); return host; }
public Host getHost() { if (host == null) { host = new StandardHost(); host.setName(hostname); getEngine().addChild( host ); } return host; }
domain=engine.getName(); oname=new ObjectName(domain + ":type=Host,host=" + this.getName()); controller = oname; if( getParent() == null ) { addLifecycleListener(deployer); if( mserver.isRegistered( serviceName )) { mserver.invoke( serviceName, "addChild",
host.setAutoDeploy(false); host.setDeployOnStartup(true); host.setUnpackWARs(false);
appBase + "'"); StandardHost host = new StandardHost(); host.setAppBase(appBase); host.setDebug(debug); host.setName(name);
private void hostAdded(StandardHost host) { addContextListener(host); host.addLifecycleListener(this); for (Container child : host.findChildren()) { if (child instanceof StandardContext) { StandardContext context = (StandardContext) child; contextAdded(context); } } }
if (getXmlBase()!=null) { path = getXmlBase(); } else { StringBuilder xmlDir = new StringBuilder("conf"); Container parent = getParent(); if (parent instanceof Engine) { xmlDir.append('/'); xmlDir.append(getName()); path = xmlDir.toString(); file = new File(getCatalinaBase(), path); try { file = file.getCanonicalFile();
/** * Add an alias name that should be mapped to this same Host. * * @param alias The alias to be added */ public void addAlias(String alias) { // START OF PE 4989789 //alias = alias.toLowerCase(); // START OF PE 4989789 // Skip duplicate aliases for(String name : aliases) { if(name.equals(alias)) { return; } } // Add this alias to the list String newAliases[] = new String[aliases.length + 1]; for (int i = 0; i < aliases.length; i++) newAliases[i] = aliases[i]; newAliases[aliases.length] = alias; aliases = newAliases; // Inform interested listeners fireContainerEvent(ADD_ALIAS_EVENT, alias); }
hostName = parentHost.getName(); if (parentHost instanceof StandardHost) { hostWorkDir = ((StandardHost)parentHost).getWorkDir();
@Override public Connector apply(String hostname) { // Create the connector with our protocol handler. Tomcat will call ProtocolHandler.setAdapter() // on its startup with the Coyote Adapter which gives an access to Tomcat's HTTP service pipeline. final Class<?> protocolType = TomcatService.PROTOCOL_HANDLER_CLASS; final Connector connector = new Connector(protocolType.getName()); // We do not really open a port - just trying to stop the Connector from complaining. connector.setPort(0); final StandardServer server = newServer(hostname, connector, config); // Retrieve the components configured by newServer(), so we can use it in checkConfiguration(). final Service service = server.findServices()[0]; final Engine engine = TomcatUtil.engine(service, hostname); final StandardHost host = (StandardHost) engine.findChildren()[0]; final Context context = (Context) host.findChildren()[0]; // Apply custom configurators set via TomcatServiceBuilder.configurator() try { config.configurators().forEach(c -> c.accept(server)); } catch (Throwable t) { throw new TomcatServiceException("failed to configure an embedded Tomcat", t); } // Make sure the configurators did not ruin what we have configured in this method. checkConfiguration(server, service, connector, engine, host, context); assert connector.getService().getServer() != null; return connector; }
public ObjectName preRegister(MBeanServer server, ObjectName oname ) throws Exception { ObjectName res=super.preRegister(server, oname); String name=oname.getKeyProperty("host"); if( name != null ) setName( name ); return res; }
public Host getHost() { Host host = tomcat.getHost(); ((StandardHost) host).setUnpackWARs(unpackWars); return host; }