diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ServletContainerInitializersStarter.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ServletContainerInitializersStarter.java index 75a22c0b425..114eeb749c3 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ServletContainerInitializersStarter.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/ServletContainerInitializersStarter.java @@ -23,6 +23,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.jetty.plus.annotation.ContainerInitializer; +import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.ConcurrentHashSet; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.log.Log; @@ -36,11 +37,10 @@ import org.eclipse.jetty.webapp.WebAppContext; * Call the onStartup() method on all ServletContainerInitializers, after having * found all applicable classes (if any) to pass in as args. */ -public class ServletContainerInitializersStarter extends AbstractLifeCycle +public class ServletContainerInitializersStarter extends AbstractLifeCycle implements ServletContextHandler.ServletContainerInitializerCaller { private static final Logger LOG = Log.getLogger(ServletContainerInitializersStarter.class); WebAppContext _context; - /** * @param context diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index 041065bf29e..ff85019e18c 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -35,6 +35,7 @@ import javax.servlet.Filter; import javax.servlet.FilterRegistration; import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; +import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; @@ -62,6 +63,7 @@ import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.servlet.BaseHolder.Source; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; +import org.eclipse.jetty.util.component.LifeCycle; /* ------------------------------------------------------------ */ @@ -82,6 +84,8 @@ public class ServletContextHandler extends ContextHandler public final static int SECURITY=2; public final static int NO_SESSIONS=0; public final static int NO_SECURITY=0; + + public interface ServletContainerInitializerCaller extends LifeCycle {}; protected final List _decorators= new ArrayList<>(); protected Class _defaultSecurityHandlerClass=org.eclipse.jetty.security.ConstraintSecurityHandler.class; @@ -267,6 +271,9 @@ public class ServletContextHandler extends ContextHandler @Override protected void startContext() throws Exception { + ServletContainerInitializerCaller sciBean = getBean(ServletContainerInitializerCaller.class); + if (sciBean!=null) + sciBean.start(); if (_servletHandler != null) {