in meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java [972:1026]
public synchronized void close() {
if (tomcat == null) {
return;
}
if (hook != null) {
Runtime.getRuntime().removeShutdownHook(hook);
this.hook = null;
}
beforeStop();
if (MeecrowaveContainerLoader.class.isInstance(tomcat.getServer().getParentClassLoader())) {
try {
MeecrowaveContainerLoader.class.cast(tomcat.getServer().getParentClassLoader()).close();
} catch (final IOException e) {
new LogFacade(Meecrowave.class.getName()).error(e.getMessage(), e);
}
}
try {
contexts.values().forEach(Runnable::run);
} finally {
try {
tomcat.stop();
tomcat.destroy();
} catch (final LifecycleException e) {
throw new IllegalStateException(e);
} finally {
Cxfs.resetDefaultBusIfEquals(clientBus); // after if runnables or listeners trigger CXF
tomcat = null; // ensure we can call close() N times and not have side effects
contexts.clear();
if (clearCatalinaSystemProperties) {
Stream.of("catalina.base", "catalina.home").forEach(System::clearProperty);
}
if (configuration.isUseLog4j2JulLogManager()) {
System.clearProperty("java.util.logging.manager");
}
ofNullable(postTask).ifPresent(Runnable::run);
postTask = null;
try {
if (deleteBase && base != null) {
IO.delete(base);
}
if (ownedTempDir != null) {
IO.delete(ownedTempDir);
}
} catch (final IllegalArgumentException /*does not exist from the hook*/ e) {
// no-op
} finally {
base = null;
// not very important if we can't delete it since next restart will write another value normally
ofNullable(configuration.getPidFile()).ifPresent(File::delete);
}
}
}
}