Stop an existing server instance.
()
| 928 | * Stop an existing server instance. |
| 929 | */ |
| 930 | public void stop() { |
| 931 | |
| 932 | try { |
| 933 | // Remove the ShutdownHook first so that server.stop() |
| 934 | // doesn't get invoked twice |
| 935 | if (useShutdownHook) { |
| 936 | Runtime.getRuntime().removeShutdownHook(shutdownHook); |
| 937 | |
| 938 | // If JULI is being used, re-enable JULI's shutdown to ensure |
| 939 | // log messages are not lost |
| 940 | LogManager logManager = LogManager.getLogManager(); |
| 941 | if (logManager instanceof ClassLoaderLogManager) { |
| 942 | ((ClassLoaderLogManager) logManager).setUseShutdownHook(true); |
| 943 | } |
| 944 | } |
| 945 | } catch (Throwable t) { |
| 946 | ExceptionUtils.handleThrowable(t); |
| 947 | // This will fail on JDK 1.2. Ignoring, as Tomcat can run |
| 948 | // fine without the shutdown hook. |
| 949 | } |
| 950 | |
| 951 | // Shut down the server |
| 952 | try { |
| 953 | Server s = getServer(); |
| 954 | LifecycleState state = s.getState(); |
| 955 | if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0 && LifecycleState.DESTROYED.compareTo(state) >= 0) { |
| 956 | // Nothing to do. stop() was already called |
| 957 | } else { |
| 958 | s.stop(); |
| 959 | s.destroy(); |
| 960 | } |
| 961 | } catch (LifecycleException e) { |
| 962 | log.error(sm.getString("catalina.stopError"), e); |
| 963 | } |
| 964 | |
| 965 | } |
| 966 | |
| 967 | |
| 968 | /** |
no test coverage detected