You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2010/03/12 18:17:41 UTC
svn commit: r922356 -
/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.java
Author: ivaynberg
Date: Fri Mar 12 17:17:40 2010
New Revision: 922356
URL: http://svn.apache.org/viewvc?rev=922356&view=rev
Log:
WICKET-2778 Set Application ThreadLocal in WicketSessionFilter
Issue: WICKET-2778
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.java?rev=922356&r1=922355&r2=922356&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/WicketSessionFilter.java Fri Mar 12 17:17:40 2010
@@ -147,11 +147,13 @@ public class WicketSessionFilter impleme
{
HttpServletRequest httpServletRequest = ((HttpServletRequest)request);
HttpSession httpSession = httpServletRequest.getSession(false);
+ WebApplication application = null;
+ Session session = null;
if (httpSession != null)
{
if (sessionKey == null)
{
- WebApplication application = (WebApplication)Application.get(filterName);
+ application = (WebApplication)Application.get(filterName);
if (application == null)
{
throw new IllegalStateException(
@@ -160,34 +162,14 @@ public class WicketSessionFilter impleme
". Make sure you set filterName attribute to the name of the wicket filter " +
"for the wicket application whose session you want to access.");
}
+
sessionKey = application.getSessionAttributePrefix(null, filterName) +
Session.SESSION_ATTRIBUTE_NAME;
log.debug("will use {} as the session key to get the Wicket session", sessionKey);
}
- Session session = (Session)httpSession.getAttribute(sessionKey);
- if (session != null)
- {
- // set the session's threadlocal
- ThreadContext.setSession(session);
-
- if (log.isDebugEnabled())
- {
- log.debug("session " + session + " set as current for " +
- httpServletRequest.getContextPath() + "," +
- httpServletRequest.getServerName());
- }
- }
- else
- {
- if (log.isDebugEnabled())
- {
- log.debug("could not set Wicket session: key " + sessionKey +
- " not found in http session for " + httpServletRequest.getContextPath() +
- "," + httpServletRequest.getServerName());
- }
- }
+ session = (Session)httpSession.getAttribute(sessionKey);
}
else
{
@@ -195,14 +177,38 @@ public class WicketSessionFilter impleme
httpServletRequest.getContextPath(), httpServletRequest.getServerName());
}
- try
+ if (session == null)
{
+ // no session found
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("could not set Wicket session: key " + sessionKey +
+ " not found in http session for " + httpServletRequest.getContextPath() + "," +
+ httpServletRequest.getServerName());
+ }
+
// go on with processing
chain.doFilter(request, response);
}
- finally
+ else
{
- ThreadContext.detach();
+ // session found
+
+ try
+ {
+ ThreadContext.setApplication(application);
+ ThreadContext.setSession(session);
+ log.debug("session " + session + " set as current for " +
+ httpServletRequest.getContextPath() + "," + httpServletRequest.getServerName());
+
+ // go on with processing
+ chain.doFilter(request, response);
+ }
+ finally
+ {
+ ThreadContext.detach();
+ }
}
}