org.apache.cocoon.components.flow
Class WebContinuation

java.lang.Object
  extended byorg.apache.cocoon.components.flow.WebContinuation
All Implemented Interfaces:
Comparable

public class WebContinuation
extends Object
implements Comparable

Representation of continuations in a Web environment.

Because a user may click on the back button of the browser and restart a saved computation in a continuation, each WebContinuation becomes the parent of a subtree of continuations.

If there is no parent WebContinuation, the created continuation becomes the root of a tree of WebContinuations.

Since:
March 19, 2002
Version:
$Id: WebContinuation.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
protected  List children
          The children continuations.
protected  Object continuation
          The continuation this object represents.
protected  ContinuationsDisposer disposer
          Holds the ContinuationsDisposer to call when this continuation gets invalidated.
protected  String id
          The continuation id used to represent this instance in Web pages.
protected  String interpreterId
          Interpreter id that this continuation is bound to
protected  long lastAccessTime
          When was this continuation accessed last time.
protected  WebContinuation parentContinuation
          The parent WebContinuation from which processing last started.
protected  int timeToLive
          Indicates how long does this continuation will live (in seconds).
protected  Object userObject
          A user definable object.
 
Method Summary
 int compareTo(Object other)
          Compares the expiration time of this instance with that of the WebContinuation passed as argument.
 void detachFromParent()
           
 void display()
          Debugging method.
protected  String display(int depth)
          Debugging method.
 void dispose()
          Dispose this continuation.
 boolean disposed()
          Return true if this continuation was disposed of
 boolean equals(Object another)
          True if the identifiers are the same, false otherwise.
 Object getAttribute(String name)
          Get an attribute of this continuation
 Enumeration getAttributeNames()
          Enumerate the attributes of this continuation.
 List getChildren()
          Return the children WebContinuation which were created as a result of resuming the processing from the current continuation.
 Object getContinuation()
          Return the continuation object.
 WebContinuation getContinuation(int level)
          Return the ancestor continuation situated levels above the current continuation.
 String getId()
          Returns the string identifier of this WebContinuation.
 String getInterpreterId()
          Returns the string identifier of the interpreter to which this WebContinuation is bound.
 long getLastAccessTime()
          Returns the last time this WebContinuation was accessed.
 Log getLogger()
           
 WebContinuation getParentContinuation()
          Return the parent WebContinuation.
 long getTimeToLive()
          Returns the the timetolive for this WebContinuation.
 Object getUserObject()
          Obtains the user object associated with this instance.
 boolean hasExpired()
          Determines whether this continuation has expired
 int hashCode()
          Returns the hash code of the associated identifier.
 boolean interpreterMatches(String interpreterId)
           
 void removeAttribute(String name)
          Remove an attribute of this continuation
 void setAttribute(String name, Object value)
          Set an attribute of this continuation
 void setLogger(Log logger)
           
 void setUserObject(Object obj)
          Sets the user object associated with this instance.
protected  void updateLastAccessTime()
          Update the continuation in the
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

continuation

protected Object continuation
The continuation this object represents.


parentContinuation

protected WebContinuation parentContinuation
The parent WebContinuation from which processing last started. If null, there is no parent continuation associated, and this is the first one to be created in a processing. In this case this WebContinuation instance becomes the root of the tree maintained by the ContinuationsManager.

See Also:
ContinuationsManager

children

protected List children
The children continuations. These are continuations created by resuming the processing from the point stored by continuation.


id

protected String id
The continuation id used to represent this instance in Web pages.


interpreterId

protected String interpreterId
Interpreter id that this continuation is bound to


userObject

protected Object userObject
A user definable object. This is present for convenience, to store any information associated with this WebContinuation a particular implementation might need.


lastAccessTime

protected long lastAccessTime
When was this continuation accessed last time. Each time the continuation is accessed, this time is set to the time of the access.


timeToLive

protected int timeToLive
Indicates how long does this continuation will live (in seconds). The continuation will be removed once the current time is bigger than lastAccessTime + timeToLive.


disposer

protected ContinuationsDisposer disposer
Holds the ContinuationsDisposer to call when this continuation gets invalidated.

Method Detail

getLogger

public final Log getLogger()

setLogger

public void setLogger(Log logger)

getAttribute

public Object getAttribute(String name)
Get an attribute of this continuation

Parameters:
name - the attribute name.

setAttribute

public void setAttribute(String name,
                         Object value)
Set an attribute of this continuation

Parameters:
name - the attribute name
value - its value

removeAttribute

public void removeAttribute(String name)
Remove an attribute of this continuation

Parameters:
name - the attribute name

getAttributeNames

public Enumeration getAttributeNames()
Enumerate the attributes of this continuation.

Returns:
an enumeration of strings

getContinuation

public Object getContinuation()
Return the continuation object.

Returns:
an Object value

getContinuation

public WebContinuation getContinuation(int level)
Return the ancestor continuation situated levels above the current continuation. The current instance is considered to be at level 0. The parent continuation of the receiving instance at level 1, its parent is at level 2 relative to the receiving instance. If level is bigger than the depth of the tree, the root of the tree is returned.

Parameters:
level - an int value
Returns:
a WebContinuation value

getParentContinuation

public WebContinuation getParentContinuation()
Return the parent WebContinuation. Equivalent with getContinuation(1).

Returns:
a WebContinuation value

getChildren

public List getChildren()
Return the children WebContinuation which were created as a result of resuming the processing from the current continuation.

Returns:
a List value

getId

public String getId()
Returns the string identifier of this WebContinuation.

Returns:
a String value

getInterpreterId

public String getInterpreterId()
Returns the string identifier of the interpreter to which this WebContinuation is bound.

Returns:
a String value

getLastAccessTime

public long getLastAccessTime()
Returns the last time this WebContinuation was accessed.

Returns:
a long value

getTimeToLive

public long getTimeToLive()
Returns the the timetolive for this WebContinuation.

Returns:
a long value

setUserObject

public void setUserObject(Object obj)
Sets the user object associated with this instance.

Parameters:
obj - an Object value

getUserObject

public Object getUserObject()
Obtains the user object associated with this instance.

Returns:
an Object value

hashCode

public int hashCode()
Returns the hash code of the associated identifier.

Returns:
an int value

equals

public boolean equals(Object another)
True if the identifiers are the same, false otherwise.

Parameters:
another - an Object value
Returns:
a boolean value

compareTo

public int compareTo(Object other)
Compares the expiration time of this instance with that of the WebContinuation passed as argument.

Note: this class has a natural ordering that is inconsistent with equals.

.

Specified by:
compareTo in interface Comparable
Parameters:
other - an Object value, which should be a WebContinuation instance
Returns:
an int value

display

public void display()
Debugging method.

Assumes the receiving instance as the root of a tree and displays the tree of continuations.


display

protected String display(int depth)
Debugging method.

Displays the receiving instance as if it is at the indent depth in the tree of continuations. Each level is indented 2 spaces.

Parameters:
depth - an int value

updateLastAccessTime

protected void updateLastAccessTime()
Update the continuation in the


hasExpired

public boolean hasExpired()
Determines whether this continuation has expired

Returns:
a boolean value

dispose

public void dispose()
Dispose this continuation. Should be called on invalidation.


disposed

public boolean disposed()
Return true if this continuation was disposed of


interpreterMatches

public boolean interpreterMatches(String interpreterId)

detachFromParent

public void detachFromParent()


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.