diff --git a/container/spi/src/main/java/org/jboss/modcluster/container/Context.java b/container/spi/src/main/java/org/jboss/modcluster/container/Context.java index 8d4dfcc6f..7831a8076 100644 --- a/container/spi/src/main/java/org/jboss/modcluster/container/Context.java +++ b/container/spi/src/main/java/org/jboss/modcluster/container/Context.java @@ -52,6 +52,18 @@ public interface Context { */ boolean isStarted(); + /** + * Returns whether this context is suspended. A suspended context is not available for processing requests, + * but it could be made available at later time. This translates into the context be made known to reverse proxies + * but in a stopped state. Implementing this method is optional defaulting to suspended mode not being supported + * by the container. + * + * @return whether this context is suspended + */ + default boolean isSuspended() { + return false; + } + /** * Registers the specified request listener with this context. Used for request draining. * diff --git a/core/src/main/java/org/jboss/modcluster/ModClusterService.java b/core/src/main/java/org/jboss/modcluster/ModClusterService.java index 3ba16ed10..af5c89ffd 100644 --- a/core/src/main/java/org/jboss/modcluster/ModClusterService.java +++ b/core/src/main/java/org/jboss/modcluster/ModClusterService.java @@ -300,11 +300,15 @@ public void add(Context context) { ModClusterLogger.LOGGER.addContext(context.getHost(), context); if (this.include(context) && this.established) { - // Send ENABLE-APP if state is started - if (context.isStarted()) { - this.enable(context); - } else { + if (context.isSuspended()) { + // Send STOP-APP if the context is suspended this.stop(context); + } else if (context.isStarted()) { + // Send ENABLE-APP if state is started + + // n.b. for some containers like Tomcat, the context at this point is only in the 'STARTING' state and + // thus enable(..) will not be called here but rather during a start(..) call. + this.enable(context); } } } @@ -313,7 +317,7 @@ public void add(Context context) { public void start(Context context) { ModClusterLogger.LOGGER.startContext(context.getHost(), context); - if (this.include(context)) { + if (this.include(context) && !context.isSuspended()) { if (this.established) { this.enable(context); }