[jboss-cvs] JBossAS SVN: r87464 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/session.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 16 18:46:00 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-04-16 18:46:00 -0400 (Thu, 16 Apr 2009)
New Revision: 87464
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java
Log:
Don't duplicate logic for invoke and event
Get rid of genericized code that crashes some Sun JDK compilers
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java 2009-04-16 21:57:35 UTC (rev 87463)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/ClusteredSessionValve.java 2009-04-16 22:46:00 UTC (rev 87464)
@@ -22,6 +22,7 @@
package org.jboss.web.tomcat.service.session;
import java.io.IOException;
+import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletException;
@@ -36,7 +37,7 @@
import org.apache.catalina.valves.ValveBase;
import org.jboss.servlet.http.HttpEvent;
import org.jboss.web.tomcat.service.session.distributedcache.spi.BatchingManager;
-import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
+//import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
/**
* This Valve detects all sessions that were used in a request. All sessions are given to a snapshot
@@ -90,59 +91,7 @@
*/
public void invoke(Request request, Response response) throws IOException, ServletException
{
- // Initialize the context and store the request and response objects
- // for any clustering code that has no direct access to these objects
- SessionReplicationContext.enterWebapp(request, response, true);
-
- boolean startedBatch = startBatchTransaction();
- try
- {
- // Workaround to JBAS-5735. Ensure we get the session from the manager
- // rather than a cached ref from the Request.
- String requestedId = request.getRequestedSessionId();
- if (requestedId != null)
- {
- manager.findSession(requestedId);
- }
-
-
- // let the servlet invocation go through
- getNext().invoke(request, response);
- }
- finally // We replicate no matter what
- {
- // --> We are now after the servlet invocation
- try
- {
- SessionReplicationContext ctx = SessionReplicationContext.exitWebapp();
-
- if (ctx.getSoleSnapshotManager() != null)
- {
- ctx.getSoleSnapshotManager().snapshot(ctx.getSoleSession());
- }
- else
- {
- // Cross-context request touched multiple sesssions;
- // need to replicate them all
- Map<ClusteredSession<? extends OutgoingDistributableSessionData>, SnapshotManager> sessions = ctx.getCrossContextSessions();
- if (sessions != null && sessions.size() > 0)
- {
- for (Map.Entry<ClusteredSession<? extends OutgoingDistributableSessionData>, SnapshotManager> entry : sessions.entrySet())
- {
- entry.getValue().snapshot(entry.getKey());
- }
- }
- }
- }
- finally
- {
- if (startedBatch)
- {
- tm.endBatch();
- }
- }
-
- }
+ handleRequest(request, response, null, false);
}
/**
@@ -155,6 +104,11 @@
*/
public void event(Request request, Response response, HttpEvent event) throws IOException, ServletException
{
+ handleRequest(request, response, event, true);
+ }
+
+ private void handleRequest(Request request, Response response, HttpEvent event, boolean isEvent) throws IOException, ServletException
+ {
// Initialize the context and store the request and response objects
// for any clustering code that has no direct access to these objects
SessionReplicationContext.enterWebapp(request, response, true);
@@ -172,7 +126,14 @@
// let the servlet invocation go through
- getNext().event(request, response, event);
+ if (isEvent)
+ {
+ getNext().event(request, response, event);
+ }
+ else
+ {
+ getNext().invoke(request, response);
+ }
}
finally // We replicate no matter what
{
@@ -189,14 +150,8 @@
{
// Cross-context request touched multiple sesssions;
// need to replicate them all
- Map<ClusteredSession<? extends OutgoingDistributableSessionData>, SnapshotManager> sessions = ctx.getCrossContextSessions();
- if (sessions != null && sessions.size() > 0)
- {
- for (Map.Entry<ClusteredSession<? extends OutgoingDistributableSessionData>, SnapshotManager> entry : sessions.entrySet())
- {
- entry.getValue().snapshot(entry.getKey());
- }
- }
+ handleCrossContextSessions(ctx);
+
}
}
finally
@@ -259,4 +214,31 @@
return started;
}
+ @SuppressWarnings("unchecked")
+ private void handleCrossContextSessions(SessionReplicationContext ctx)
+ {
+ // Genericized code below crashes some Sun JDK compilers; see
+ // http://www.jboss.org/index.html?module=bb&op=viewtopic&t=154175
+
+// Map<ClusteredSession<? extends OutgoingDistributableSessionData>, SnapshotManager> sessions = ctx.getCrossContextSessions();
+// if (sessions != null && sessions.size() > 0)
+// {
+// for (Map.Entry<ClusteredSession<? extends OutgoingDistributableSessionData>, SnapshotManager> entry : sessions.entrySet())
+// {
+// entry.getValue().snapshot(entry.getKey());
+// }
+// }
+
+ // So, use this non-genericized code instead
+ Map sessions = ctx.getCrossContextSessions();
+ if (sessions != null && sessions.size() > 0)
+ {
+ for (Iterator it = sessions.entrySet().iterator(); it.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ ((SnapshotManager) entry.getValue()).snapshot((ClusteredSession) entry.getKey());
+ }
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list