@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; }
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.");
protected void checkFailures(StandardHost host) { boolean ok = Stream.of(host.findChildren()).map(Lifecycle::getState).allMatch(s -> s == LifecycleState.STARTED); boolean strict = Boolean.getBoolean("nuxeo.start.strict"); if (!ok && strict) { // Throws an exception and let Tomcat to handle it via Catalina's shutdown hook. Otherwise, we could call // `#stop()` and `#destroy()` by ourselves, but that means we're making a shutdown in AFTER_STARTED // lifecycle event. It would be misleading. throw new IllegalStateException("Some contexts failed to start."); } } protected void preprocess(Container container) {
/** * Return the context paths of all deployed web applications in this * Container. If there are no deployed applications, a zero-length * array is returned. */ public String[] findDeployedApps() { Container children[] = host.findChildren(); String results[] = new String[children.length]; for (int i = 0; i < children.length; i++) results[i] = children[i].getName(); return (results); }
/** * Host is removed. * * @param host tomcat host */ private void hostRemoved(StandardHost host) { for (Container child : host.findChildren()) { if (child instanceof StandardContext) { StandardContext context = (StandardContext) child; contextRemoved(context); } } }
/** * Host is removed. * * @param host tomcat host */ private void hostRemoved(final StandardHost host) { for (final Container child : host.findChildren()) { if (child instanceof StandardContext) { final StandardContext context = (StandardContext) child; contextRemoved(context); } } }
private void hostRemoved(StandardHost host) { for (Container child : host.findChildren()) { if (child instanceof StandardContext) { StandardContext context = (StandardContext) child; contextRemoved(context); } } }
private static boolean hasChild(final StandardHost host, final String name) { for (final Container child : host.findChildren()) { // the TomEERemoteWebapp path = "/" + name if (name.equals(child.getName()) || (StandardContext.class.isInstance(child) && ("/" + name).equals(StandardContext.class.cast(child).getPath()))) { return true; } } return false; }
public synchronized void destroy() throws Exception { // destroy our child containers, if any Container children[] = findChildren(); super.destroy(); for (int i = 0; i < children.length; i++) { if(children[i] instanceof StandardContext) ((StandardContext)children[i]).destroy(); } }
public void destroy() throws Exception { // destroy our child containers, if any Container children[] = findChildren(); super.destroy(); for (int i = 0; i < children.length; i++) { if(children[i] instanceof StandardContext) ((StandardContext)children[i]).destroy(); } }
private static File findOpenEjbWar(StandardHost standardHost) { //look for openejb war in a Tomcat context for(Container container : standardHost.findChildren()) { if(container instanceof StandardContext) { StandardContext standardContext = (StandardContext)container; File contextDocBase = new File(standardContext.getDocBase()); if(contextDocBase.isDirectory()) { File openEjbWar = findOpenEjbWarInContext(contextDocBase); if (openEjbWar != null) { return openEjbWar; } } } } return null; }
public synchronized void destroy() throws Exception { // destroy our child containers, if any Container children[] = findChildren(); super.destroy(); for (int i = 0; i < children.length; i++) { if(children[i] instanceof StandardContext) ((StandardContext)children[i]).destroy(); } }
private static File findOpenEjbWar(final StandardHost standardHost) { //look for openejb war in a Tomcat context for (final Container container : standardHost.findChildren()) { if (container instanceof StandardContext) { final StandardContext standardContext = (StandardContext) container; File contextDocBase = new File(standardContext.getDocBase()); if (!contextDocBase.isDirectory() && standardContext.getOriginalDocBase() != null) { contextDocBase = new File(standardContext.getOriginalDocBase()); } if (contextDocBase.isDirectory()) { final File openEjbWar = findOpenEjbWarInContext(contextDocBase); if (openEjbWar != null) { return openEjbWar; } } } } return null; }
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); } } }
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); } } }
/** * Host is added. * * @param host tomcat host. */ 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); } } }
/** * Host is added. * * @param host tomcat host. */ private void hostAdded(final StandardHost host) { addContextListener(host); host.addLifecycleListener(this); for (final Container child : host.findChildren()) { if (child instanceof StandardContext) { final StandardContext context = (StandardContext) child; contextAdded(context); } } }
Container children[] = host.findChildren(); storeElementArray(aWriter, indent, children);