You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2002/04/01 21:07:06 UTC
cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/pipeline DefaultSessionTimeoutValve.java
jmcnally 02/04/01 11:07:06
Modified: src/java/org/apache/turbine/pipeline
DefaultSessionTimeoutValve.java
Log:
was treating -1 as a marker to not set the session timeout.
-1 is a valid value, however. This was not a major problem as
any negative works the same as -1, but -1 is probably the most
likely negative value choice.
Now if any integer value is given the value will be set.
Revision Changes Path
1.5 +14 -17 jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultSessionTimeoutValve.java
Index: DefaultSessionTimeoutValve.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultSessionTimeoutValve.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultSessionTimeoutValve.java 6 Feb 2002 17:26:34 -0000 1.4
+++ DefaultSessionTimeoutValve.java 1 Apr 2002 19:07:06 -0000 1.5
@@ -72,7 +72,7 @@
*
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
* @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
- * @version $Id: DefaultSessionTimeoutValve.java,v 1.4 2002/02/06 17:26:34 mpoeschl Exp $
+ * @version $Id: DefaultSessionTimeoutValve.java,v 1.5 2002/04/01 19:07:06 jmcnally Exp $
*/
public class DefaultSessionTimeoutValve
extends AbstractValve
@@ -81,16 +81,11 @@
private static final Category log =
Category.getInstance(DefaultSessionTimeoutValve.class);
- /**
- * The default session timeout.
- */
- protected static final int DEFAULT_TIMEOUT = -1;
- protected int timeout = DEFAULT_TIMEOUT;
+ protected Integer timeout = null;
/**
* Here we can setup objects that are thread safe and can be
- * reused. We setup the session validator and the access
- * controller.
+ * reused, so we get the timeout from the configuration..
*/
public DefaultSessionTimeoutValve()
throws Exception
@@ -98,8 +93,13 @@
Configuration cfg = Turbine.getConfiguration();
if (cfg != null)
{
- // Get the session timeout.
- timeout = cfg.getInt(SESSION_TIMEOUT, DEFAULT_TIMEOUT);
+ // Get the session timeout. Use String so we know whether
+ // the timeout was specified or not.
+ String timeoutString = cfg.getString(SESSION_TIMEOUT);
+ if (timeoutString != null && timeoutString.length() > 0)
+ {
+ timeout = new Integer(timeoutString);
+ }
}
}
@@ -109,14 +109,11 @@
public void invoke(RunData data, ValveContext context)
throws IOException, TurbineException
{
- if (data.getSession().isNew())
+ // If the session is new take this opportunity to
+ // set the session timeout if specified in TR.properties
+ if (data.getSession().isNew() && timeout != null)
{
- // as the session is new take this opportunity to
- // set the session timeout if specified in TR.properties
- if (timeout != -1)
- {
- data.getSession().setMaxInactiveInterval(timeout);
- }
+ data.getSession().setMaxInactiveInterval(timeout.intValue());
}
// Pass control to the next Valve in the Pipeline
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>