Author: mstruk
Date: 2011-02-23 05:15:49 -0500 (Wed, 23 Feb 2011)
New Revision: 5921
Modified:
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ContainerServlet.java
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
Log:
Off switch for cross-context session invalidation on logout - prototype impl
Modified:
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ContainerServlet.java
===================================================================
---
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ContainerServlet.java 2011-02-23
06:42:19 UTC (rev 5920)
+++
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ContainerServlet.java 2011-02-23
10:15:49 UTC (rev 5921)
@@ -26,6 +26,8 @@
import org.apache.catalina.Wrapper;
import org.apache.catalina.Container;
import org.apache.catalina.Engine;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
@@ -36,7 +38,10 @@
*/
public class TC6ContainerServlet extends HttpServlet implements ContainerServlet
{
+ private static final Logger log = LoggerFactory.getLogger(TC6ContainerServlet.class);
+ private static final String INVALIDATE_SESSION_IN_ALL_CTX =
"org.gatein.invalidate_session_in_all_ctx";
+
/** . */
private Wrapper wrapper;
@@ -108,6 +113,7 @@
{
Engine engine = (Engine)container;
containerContext = new TC6ServletContainerContext(engine);
+
containerContext.setInvalidateSessionInAllContexts(getInvalidateSessionInAllContextsConfig());
containerContext.start();
break;
}
@@ -124,4 +130,16 @@
containerContext = null;
}
}
+
+ public boolean getInvalidateSessionInAllContextsConfig() {
+ String val = getServletContext().getInitParameter(INVALIDATE_SESSION_IN_ALL_CTX);
+ if (val == null || Boolean.valueOf(val))
+ return true;
+
+ if (!"false".equalsIgnoreCase(val))
+ log.warn("Context init param " + INVALIDATE_SESSION_IN_ALL_CTX +
" value is invalid: " + val + " - falling back to: false");
+
+ log.info("Cross-context session invalidation on logout disabled");
+ return false;
+ }
}
Modified:
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
===================================================================
---
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2011-02-23
06:42:19 UTC (rev 5920)
+++
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2011-02-23
10:15:49 UTC (rev 5921)
@@ -77,6 +77,9 @@
/** . */
private Registration registration;
+ /** perform cross context session invalidation on logout, or not */
+ private boolean invalidateSessionInAllCtx = true;
+
public TC6ServletContainerContext(Engine engine)
{
this.engine = engine;
@@ -115,8 +118,11 @@
return;
sess.invalidate();
+
+ if (!invalidateSessionInAllCtx)
+ return;
+
final String sessId = sess.getId();
-
DefaultServletContainerFactory.getInstance().getServletContainer().visit(new
ServletContainerVisitor()
{
public void accept(WebApp webApp)
@@ -332,4 +338,8 @@
e.printStackTrace();
}
}
+
+ public void setInvalidateSessionInAllContexts(boolean val) {
+ invalidateSessionInAllCtx = val;
+ }
}
Show replies by date