Author: mstruk
Date: 2011-03-11 09:27:41 -0500 (Fri, 11 Mar 2011)
New Revision: 6009
Modified:
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ContainerServlet.java
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java
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
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ContainerServlet.java
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
Log:
Renamed off-switch init param and consistently renamed fields and methods + applied
off-switch to JB6, and TC7
Modified:
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ContainerServlet.java
===================================================================
---
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ContainerServlet.java 2011-03-11
10:58:08 UTC (rev 6008)
+++
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ContainerServlet.java 2011-03-11
14:27:41 UTC (rev 6009)
@@ -29,6 +29,8 @@
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Engine;
import org.apache.catalina.Wrapper;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
@@ -36,6 +38,11 @@
*/
public class JB6ContainerServlet extends HttpServlet implements ContainerServlet
{
+ private static final Logger log = LoggerFactory.getLogger(JB6ContainerServlet.class);
+
+ /** Servlet context init parameter name that can be used to turn off cross-context
logout */
+ private static final String CROSS_CONTEXT_LOGOUT_KEY =
"org.gatein.wci.cross_context_logout";
+
/** . */
private Wrapper wrapper;
@@ -107,6 +114,7 @@
{
Engine engine = (Engine) container;
containerContext = new JB6ServletContainerContext(engine);
+ containerContext.setCrossContextLogout(getCrossContextLogoutConfig());
containerContext.start();
break;
}
@@ -123,4 +131,21 @@
containerContext = null;
}
}
+
+ private boolean getCrossContextLogoutConfig()
+ {
+ String val = getServletContext().getInitParameter(CROSS_CONTEXT_LOGOUT_KEY);
+ if (val == null || Boolean.valueOf(val))
+ {
+ return true;
+ }
+
+ if (!"false".equalsIgnoreCase(val))
+ {
+ log.warn("Context init param " + CROSS_CONTEXT_LOGOUT_KEY + "
value is invalid: " + val + " - falling back to: false");
+ }
+
+ log.info("Cross-context session invalidation on logout disabled");
+ return false;
+ }
}
Modified:
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java
===================================================================
---
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java 2011-03-11
10:58:08 UTC (rev 6008)
+++
components/wci/branches/logout/jboss/jboss6/src/main/java/org/gatein/wci/jboss/JB6ServletContainerContext.java 2011-03-11
14:27:41 UTC (rev 6009)
@@ -78,6 +78,9 @@
/** . */
private Registration registration;
+ /** Perform cross-context session invalidation on logout, or not */
+ private boolean crossContextLogout = true;
+
public JB6ServletContainerContext(Engine engine)
{
this.engine = engine;
@@ -99,6 +102,11 @@
this.registration = null;
}
+ public void setCrossContextLogout(boolean val)
+ {
+ crossContextLogout = val;
+ }
+
public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws ServletException, IOException
{
login(request, response, credentials, validityMillis, null);
@@ -142,8 +150,10 @@
if (sess == null)
return;
+ if (!crossContextLogout)
+ return;
+
final String sessId = sess.getId();
-
DefaultServletContainerFactory.getInstance().getServletContainer().visit(new
ServletContainerVisitor()
{
public void accept(WebApp webApp)
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-03-11
10:58:08 UTC (rev 6008)
+++
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ContainerServlet.java 2011-03-11
14:27:41 UTC (rev 6009)
@@ -40,7 +40,8 @@
{
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";
+ /** Servlet context init parameter name that can be used to turn off cross-context
logout */
+ private static final String CROSS_CONTEXT_LOGOUT_KEY =
"org.gatein.wci.cross_context_logout";
/** . */
private Wrapper wrapper;
@@ -113,7 +114,7 @@
{
Engine engine = (Engine)container;
containerContext = new TC6ServletContainerContext(engine);
-
containerContext.setInvalidateSessionInAllContexts(getInvalidateSessionInAllContextsConfig());
+ containerContext.setCrossContextLogout(getCrossContextLogoutConfig());
containerContext.start();
break;
}
@@ -131,13 +132,13 @@
}
}
- public boolean getInvalidateSessionInAllContextsConfig() {
- String val = getServletContext().getInitParameter(INVALIDATE_SESSION_IN_ALL_CTX);
+ private boolean getCrossContextLogoutConfig() {
+ String val = getServletContext().getInitParameter(CROSS_CONTEXT_LOGOUT_KEY);
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.warn("Context init param " + CROSS_CONTEXT_LOGOUT_KEY + "
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-03-11
10:58:08 UTC (rev 6008)
+++
components/wci/branches/logout/tomcat/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2011-03-11
14:27:41 UTC (rev 6009)
@@ -78,8 +78,8 @@
/** . */
private Registration registration;
- /** perform cross context session invalidation on logout, or not */
- private boolean invalidateSessionInAllCtx = true;
+ /** Perform cross-context session invalidation on logout, or not */
+ private boolean crossContextLogout = true;
/** . */
private GenericAuthentication authentication = new GenericAuthentication();
@@ -109,6 +109,11 @@
this.registration = null;
}
+ public void setCrossContextLogout(boolean val)
+ {
+ crossContextLogout = val;
+ }
+
public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws IOException
{
authentication.login(credentials, request, response, validityMillis);
@@ -128,7 +133,7 @@
sess.invalidate();
- if (!invalidateSessionInAllCtx)
+ if (!crossContextLogout)
return;
final String sessId = sess.getId();
@@ -352,8 +357,4 @@
e.printStackTrace();
}
}
-
- public void setInvalidateSessionInAllContexts(boolean val) {
- invalidateSessionInAllCtx = val;
- }
}
Modified:
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ContainerServlet.java
===================================================================
---
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ContainerServlet.java 2011-03-11
10:58:08 UTC (rev 6008)
+++
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ContainerServlet.java 2011-03-11
14:27:41 UTC (rev 6009)
@@ -26,6 +26,8 @@
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Engine;
import org.apache.catalina.Wrapper;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -36,7 +38,11 @@
*/
public class TC7ContainerServlet extends HttpServlet implements ContainerServlet
{
+ private static final Logger log = LoggerFactory.getLogger(TC7ContainerServlet.class);
+ /** Servlet context init parameter name that can be used to turn off cross-context
logout */
+ private static final String CROSS_CONTEXT_LOGOUT_KEY =
"org.gatein.wci.cross_context_logout";
+
/** . */
private Wrapper wrapper;
@@ -108,6 +114,7 @@
{
Engine engine = (Engine)container;
containerContext = new TC7ServletContainerContext(engine);
+ containerContext.setCrossContextLogout(getCrossContextLogoutConfig());
containerContext.start();
break;
}
@@ -124,4 +131,16 @@
containerContext = null;
}
}
+
+ private boolean getCrossContextLogoutConfig() {
+ String val = getServletContext().getInitParameter(CROSS_CONTEXT_LOGOUT_KEY);
+ if (val == null || Boolean.valueOf(val))
+ return true;
+
+ if (!"false".equalsIgnoreCase(val))
+ log.warn("Context init param " + CROSS_CONTEXT_LOGOUT_KEY + "
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/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
===================================================================
---
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2011-03-11
10:58:08 UTC (rev 6008)
+++
components/wci/branches/logout/tomcat/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2011-03-11
14:27:41 UTC (rev 6009)
@@ -81,6 +81,9 @@
/** . */
private Registration registration;
+ /** Perform cross-context session invalidation on logout, or not */
+ private boolean crossContextLogout = true;
+
public TC7ServletContainerContext(Engine engine)
{
this.engine = engine;
@@ -106,6 +109,11 @@
this.registration = null;
}
+ public void setCrossContextLogout(boolean val)
+ {
+ crossContextLogout = val;
+ }
+
public void login(HttpServletRequest request, HttpServletResponse response,
Credentials credentials, long validityMillis) throws ServletException, IOException
{
login(request, response, credentials, validityMillis, null);
@@ -146,8 +154,10 @@
if (sess == null)
return;
+ if (!crossContextLogout)
+ return;
+
final String sessId = sess.getId();
-
DefaultServletContainerFactory.getInstance().getServletContainer().visit(new
ServletContainerVisitor()
{
public void accept(WebApp webApp)