use of org.apache.tomee.catalina.TomEERuntimeException in project tomee by apache.
the class TomcatWsRegistry method removeWsContainer.
public void removeWsContainer(String path, final String moduleId) {
if (path == null) {
return;
}
// assure context root with a leading slash
if (!path.startsWith("/")) {
path = "/" + path;
}
if (TomcatHelper.isStopping()) {
return;
}
Context context = webserviceContexts.remove(new Key(path, moduleId));
if (context == null) {
// fake
context = webserviceContexts.remove(new Key(path, null));
}
// > 0 to avoid to destroy the context if not mandatory
Integer refs = 1;
if (context != null) {
final String name = context.getName();
refs = fakeContextReferences.remove(name);
if (refs != null && refs > 0) {
fakeContextReferences.put(name, refs - 1);
}
}
if ((WEBSERVICE_OLDCONTEXT_ACTIVE || (refs != null && refs == 0)) && context != null) {
try {
context.stop();
context.destroy();
} catch (final Exception e) {
throw new TomEERuntimeException(e);
}
final Host host = (Host) context.getParent();
host.removeChild(context);
}
// else let tomcat manages its context
}
Aggregations