public void init() { if (initialized) return; initialized = true; log = Logger.getLogger(ManagerBase.class); StandardContext ctx = (StandardContext) this.getContainer(); distributable = ctx.getDistributable(); if (org.apache.tomcat.util.Constants.ENABLE_MODELER) { if (oname == null) { try { Engine eng = (Engine) ctx.getParent().getParent(); domain = ctx.getEngineName(); StandardHost hst = (StandardHost) ctx.getParent(); String path = ctx.getPath(); if (path.equals("")) { path = "/"; } oname = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + hst.getName()); Registry.getRegistry(null, null).registerComponent(this, oname, null); } catch (Exception e) { log.error("Error registering ", e); } } } if (log.isDebugEnabled()) log.debug("Registering " + oname); }
public void init() { if (initialized) return; initialized = true; StandardContext ctx = (StandardContext) this.getContainer(); distributable = ctx.getDistributable(); if (org.apache.tomcat.util.Constants.ENABLE_MODELER) { if (oname == null) { try { Engine eng = (Engine) ctx.getParent().getParent(); domain = ctx.getEngineName(); StandardHost hst = (StandardHost) ctx.getParent(); String path = ctx.getPath(); if (path.equals("")) { path = "/"; } oname = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + hst.getName()); Registry.getRegistry(null, null).registerComponent(this, oname, null); } catch (Exception e) { CatalinaLogger.SESSION_LOGGER.failedSessionManagerJmxRegistration(oname, e); } } } if (CatalinaLogger.SESSION_LOGGER.isDebugEnabled()) CatalinaLogger.SESSION_LOGGER.debug("Registering " + oname); }
/** Un-initialization. */ @Override public void destroy() throws Exception { log.debug("TomcatVHostLoader un-init"); Container[] children = host.findChildren(); for (Container c : children) { if (c instanceof StandardContext) { try { ((StandardContext) c).stop(); host.removeChild(c); } catch (Exception e) { log.error("Could not stop context: {}", c.getName(), e); } } } // remove system prop String propertyPrefix = name; if (domain != null) { propertyPrefix += '_' + domain.replace('.', '_'); } System.clearProperty(propertyPrefix + ".webapp.root"); // stop the host try { ((StandardHost) host).stop(); } catch (LifecycleException e) { log.error("Could not stop host: {}", host.getName(), e); } // remove host engine.removeChild(host); // unregister jmx unregisterJMX(); }
/** * 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; }
/** * Adds a valve to the current host. * * @param valve Valve */ public void addValve(Valve valve) { log.debug("Adding valve: {}", valve); log.debug("Valve info: {}", valve); ((StandardHost) host).addValve(valve); }