jetty-9 further lifecycle improvements
This commit is contained in:
parent
68ee346b8a
commit
879cdf4b82
|
@ -166,7 +166,7 @@ public class ScanningAppProviderRuntimeUpdatesTest
|
|||
jetty.assertResponseContains("/foo/info","FooServlet-1");
|
||||
|
||||
waitForDirectoryScan();
|
||||
System.err.println("Updating war files");
|
||||
//System.err.println("Updating war files");
|
||||
jetty.copyContext("foo.xml","foo.xml"); // essentially "touch" the context xml
|
||||
jetty.copyWebapp("foo-webapp-2.war","foo.war");
|
||||
|
||||
|
|
|
@ -170,8 +170,8 @@ public class HttpTester
|
|||
{
|
||||
HttpGenerator generator = new HttpGenerator();
|
||||
HttpGenerator.Info info = getInfo();
|
||||
System.err.println(info.getClass());
|
||||
System.err.println(info);
|
||||
// System.err.println(info.getClass());
|
||||
// System.err.println(info);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteBuffer header=null;
|
||||
|
|
|
@ -73,19 +73,20 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
private String _authMethod;
|
||||
private final Map<String,String> _initParameters=new HashMap<>();
|
||||
private LoginService _loginService;
|
||||
private boolean _loginServiceShared;
|
||||
private IdentityService _identityService;
|
||||
private boolean _renewSession=true;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected SecurityHandler()
|
||||
{
|
||||
addBean(_authenticatorFactory);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the identityService.
|
||||
* @return the identityService
|
||||
*/
|
||||
@Override
|
||||
public IdentityService getIdentityService()
|
||||
{
|
||||
return _identityService;
|
||||
|
@ -99,6 +100,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
{
|
||||
if (isStarted())
|
||||
throw new IllegalStateException("Started");
|
||||
updateBean(_identityService,identityService);
|
||||
_identityService = identityService;
|
||||
}
|
||||
|
||||
|
@ -106,6 +108,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
/** Get the loginService.
|
||||
* @return the loginService
|
||||
*/
|
||||
@Override
|
||||
public LoginService getLoginService()
|
||||
{
|
||||
return _loginService;
|
||||
|
@ -119,8 +122,8 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
{
|
||||
if (isStarted())
|
||||
throw new IllegalStateException("Started");
|
||||
updateBean(_loginService,loginService);
|
||||
_loginService = loginService;
|
||||
_loginServiceShared=false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +142,10 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
{
|
||||
if (isStarted())
|
||||
throw new IllegalStateException("Started");
|
||||
updateBean(_authenticator,authenticator);
|
||||
_authenticator = authenticator;
|
||||
if (_authenticator!=null)
|
||||
_authMethod=_authenticator.getAuthMethod();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -160,6 +166,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException("running");
|
||||
updateBean(_authenticatorFactory,authenticatorFactory);
|
||||
_authenticatorFactory = authenticatorFactory;
|
||||
}
|
||||
|
||||
|
@ -167,6 +174,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
/**
|
||||
* @return the realmName
|
||||
*/
|
||||
@Override
|
||||
public String getRealmName()
|
||||
{
|
||||
return _realmName;
|
||||
|
@ -188,6 +196,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
/**
|
||||
* @return the authMethod
|
||||
*/
|
||||
@Override
|
||||
public String getAuthMethod()
|
||||
{
|
||||
return _authMethod;
|
||||
|
@ -228,12 +237,14 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String getInitParameter(String key)
|
||||
{
|
||||
return _initParameters.get(key);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Set<String> getInitParameterNames()
|
||||
{
|
||||
return _initParameters.keySet();
|
||||
|
@ -299,16 +310,16 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
//register a session listener to handle securing sessions when authentication is performed
|
||||
context.getContextHandler().addEventListener(new HttpSessionListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void sessionDestroyed(HttpSessionEvent se)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sessionCreated(HttpSessionEvent se)
|
||||
{
|
||||
//if current request is authenticated, then as we have just created the session, mark it as secure, as it has not yet been returned to a user
|
||||
HttpChannel channel = HttpChannel.getCurrentHttpChannel();
|
||||
HttpChannel<?> channel = HttpChannel.getCurrentHttpChannel();
|
||||
|
||||
if (channel == null)
|
||||
return;
|
||||
|
@ -328,22 +339,18 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
// many different ways these can be constructed and injected.
|
||||
|
||||
if (_loginService==null)
|
||||
{
|
||||
_loginService=findLoginService();
|
||||
if (_loginService!=null)
|
||||
_loginServiceShared=true;
|
||||
}
|
||||
setLoginService(findLoginService());
|
||||
|
||||
if (_identityService==null)
|
||||
{
|
||||
if (_loginService!=null)
|
||||
_identityService=_loginService.getIdentityService();
|
||||
setIdentityService(_loginService.getIdentityService());
|
||||
|
||||
if (_identityService==null)
|
||||
_identityService=findIdentityService();
|
||||
setIdentityService(findIdentityService());
|
||||
|
||||
if (_identityService==null && _realmName!=null)
|
||||
_identityService=new DefaultIdentityService();
|
||||
setIdentityService(new DefaultIdentityService());
|
||||
}
|
||||
|
||||
if (_loginService!=null)
|
||||
|
@ -354,49 +361,21 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
throw new IllegalStateException("LoginService has different IdentityService to "+this);
|
||||
}
|
||||
|
||||
if (!_loginServiceShared && _loginService instanceof LifeCycle)
|
||||
((LifeCycle)_loginService).start();
|
||||
|
||||
Authenticator.Factory authenticatorFactory = getAuthenticatorFactory();
|
||||
if (_authenticator==null && authenticatorFactory!=null && _identityService!=null)
|
||||
{
|
||||
_authenticator=authenticatorFactory.getAuthenticator(getServer(),ContextHandler.getCurrentContext(),this, _identityService, _loginService);
|
||||
if (_authenticator!=null)
|
||||
_authMethod=_authenticator.getAuthMethod();
|
||||
}
|
||||
setAuthenticator(authenticatorFactory.getAuthenticator(getServer(),ContextHandler.getCurrentContext(),this, _identityService, _loginService));
|
||||
|
||||
if (_authenticator==null)
|
||||
{
|
||||
if (_realmName!=null)
|
||||
{
|
||||
LOG.warn("No ServerAuthentication for "+this);
|
||||
throw new IllegalStateException("No ServerAuthentication");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_authenticator!=null)
|
||||
_authenticator.setConfiguration(this);
|
||||
if (_authenticator instanceof LifeCycle)
|
||||
((LifeCycle)_authenticator).start();
|
||||
else if (_realmName!=null)
|
||||
{
|
||||
LOG.warn("No Authenticator for "+this);
|
||||
throw new IllegalStateException("No Authenticator");
|
||||
}
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.handler.HandlerWrapper#doStop()
|
||||
*/
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
super.doStop();
|
||||
|
||||
if (!_loginServiceShared && _loginService instanceof LifeCycle)
|
||||
((LifeCycle)_loginService).stop();
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected boolean checkSecurity(Request request)
|
||||
{
|
||||
|
|
|
@ -732,9 +732,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
|
||||
super.doStart();
|
||||
|
||||
if (_errorHandler != null)
|
||||
_errorHandler.start();
|
||||
|
||||
// Context listeners
|
||||
if (_contextListeners != null)
|
||||
{
|
||||
|
@ -1391,11 +1388,10 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
*/
|
||||
public void setErrorHandler(ErrorHandler errorHandler)
|
||||
{
|
||||
updateBean(_errorHandler,errorHandler);
|
||||
_errorHandler = errorHandler;
|
||||
if (errorHandler != null)
|
||||
errorHandler.setServer(getServer());
|
||||
|
||||
updateBean(_errorHandler,errorHandler);
|
||||
_errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -75,7 +75,6 @@ public class HandlerCollection extends AbstractHandlerContainer
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*
|
||||
* @param handlers The handlers to set.
|
||||
*/
|
||||
public void setHandlers(Handler[] handlers)
|
||||
|
@ -83,19 +82,14 @@ public class HandlerCollection extends AbstractHandlerContainer
|
|||
if (!_mutableWhenRunning && isStarted())
|
||||
throw new IllegalStateException(STARTED);
|
||||
|
||||
if (handlers!=null)
|
||||
for (Handler handler:handlers)
|
||||
handler.setServer(getServer());
|
||||
|
||||
updateBeans(_handlers, handlers);
|
||||
_handlers = handlers;
|
||||
|
||||
Server server = getServer();
|
||||
for (int i=0;handlers!=null && i<handlers.length;i++)
|
||||
{
|
||||
if (handlers[i].getServer()!=server)
|
||||
handlers[i].setServer(server);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see Handler#handle(String, Request, HttpServletRequest, HttpServletResponse)
|
||||
|
@ -145,9 +139,10 @@ public class HandlerCollection extends AbstractHandlerContainer
|
|||
public void setServer(Server server)
|
||||
{
|
||||
super.setServer(server);
|
||||
Handler[] h=getHandlers();
|
||||
for (int i=0;h!=null && i<h.length;i++)
|
||||
h[i].setServer(server);
|
||||
Handler[] handlers=getHandlers();
|
||||
if (handlers!=null)
|
||||
for (Handler h : handlers)
|
||||
h.setServer(server);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -103,15 +103,10 @@ public class HandlerWrapper extends AbstractHandlerContainer
|
|||
@Override
|
||||
public void setServer(Server server)
|
||||
{
|
||||
Server old_server=getServer();
|
||||
if (server==old_server)
|
||||
return;
|
||||
|
||||
if (isStarted())
|
||||
throw new IllegalStateException(STARTED);
|
||||
|
||||
super.setServer(server);
|
||||
|
||||
Handler h=getHandler();
|
||||
if (h!=null)
|
||||
h.setServer(server);
|
||||
|
|
|
@ -126,10 +126,6 @@ public class HotSwapHandler extends AbstractHandlerContainer
|
|||
@Override
|
||||
public void setServer(Server server)
|
||||
{
|
||||
Server old_server = getServer();
|
||||
if (server == old_server)
|
||||
return;
|
||||
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(RUNNING);
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ public class SessionHandler extends ScopedHandler
|
|||
public final static EnumSet<SessionTrackingMode> DEFAULT_TRACKING = EnumSet.of(SessionTrackingMode.COOKIE,SessionTrackingMode.URL);
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
private SessionManager _sessionManager;
|
||||
|
||||
|
@ -88,10 +87,10 @@ public class SessionHandler extends ScopedHandler
|
|||
{
|
||||
if (isStarted())
|
||||
throw new IllegalStateException();
|
||||
updateBean(_sessionManager,sessionManager);
|
||||
_sessionManager=sessionManager;
|
||||
if (sessionManager!=null)
|
||||
sessionManager.setSessionHandler(this);
|
||||
updateBean(_sessionManager,sessionManager);
|
||||
_sessionManager=sessionManager;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -101,7 +100,8 @@ public class SessionHandler extends ScopedHandler
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
_sessionManager.start();
|
||||
if (_sessionManager==null)
|
||||
setSessionManager(new HashSessionManager());
|
||||
super.doStart();
|
||||
}
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -112,7 +112,6 @@ public class SessionHandler extends ScopedHandler
|
|||
protected void doStop() throws Exception
|
||||
{
|
||||
// Destroy sessions before destroying servlets/filters see JETTY-1266
|
||||
_sessionManager.stop();
|
||||
super.doStop();
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void doStart()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -85,7 +85,6 @@ public class ServletContextHandler extends ContextHandler
|
|||
protected SessionHandler _sessionHandler;
|
||||
protected SecurityHandler _securityHandler;
|
||||
protected ServletHandler _servletHandler;
|
||||
protected HandlerWrapper _wrapper;
|
||||
protected int _options;
|
||||
protected JspConfigDescriptor _jspConfig;
|
||||
protected List<ServletContextListener> _restrictedContextListeners = new ArrayList<>();
|
||||
|
@ -112,8 +111,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
/* ------------------------------------------------------------ */
|
||||
public ServletContextHandler(HandlerContainer parent, String contextPath, int options)
|
||||
{
|
||||
this(parent,contextPath,null,null,null,null);
|
||||
_options=options;
|
||||
this(parent,contextPath,null,null,null,null,options);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -130,25 +128,71 @@ public class ServletContextHandler extends ContextHandler
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
public ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
|
||||
{
|
||||
this(parent,contextPath,sessionHandler,securityHandler,servletHandler,errorHandler,0);
|
||||
}
|
||||
|
||||
public ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler,int options)
|
||||
{
|
||||
super((ContextHandler.Context)null);
|
||||
_options=options;
|
||||
_scontext = new Context();
|
||||
_sessionHandler = sessionHandler;
|
||||
_securityHandler = securityHandler;
|
||||
_servletHandler = servletHandler;
|
||||
|
||||
if (errorHandler!=null)
|
||||
setErrorHandler(errorHandler);
|
||||
|
||||
if (contextPath!=null)
|
||||
setContextPath(contextPath);
|
||||
|
||||
|
||||
if (parent instanceof HandlerWrapper)
|
||||
((HandlerWrapper)parent).setHandler(this);
|
||||
else if (parent instanceof HandlerCollection)
|
||||
((HandlerCollection)parent).addHandler(this);
|
||||
}
|
||||
|
||||
|
||||
// Link the handlers
|
||||
relinkHandlers();
|
||||
|
||||
if (errorHandler!=null)
|
||||
setErrorHandler(errorHandler);
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void relinkHandlers()
|
||||
{
|
||||
HandlerWrapper handler=this;
|
||||
|
||||
// Skip any injected handlers
|
||||
while (handler.getHandler() instanceof HandlerWrapper)
|
||||
{
|
||||
HandlerWrapper wrapper = (HandlerWrapper)handler.getHandler();
|
||||
if (wrapper instanceof SessionHandler ||
|
||||
wrapper instanceof SecurityHandler ||
|
||||
wrapper instanceof ServletHandler)
|
||||
break;
|
||||
handler=wrapper;
|
||||
}
|
||||
|
||||
if (getSessionHandler()!=null)
|
||||
{
|
||||
handler.setHandler(_sessionHandler);
|
||||
handler=_sessionHandler;
|
||||
}
|
||||
|
||||
if (getSecurityHandler()!=null)
|
||||
{
|
||||
handler.setHandler(_securityHandler);
|
||||
handler=_securityHandler;
|
||||
}
|
||||
|
||||
if (getServletHandler()!=null)
|
||||
{
|
||||
handler.setHandler(_servletHandler);
|
||||
handler=_servletHandler;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.handler.ContextHandler#doStop()
|
||||
|
@ -159,8 +203,6 @@ public class ServletContextHandler extends ContextHandler
|
|||
super.doStop();
|
||||
if (_decorators != null)
|
||||
_decorators.clear();
|
||||
if (_wrapper != null)
|
||||
_wrapper.setHandler(null);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -212,43 +254,11 @@ public class ServletContextHandler extends ContextHandler
|
|||
*
|
||||
* @see org.eclipse.jetty.server.handler.ContextHandler#startContext()
|
||||
*/
|
||||
@Override
|
||||
protected void startContext() throws Exception
|
||||
{
|
||||
// force creation of missing handlers.
|
||||
getSessionHandler();
|
||||
getSecurityHandler();
|
||||
getServletHandler();
|
||||
|
||||
Handler handler = _servletHandler;
|
||||
if (_securityHandler!=null)
|
||||
{
|
||||
_securityHandler.setHandler(handler);
|
||||
handler=_securityHandler;
|
||||
}
|
||||
|
||||
if (_sessionHandler!=null)
|
||||
{
|
||||
_sessionHandler.setHandler(handler);
|
||||
handler=_sessionHandler;
|
||||
}
|
||||
|
||||
// skip any wrapped handlers
|
||||
_wrapper=this;
|
||||
while (_wrapper!=handler && _wrapper.getHandler() instanceof HandlerWrapper)
|
||||
_wrapper=(HandlerWrapper)_wrapper.getHandler();
|
||||
|
||||
// if we are not already linked
|
||||
if (_wrapper!=handler)
|
||||
{
|
||||
if (_wrapper.getHandler()!=null )
|
||||
throw new IllegalStateException("!ScopedHandler");
|
||||
_wrapper.setHandler(handler);
|
||||
}
|
||||
|
||||
super.startContext();
|
||||
|
||||
// OK to Initialize servlet handler now
|
||||
if (_servletHandler != null && _servletHandler.isStarted())
|
||||
if (_servletHandler != null)
|
||||
{
|
||||
for (int i=_decorators.size()-1;i>=0; i--)
|
||||
{
|
||||
|
@ -263,6 +273,8 @@ public class ServletContextHandler extends ContextHandler
|
|||
|
||||
_servletHandler.initialize();
|
||||
}
|
||||
|
||||
super.startContext();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -388,8 +400,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void restrictEventListener (EventListener e)
|
||||
{
|
||||
if (_restrictListeners && e instanceof ServletContextListener)
|
||||
|
@ -406,6 +417,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
this._restrictListeners = restrictListeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callContextInitialized(ServletContextListener l, ServletContextEvent e)
|
||||
{
|
||||
try
|
||||
|
@ -424,13 +436,12 @@ public class ServletContextHandler extends ContextHandler
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void callContextDestroyed(ServletContextListener l, ServletContextEvent e)
|
||||
{
|
||||
super.callContextDestroyed(l, e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param sessionHandler The sessionHandler to set.
|
||||
|
@ -440,7 +451,11 @@ public class ServletContextHandler extends ContextHandler
|
|||
if (isStarted())
|
||||
throw new IllegalStateException("STARTED");
|
||||
|
||||
if (_sessionHandler!=null)
|
||||
_sessionHandler.setHandler(null);
|
||||
|
||||
_sessionHandler = sessionHandler;
|
||||
relinkHandlers();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -452,7 +467,10 @@ public class ServletContextHandler extends ContextHandler
|
|||
if (isStarted())
|
||||
throw new IllegalStateException("STARTED");
|
||||
|
||||
if (_securityHandler!=null)
|
||||
_securityHandler.setHandler(null);
|
||||
_securityHandler = securityHandler;
|
||||
relinkHandlers();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -464,7 +482,15 @@ public class ServletContextHandler extends ContextHandler
|
|||
if (isStarted())
|
||||
throw new IllegalStateException("STARTED");
|
||||
|
||||
Handler next=null;
|
||||
if (_servletHandler!=null)
|
||||
{
|
||||
next=_servletHandler.getHandler();
|
||||
_servletHandler.setHandler(null);
|
||||
}
|
||||
_servletHandler = servletHandler;
|
||||
relinkHandlers();
|
||||
_servletHandler.setHandler(next);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -155,10 +155,10 @@ public class ServletHandler extends ScopedHandler
|
|||
_chainLRU[FilterMapping.ASYNC]=new ConcurrentLinkedQueue<String>();
|
||||
}
|
||||
|
||||
super.doStart();
|
||||
|
||||
if (_contextHandler==null)
|
||||
initialize();
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
@ -691,13 +691,6 @@ public class ServletHandler extends ScopedHandler
|
|||
{
|
||||
MultiException mx = new MultiException();
|
||||
|
||||
// Start filters
|
||||
if (_filters!=null)
|
||||
{
|
||||
for (FilterHolder filter : _filters)
|
||||
filter.start();
|
||||
}
|
||||
|
||||
if (_servlets!=null)
|
||||
{
|
||||
// Sort and Initialize servlets
|
||||
|
@ -717,8 +710,6 @@ public class ServletHandler extends ScopedHandler
|
|||
}
|
||||
servlet.setClassName(forced_holder.getClassName());
|
||||
}
|
||||
|
||||
servlet.start();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
*
|
||||
*/
|
||||
@ManagedObject("Servlet Holder")
|
||||
public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope, Comparable
|
||||
public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope, Comparable<ServletHolder>
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ServletHolder.class);
|
||||
|
||||
|
@ -190,32 +190,28 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
/* ------------------------------------------------------------ */
|
||||
/** Comparitor by init order.
|
||||
*/
|
||||
public int compareTo(Object o)
|
||||
@Override
|
||||
public int compareTo(ServletHolder sh)
|
||||
{
|
||||
if (o instanceof ServletHolder)
|
||||
{
|
||||
ServletHolder sh= (ServletHolder)o;
|
||||
if (sh==this)
|
||||
return 0;
|
||||
if (sh._initOrder<_initOrder)
|
||||
return 1;
|
||||
if (sh._initOrder>_initOrder)
|
||||
return -1;
|
||||
if (sh==this)
|
||||
return 0;
|
||||
if (sh._initOrder<_initOrder)
|
||||
return 1;
|
||||
if (sh._initOrder>_initOrder)
|
||||
return -1;
|
||||
|
||||
int c=(_className!=null && sh._className!=null)?_className.compareTo(sh._className):0;
|
||||
if (c==0)
|
||||
c=_name.compareTo(sh._name);
|
||||
if (c==0)
|
||||
c=this.hashCode()>o.hashCode()?1:-1;
|
||||
int c=(_className!=null && sh._className!=null)?_className.compareTo(sh._className):0;
|
||||
if (c==0)
|
||||
c=_name.compareTo(sh._name);
|
||||
if (c==0)
|
||||
c=this.hashCode()>sh.hashCode()?1:-1;
|
||||
return c;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return compareTo(o)==0;
|
||||
return o instanceof ServletHolder && compareTo((ServletHolder)o)==0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -209,7 +210,7 @@ public abstract class AbstractDoSFilterTest
|
|||
String request="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\n\r\n";
|
||||
String last="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n";
|
||||
String responses = doRequests(request+request+request+request,1,0,0,last);
|
||||
System.out.println("responses are " + responses);
|
||||
// System.out.println("responses are " + responses);
|
||||
assertEquals("200 OK responses", 5,count(responses,"HTTP/1.1 200 OK"));
|
||||
assertEquals("delayed responses", 1,count(responses,"DoSFilter: delayed"));
|
||||
assertEquals("throttled responses", 1,count(responses,"DoSFilter: throttled"));
|
||||
|
@ -246,7 +247,7 @@ public abstract class AbstractDoSFilterTest
|
|||
String last="GET /ctx/dos/test HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n";
|
||||
String responses = doRequests(request+request+request+request,1,0,0,last);
|
||||
|
||||
System.err.println("RESPONSES: \n"+responses);
|
||||
// System.err.println("RESPONSES: \n"+responses);
|
||||
|
||||
assertEquals(4,count(responses,"HTTP/1.1 200 OK"));
|
||||
assertEquals(1,count(responses,"HTTP/1.1 503"));
|
||||
|
@ -304,8 +305,7 @@ public abstract class AbstractDoSFilterTest
|
|||
// alternate between sessions
|
||||
responses = doRequests(request1+request2+request1+request2+request1,2,250,250,last);
|
||||
|
||||
System.err.println(responses);
|
||||
|
||||
// System.err.println(responses);
|
||||
assertEquals(11,count(responses,"HTTP/1.1 200 OK"));
|
||||
int delayedRequests = count(responses,"DoSFilter: delayed");
|
||||
assertTrue("delayedRequests: " + delayedRequests + " is not between 2 and 5",delayedRequests >= 2 && delayedRequests <= 5);
|
||||
|
|
|
@ -161,7 +161,7 @@ public class GzipWithPipeliningTest
|
|||
client.issueGET("/lots-of-fantasy-names.txt",true, false);
|
||||
|
||||
respHeader = client.readResponseHeader();
|
||||
System.out.println("Response Header #1 --\n" + respHeader);
|
||||
//System.out.println("Response Header #1 --\n" + respHeader);
|
||||
String expectedEncodingHeader = encodingHeader.equals(GzipFilter.DEFLATE) ? GzipFilter.DEFLATE : GzipFilter.GZIP;
|
||||
assertThat("Content-Encoding should be gzipped",respHeader,containsString("Content-Encoding: " + expectedEncodingHeader + "\r\n"));
|
||||
assertThat("Transfer-Encoding should be chunked",respHeader,containsString("Transfer-Encoding: chunked\r\n"));
|
||||
|
@ -171,28 +171,28 @@ public class GzipWithPipeliningTest
|
|||
FileOutputStream rawOutputStream = new FileOutputStream(rawOutputFile);
|
||||
|
||||
long chunkSize = client.readChunkSize();
|
||||
System.out.println("Chunk Size: " + chunkSize);
|
||||
//System.out.println("Chunk Size: " + chunkSize);
|
||||
|
||||
// Read only 20% - intentionally a partial read.
|
||||
System.out.println("Attempting to read partial content ...");
|
||||
//System.out.println("Attempting to read partial content ...");
|
||||
int readBytes = client.readBody(rawOutputStream,(int)(chunkSize * 0.20f));
|
||||
System.out.printf("Read %,d bytes%n",readBytes);
|
||||
//System.out.printf("Read %,d bytes%n",readBytes);
|
||||
|
||||
// Issue another request
|
||||
client.issueGET("/jetty_logo.png",true, false);
|
||||
|
||||
// Finish reading chunks
|
||||
System.out.println("Finish reading remaining chunks ...");
|
||||
//System.out.println("Finish reading remaining chunks ...");
|
||||
String line;
|
||||
chunkSize = chunkSize - readBytes;
|
||||
while (chunkSize > 0)
|
||||
{
|
||||
readBytes = client.readBody(rawOutputStream,(int)chunkSize);
|
||||
System.out.printf("Read %,d bytes%n",readBytes);
|
||||
//System.out.printf("Read %,d bytes%n",readBytes);
|
||||
line = client.readLine();
|
||||
assertThat("Chunk delim should be an empty line with CR+LF",line,is(""));
|
||||
chunkSize = client.readChunkSize();
|
||||
System.out.printf("Next Chunk: (0x%X) %,d bytes%n",chunkSize,chunkSize);
|
||||
//System.out.printf("Next Chunk: (0x%X) %,d bytes%n",chunkSize,chunkSize);
|
||||
}
|
||||
|
||||
// Inter-pipeline delim
|
||||
|
@ -220,7 +220,7 @@ public class GzipWithPipeliningTest
|
|||
|
||||
// Read 2nd request http response header
|
||||
respHeader = client.readResponseHeader();
|
||||
System.out.println("Response Header #2 --\n" + respHeader);
|
||||
//System.out.println("Response Header #2 --\n" + respHeader);
|
||||
assertThat("Content-Encoding should NOT be gzipped",respHeader,not(containsString("Content-Encoding: gzip\r\n")));
|
||||
assertThat("Transfer-Encoding should NOT be chunked",respHeader,not(containsString("Transfer-Encoding: chunked\r\n")));
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ public class PipelineHelper
|
|||
{
|
||||
int len = inputStream.read(partial,readBytes,bytesLeft);
|
||||
Assert.assertThat("Read should not have hit EOL yet",len,not(-1));
|
||||
System.out.printf("Read %,d bytes%n",len);
|
||||
//System.out.printf("Read %,d bytes%n",len);
|
||||
if (len > 0)
|
||||
{
|
||||
readBytes += len;
|
||||
|
|
|
@ -223,7 +223,6 @@ public class PutFilterTest
|
|||
request.setHeader("Content-Type","text/plain");
|
||||
String data1="How Now BROWN COW!!!!";
|
||||
request.setContent(data1);
|
||||
System.err.println(request);
|
||||
response = HttpTester.parseResponse(tester.getResponses(request.generate()));
|
||||
|
||||
assertEquals(HttpServletResponse.SC_CREATED,response.getStatus());
|
||||
|
|
|
@ -80,7 +80,7 @@ public class GzipTester
|
|||
|
||||
public void assertIsResponseGzipCompressed(String requestedFilename, String serverFilename) throws Exception
|
||||
{
|
||||
System.err.printf("[GzipTester] requesting /context/%s%n",requestedFilename);
|
||||
// System.err.printf("[GzipTester] requesting /context/%s%n",requestedFilename);
|
||||
HttpTester.Request request = HttpTester.newRequest();
|
||||
HttpTester.Response response;
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class GzipTester
|
|||
*/
|
||||
public void assertIsResponseNotGzipFiltered(String requestedFilename, String testResourceSha1Sum, String expectedContentType) throws Exception
|
||||
{
|
||||
System.err.printf("[GzipTester] requesting /context/%s%n",requestedFilename);
|
||||
//System.err.printf("[GzipTester] requesting /context/%s%n",requestedFilename);
|
||||
HttpTester.Request request = HttpTester.newRequest();
|
||||
HttpTester.Response response;
|
||||
|
||||
|
@ -197,14 +197,14 @@ public class GzipTester
|
|||
|
||||
private void dumpHeaders(String prefix, HttpTester.Message message)
|
||||
{
|
||||
System.out.println(prefix);
|
||||
//System.out.println(prefix);
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<String> names = message.getFieldNames();
|
||||
while (names.hasMoreElements())
|
||||
{
|
||||
String name = names.nextElement();
|
||||
String value = message.get(name);
|
||||
System.out.printf(" [%s] = %s%n",name,value);
|
||||
//System.out.printf(" [%s] = %s%n",name,value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public class GzipTester
|
|||
|
||||
private HttpTester.Response executeRequest(String uri) throws IOException, Exception
|
||||
{
|
||||
System.err.printf("[GzipTester] requesting %s%n",uri);
|
||||
//System.err.printf("[GzipTester] requesting %s%n",uri);
|
||||
HttpTester.Request request = HttpTester.newRequest();
|
||||
HttpTester.Response response;
|
||||
|
||||
|
|
|
@ -324,6 +324,11 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bean._bean instanceof AbstractLifeCycle)
|
||||
{
|
||||
((AbstractLifeCycle)bean._bean).setStopTimeout(getStopTimeout());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -456,11 +461,8 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
|||
super.setStopTimeout(stopTimeout);
|
||||
for (Bean bean : _beans)
|
||||
{
|
||||
Object component = bean._bean;
|
||||
if (component instanceof AbstractLifeCycle)
|
||||
{
|
||||
((AbstractLifeCycle)component).setStopTimeout(stopTimeout);
|
||||
}
|
||||
if (bean.isManaged() && bean._bean instanceof AbstractLifeCycle)
|
||||
((AbstractLifeCycle)bean._bean).setStopTimeout(stopTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# Setup default logging implementation for during testing
|
||||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.io.LEVEL=DEBUG
|
||||
#org.eclipse.jetty.io.LEVEL=DEBUG
|
||||
|
|
|
@ -246,7 +246,7 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
String servlet_class = node.getString("servlet-class", false, true);
|
||||
|
||||
// Handle JSP
|
||||
String jspServletClass=null;;
|
||||
String jspServletClass=null;
|
||||
|
||||
//Handle the default jsp servlet instance
|
||||
if (id != null && id.equals("jsp"))
|
||||
|
@ -315,7 +315,9 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
|
|||
if (jsp_file != null)
|
||||
{
|
||||
holder.setForcedPath(jsp_file);
|
||||
holder.setClassName(jspServletClass); //only use our default instance
|
||||
ServletHolder jsp=context.getServletHandler().getServlet("jsp");
|
||||
if (jsp!=null)
|
||||
holder.setClassName(jsp.getClassName());
|
||||
}
|
||||
|
||||
// handle load-on-startup
|
||||
|
|
|
@ -1301,7 +1301,6 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
return servletContext;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
Loading…
Reference in New Issue