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:
parent
4912c23732
commit
1b0347c0ac
|
@ -4,6 +4,7 @@ jetty-7.0.2-SNAPSHOT
|
||||||
+ 296765 JMX Connector Server and ShutdownThread
|
+ 296765 JMX Connector Server and ShutdownThread
|
||||||
+ 297421 Hide server/system classes from WebAppClassLoader.getResources
|
+ 297421 Hide server/system classes from WebAppClassLoader.getResources
|
||||||
+ 297783 Handle HEAD reponses in HttpClient
|
+ 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-1156 SSL blocking close with JVM Bug busy key fix
|
||||||
+ JETTY-1157 Don't hold array passed in write(byte[])
|
+ JETTY-1157 Don't hold array passed in write(byte[])
|
||||||
+ COMETD-46 reset ContentExchange response content on resend
|
+ COMETD-46 reset ContentExchange response content on resend
|
||||||
|
|
|
@ -597,18 +597,11 @@ public class HttpConnection implements Connection
|
||||||
throw (ThreadDeath)e;
|
throw (ThreadDeath)e;
|
||||||
|
|
||||||
error=true;
|
error=true;
|
||||||
if (info==null)
|
Log.warn(_uri+": "+e);
|
||||||
{
|
Log.debug(e);
|
||||||
Log.debug(_uri+": "+e);
|
_request.setHandled(true);
|
||||||
_request.setHandled(true);
|
_generator.sendError(info==null?400:500, null, null, true);
|
||||||
_generator.sendError(400, null, null, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.debug(""+_uri,e);
|
|
||||||
_request.setHandled(true);
|
|
||||||
_generator.sendError(500, null, null, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ public class Request implements HttpServletRequest
|
||||||
public HttpSession getSession(boolean create)
|
public HttpSession getSession(boolean create)
|
||||||
{
|
{
|
||||||
if (_sessionManager==null && 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))
|
if (_session != null && _sessionManager!=null && _sessionManager.isValid(_session))
|
||||||
return _session;
|
return _session;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.SessionManager;
|
import org.eclipse.jetty.server.SessionManager;
|
||||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||||
|
import org.eclipse.jetty.server.handler.ScopedHandler;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
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;
|
private SessionManager _sessionManager;
|
||||||
|
@ -126,12 +127,13 @@ public class SessionHandler extends HandlerWrapper
|
||||||
_sessionManager.stop();
|
_sessionManager.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
|
* @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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
|
throws IOException, ServletException
|
||||||
{
|
{
|
||||||
setRequestedId(baseRequest,request);
|
setRequestedId(baseRequest,request);
|
||||||
|
@ -179,7 +181,18 @@ public class SessionHandler extends HandlerWrapper
|
||||||
Log.debug("session="+session);
|
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
|
finally
|
||||||
{
|
{
|
||||||
|
@ -195,6 +208,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
|
/** Look for a requested session ID in cookies and URI parameters
|
||||||
|
|
|
@ -98,6 +98,7 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
|
||||||
|
|
||||||
public void requestInitialized(ServletRequestEvent sre)
|
public void requestInitialized(ServletRequestEvent sre)
|
||||||
{
|
{
|
||||||
|
((HttpServletRequest)sre.getServletRequest()).getSession(true).getId();
|
||||||
sre.getServletRequest().setAttribute("requestInitialized","'"+sre.getServletContext().getContextPath()+"'");
|
sre.getServletRequest().setAttribute("requestInitialized","'"+sre.getServletContext().getContextPath()+"'");
|
||||||
// System.err.println("requestInitialized "+sre);
|
// System.err.println("requestInitialized "+sre);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue