JETTY-910 Allow request listeners to access session

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1158 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-12-17 13:00:28 +00:00
parent 4912c23732
commit 1b0347c0ac
5 changed files with 44 additions and 16 deletions

View File

@ -4,6 +4,7 @@ jetty-7.0.2-SNAPSHOT
+ 296765 JMX Connector Server and ShutdownThread
+ 297421 Hide server/system classes from WebAppClassLoader.getResources
+ 297783 Handle HEAD reponses in HttpClient
+ JETTY-910 Allow request listeners to access session
+ JETTY-1156 SSL blocking close with JVM Bug busy key fix
+ JETTY-1157 Don't hold array passed in write(byte[])
+ COMETD-46 reset ContentExchange response content on resend

View File

@ -597,18 +597,11 @@ public class HttpConnection implements Connection
throw (ThreadDeath)e;
error=true;
if (info==null)
{
Log.debug(_uri+": "+e);
_request.setHandled(true);
_generator.sendError(400, null, null, true);
}
else
{
Log.debug(""+_uri,e);
_request.setHandled(true);
_generator.sendError(500, null, null, true);
}
Log.warn(_uri+": "+e);
Log.debug(e);
_request.setHandled(true);
_generator.sendError(info==null?400:500, null, null, true);
}
finally
{

View File

@ -1093,7 +1093,7 @@ public class Request implements HttpServletRequest
public HttpSession getSession(boolean create)
{
if (_sessionManager==null && create)
throw new IllegalStateException("No SessionHandler or SessionManager");
throw new IllegalStateException("No SessionManager");
if (_session != null && _sessionManager!=null && _sessionManager.isValid(_session))
return _session;

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.SessionManager;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.server.handler.ScopedHandler;
import org.eclipse.jetty.util.log.Log;
/* ------------------------------------------------------------ */
@ -36,7 +37,7 @@ import org.eclipse.jetty.util.log.Log;
*
*
*/
public class SessionHandler extends HandlerWrapper
public class SessionHandler extends ScopedHandler
{
/* -------------------------------------------------------------- */
private SessionManager _sessionManager;
@ -126,12 +127,13 @@ public class SessionHandler extends HandlerWrapper
_sessionManager.stop();
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
*/
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
setRequestedId(baseRequest,request);
@ -179,7 +181,18 @@ public class SessionHandler extends HandlerWrapper
Log.debug("session="+session);
}
getHandler().handle(target, baseRequest, request, response);
// start manual inline of nextScope(target,baseRequest,request,response);
//noinspection ConstantIfStatement
if (false)
nextScope(target,baseRequest,request,response);
else if (_nextScope!=null)
_nextScope.doScope(target,baseRequest,request, response);
else if (_outerScope!=null)
_outerScope.doHandle(target,baseRequest,request, response);
else
doHandle(target,baseRequest,request, response);
// end manual inline (pathentic attempt to reduce stack depth)
}
finally
{
@ -196,6 +209,26 @@ public class SessionHandler extends HandlerWrapper
}
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
*/
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
// start manual inline of nextHandle(target,baseRequest,request,response);
//noinspection ConstantIfStatement
if (false)
nextHandle(target,baseRequest,request,response);
else if (_nextScope!=null && _nextScope==_handler)
_nextScope.doHandle(target,baseRequest,request, response);
else if (_handler!=null)
_handler.handle(target,baseRequest, request, response);
// end manual inline
}
/* ------------------------------------------------------------ */
/** Look for a requested session ID in cookies and URI parameters
* @param request

View File

@ -98,6 +98,7 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
public void requestInitialized(ServletRequestEvent sre)
{
((HttpServletRequest)sre.getServletRequest()).getSession(true).getId();
sre.getServletRequest().setAttribute("requestInitialized","'"+sre.getServletContext().getContextPath()+"'");
// System.err.println("requestInitialized "+sre);
}