public void lifecycleEvent(LifecycleEvent event) {
try {
Lifecycle lifecycle = event.getLifecycle();
- if (Lifecycle.AFTER_START_EVENT.equals(event.getType())
- && lifecycle instanceof Server) {
+ if (Lifecycle.AFTER_START_EVENT.equals(event.getType()) &&
+ lifecycle instanceof Server) {
// when the server starts, we register ourself as listener for
// all context
// as well as container event listener so that we know when new
registerListenersForServer(server);
}
- if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())
- && lifecycle instanceof Context) {
+ if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType()) &&
+ lifecycle instanceof Context) {
stopIdleThreads((Context) lifecycle);
}
} catch (Exception e) {
protected void processContainerAddChild(Container parent, Container child) {
if (log.isDebugEnabled())
- log.debug("Process addChild[parent=" + parent + ",child=" + child
- + "]");
+ log.debug("Process addChild[parent=" + parent + ",child=" + child +
+ "]");
if (child instanceof Context) {
registerContextListener((Context) child);
}
- protected void processContainerRemoveChild(Container parent,
+ protected void processContainerRemoveChild(Container parent,
Container child) {
if (log.isDebugEnabled())
- log.debug("Process removeChild[parent=" + parent + ",child="
- + child + "]");
+ log.debug("Process removeChild[parent=" + parent + ",child=" +
+ child + "]");
if (child instanceof Context) {
Context context = (Context) child;
context.removeLifecycleListener(this);
- } else if (child instanceof Host) {
- Host host = (Host) child;
- host.removeContainerListener(this);
- } else if (child instanceof Engine) {
- Engine engine = (Engine) child;
- engine.removeContainerListener(this);
+ } else if (child instanceof Host || child instanceof Engine) {
+ child.removeContainerListener(this);
}
}
* of its parent Service.
*/
private void stopIdleThreads(Context context) {
- if (context instanceof StandardContext &&
+ if (context instanceof StandardContext &&
!((StandardContext) context).getRenewThreadsWhenStoppingContext()) {
- log.debug("Not renewing threads when the context is stopping, it is configured not to do it.");
+ log.debug("Not renewing threads when the context is stopping, "
+ + "it is configured not to do it.");
return;
}