423361 Ensure ServletContainerInitializers called before injecting Listeners
This commit is contained in:
parent
1731e0c69a
commit
2d3d912173
|
@ -23,6 +23,7 @@ import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
|
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
|
||||||
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
@ -36,12 +37,11 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
* Call the onStartup() method on all ServletContainerInitializers, after having
|
* Call the onStartup() method on all ServletContainerInitializers, after having
|
||||||
* found all applicable classes (if any) to pass in as args.
|
* 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);
|
private static final Logger LOG = Log.getLogger(ServletContainerInitializersStarter.class);
|
||||||
WebAppContext _context;
|
WebAppContext _context;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,6 +35,7 @@ import javax.servlet.Filter;
|
||||||
import javax.servlet.FilterRegistration;
|
import javax.servlet.FilterRegistration;
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
|
import javax.servlet.ServletContainerInitializer;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
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.servlet.BaseHolder.Source;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
import org.eclipse.jetty.util.component.LifeCycle;
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -83,6 +85,8 @@ public class ServletContextHandler extends ContextHandler
|
||||||
public final static int NO_SESSIONS=0;
|
public final static int NO_SESSIONS=0;
|
||||||
public final static int NO_SECURITY=0;
|
public final static int NO_SECURITY=0;
|
||||||
|
|
||||||
|
public interface ServletContainerInitializerCaller extends LifeCycle {};
|
||||||
|
|
||||||
protected final List<Decorator> _decorators= new ArrayList<>();
|
protected final List<Decorator> _decorators= new ArrayList<>();
|
||||||
protected Class<? extends SecurityHandler> _defaultSecurityHandlerClass=org.eclipse.jetty.security.ConstraintSecurityHandler.class;
|
protected Class<? extends SecurityHandler> _defaultSecurityHandlerClass=org.eclipse.jetty.security.ConstraintSecurityHandler.class;
|
||||||
protected SessionHandler _sessionHandler;
|
protected SessionHandler _sessionHandler;
|
||||||
|
@ -267,6 +271,9 @@ public class ServletContextHandler extends ContextHandler
|
||||||
@Override
|
@Override
|
||||||
protected void startContext() throws Exception
|
protected void startContext() throws Exception
|
||||||
{
|
{
|
||||||
|
ServletContainerInitializerCaller sciBean = getBean(ServletContainerInitializerCaller.class);
|
||||||
|
if (sciBean!=null)
|
||||||
|
sciBean.start();
|
||||||
|
|
||||||
if (_servletHandler != null)
|
if (_servletHandler != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue