ovidiu 2003/01/08 21:40:24
Modified: src/java/org/apache/cocoon/components/flow
WebContinuation.java
Log:
Added support for expiring continuations.
Revision Changes Path
1.6 +36 -3
xml-cocoon2/src/java/org/apache/cocoon/components/flow/WebContinuation.java
Index: WebContinuation.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/WebContinuation.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebContinuation.java 6 Dec 2002 18:20:15 -0000 1.5
+++ WebContinuation.java 9 Jan 2003 05:40:24 -0000 1.6
@@ -51,6 +51,8 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+
/**
* Representation of continuations in a Web environment.
*
@@ -225,6 +227,17 @@
}
/**
+ * Returns the the timetolive for this
+ * <code>WebContinuation</code>.
+ *
+ * @return a <code>long</code> value
+ */
+ public long getTimeToLive()
+ {
+ return this.timeToLive;
+ }
+
+ /**
* Sets the user object associated with this instance.
*
* @param obj an <code>Object</code> value
@@ -314,15 +327,23 @@
tree.append("WK: WebContinuation ")
.append(id)
- .append(" Last Touched [")
- .append(lastAccessTime)
- .append("]");
+ .append(" ExpireTime [");
+
+ if ((lastAccessTime + timeToLive) < System.currentTimeMillis()) {
+ tree.append("Expired");
+ }
+ else {
+ tree.append(lastAccessTime + timeToLive);
+ }
+
+ tree.append("]");
//REVISIT: is this needed for some reason?
//System.out.print(spaces); System.out.println("WebContinuation " + id);
int size = children.size();
depth++;
+
for (int i = 0; i < size; i++) {
tree.append(((WebContinuation)children.get(i)).display(depth));
}
@@ -336,5 +357,17 @@
protected void updateLastAccessTime()
{
lastAccessTime = new Date().getTime();
+ }
+
+ /**
+ * Determines whether this continuation has expired
+ *
+ * @return a <code>boolean</code> value
+ */
+ public boolean hasExpired() {
+ long currentTime = System.currentTimeMillis();
+ long expireTime = this.getLastAccessTime() + this.timeToLive;
+
+ return (currentTime > expireTime);
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]