private void destroy(Context context) throws LifecycleException, InterruptedException { context.destroy(); long deadline = System.currentTimeMillis() + 10000; do { switch(context.getState()) { case DESTROYED: case FAILED: return; default : { } } Thread.sleep(10); } while(deadline > System.currentTimeMillis()); } }
@Override public HttpListener removeListener(final String completePath) { String path = completePath; if (path == null) { return listeners.get(path); } // assure context root with a leading slash if (!path.startsWith("/") && !path.startsWith("http://") && !path.startsWith("https://")) { path = "/" + path; } if (TomcatHelper.isTomcat7() && TomcatHelper.isStopping() && listeners.containsKey(path)) { return listeners.get(path); } Context context = contexts.remove(path); try { context.stop(); context.destroy(); } catch (Exception e) { throw new TomEERuntimeException(e); } Host host = (Host) context.getParent(); host.removeChild(context); return listeners.remove(completePath); } }
if(context instanceof StandardContext) try { context.destroy(); } catch (Exception e) { log.warn("Error during context [" + context.getName() + "] destroy ", e);
if(context instanceof StandardContext) try { context.destroy(); } catch (Exception e) { log.warn("Error during context [" + context.getName() + "] destroy ", e);
public void removeWsContainer(String path) { if (path == null) return; // assure context root with a leading slash if (!path.startsWith("/")) path = "/" + path; if (TomcatHelper.isTomcat7() && TomcatHelper.isStopping()) { return; } Context context = webserviceContexts.remove(path); if (WEBSERVICE_OLDCONTEXT_ACTIVE) { try { context.destroy(); context.stop(); } catch (Exception e) { throw new TomEERuntimeException(e); } Host host = (Host) context.getParent(); host.removeChild(context); } // else let tomcat manages its context }
@Override protected void doStop() { try { tomcat.stop(); // Do not forget to destroy context if (context != null) { context.destroy(); context = null; } if (!configuration.isKeepBaseDir()) { deleteDirectory(configuration.getBaseDir()); } } catch (Exception ex) { throw new ServerStopException(ex); } }
public static void removeVirtualHost(String hostName) { Engine engine = DataHolder.getInstance().getCarbonTomcatService().getTomcat().getEngine(); Host host = (Host) engine.findChild(hostName); Context context = (Context) host.findChild("/"); try { if (host.getState().isAvailable()) { if (context != null && context.getAvailable()) { context.setRealm(null); context.stop(); context.destroy(); log.info("Unloaded webapp from the host: " + host + " as the context of: " + context); } host.removeChild(context); host.setRealm(null); host.stop(); host.destroy(); engine.removeChild(host); } }catch (LifecycleException e) { log.error("error while removing host from tomcat", e); } URLMappingHolder.getInstance().removeUrlMappingMap( host.getName()); log.info("Unloaded host from the engine: " + host); } public static Host addHostToEngine(String hostName) {