Author: chris.laprun(a)jboss.com
Date: 2011-09-20 13:41:46 -0400 (Tue, 20 Sep 2011)
New Revision: 7470
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/ProducerSessionInformation.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java
Log:
- Clustering work: use "real" session id to store session information since
JBoss Web will modify it. Experimental: needs to be tested!
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/ProducerSessionInformation.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/ProducerSessionInformation.java 2011-09-20
17:32:45 UTC (rev 7469)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/ProducerSessionInformation.java 2011-09-20
17:41:46 UTC (rev 7470)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -91,8 +91,27 @@
*/
public void setParentSessionId(String parentSessionId)
{
- if (this.parentSessionId != null &&
!this.parentSessionId.equals(parentSessionId))
+ boolean error = false;
+
+ if (parentSessionId != null)
{
+ parentSessionId = SessionHandler.getRealId(parentSessionId);
+
+ if (this.parentSessionId != null &&
!parentSessionId.equals(this.parentSessionId))
+ {
+ error = true;
+ }
+ }
+ else
+ {
+ if (this.parentSessionId != null)
+ {
+ error = true;
+ }
+ }
+
+ if (error)
+ {
throw new IllegalStateException("Cannot modify Parent Session id once it
has been set!");
}
@@ -224,7 +243,8 @@
}
/**
- * Retrieves the session id for the portlet with the specified handle. Note that this
will "touch" the session, hence
+ * Retrieves the session id for the portlet with the specified handle. Note that this
will "touch" the session,
+ * hence
* resetting the time since the last use of the session.
*
* @param portletHandle the handle of the portlet for which the session id is to be
retrieved
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java 2011-09-20
17:32:45 UTC (rev 7469)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/SessionHandler.java 2011-09-20
17:41:46 UTC (rev 7470)
@@ -401,7 +401,7 @@
{
if (SessionEvent.SessionEventType.SESSION_DESTROYED.equals(event.getType()))
{
- String id = event.getSession().getId();
+ String id = getRealId(event.getSession().getId());
// check if the session being destroyed is the one associated with this thread
ProducerSessionInformation info =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
@@ -424,6 +424,29 @@
}
/**
+ * Copied from org.jboss.web.tomcat.service.session.Util.
+ * <p/>
+ * Returns a session id with any trailing jvmRoute removed.
+ *
+ * @param sessionId the raw session id
+ * @return <code>sessionId</code> with the final '.' and any
+ * characters thereafter removed.
+ */
+ public static String getRealId(String sessionId)
+ {
+ int index = sessionId.lastIndexOf(".");
+ if (index > 0)
+ {
+ return sessionId.substring(0, index);
+ }
+ else
+ {
+ return sessionId;
+ }
+ }
+
+
+ /**
* @param originalHandle
* @param newHandle
* @param invocation
Show replies by date