asmuts 2004/04/20 18:00:43
Modified: src/java/org/apache/jcs/engine/behavior
IElementAttributes.java
src/java/org/apache/jcs/engine ElementAttributes.java
Log:
Mike Pettypiece's patch: makes sure the elementevent clones properly. Eventhandlers
should now be copied.
Revision Changes Path
1.6 +185 -189
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/behavior/IElementAttributes.java
Index: IElementAttributes.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/behavior/IElementAttributes.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- IElementAttributes.java 15 Apr 2004 19:22:53 -0000 1.5
+++ IElementAttributes.java 21 Apr 2004 01:00:43 -0000 1.6
@@ -1,6 +1,5 @@
package org.apache.jcs.engine.behavior;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -17,7 +16,6 @@
* limitations under the License.
*/
-
import java.util.ArrayList;
import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
@@ -29,193 +27,191 @@
public interface IElementAttributes
{
- /**
- * Sets the version attribute of the IAttributes object
- *
- [EMAIL PROTECTED] version The new version value
- */
- public void setVersion( long version );
-
-
- /**
- * Sets the maxLife attribute of the IAttributes object
- *
- [EMAIL PROTECTED] mls The new {3} value
- */
- public void setMaxLifeSeconds( long mls );
-
- /**
- * Sets the maxLife attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The {3} value
- */
- public long getMaxLifeSeconds();
-
-
- /**
- * Sets the idleTime attribute of the IAttributes object
- *
- [EMAIL PROTECTED] idle The new idleTime value
- */
- public void setIdleTime( long idle );
-
-
- //public void setListener( int event, CacheEventListener listerner) {}
-
- /**
- * Size in bytes.
- *
- [EMAIL PROTECTED] size The new size value
- */
- public void setSize( int size );
-
-
- /**
- * Gets the size attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The size value
- */
- public int getSize();
-
-
- /**
- * Gets the createTime attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The createTime value
- */
- public long getCreateTime();
-
-
- /**
- * Gets the LastAccess attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The LastAccess value
- */
- public long getLastAccessTime();
-
- /**
- * Sets the LastAccessTime as now of the IElementAttributes object
- */
- public void setLastAccessTimeNow();
-
-
- /**
- * Gets the version attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The version value
- */
- public long getVersion();
-
-
- /**
- * Gets the idleTime attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The idleTime value
- */
- public long getIdleTime();
-
-
- /**
- * Gets the time left to live of the IAttributes object
- *
- [EMAIL PROTECTED] The t value
- */
- public long getTimeToLiveSeconds();
-
- /**
- * Returns a copy of the object.
- *
- [EMAIL PROTECTED] IElementAttributes
- */
- public IElementAttributes copy();
-
-
- /**
- * Gets the {3} attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsDistribute();
-
- /**
- * Sets the isDistribute attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] val The new isDistribute value
- */
- public void setIsDistribute( boolean val );
- // lateral
-
- /**
- * can this item be flushed to disk
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsSpool();
-
- /**
- * Sets the isSpool attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] val The new isSpool value
- */
- public void setIsSpool( boolean val );
-
- /**
- * Is this item laterally distributable
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsLateral();
-
- /**
- * Sets the isLateral attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] val The new isLateral value
- */
- public void setIsLateral( boolean val );
-
- /**
- * Can this item be sent to the remote cache
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsRemote();
-
- /**
- * Sets the isRemote attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] val The new isRemote value
- */
- public void setIsRemote( boolean val );
-
- /**
- * can turn off expiration
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsEternal();
-
- /**
- * Sets the isEternal attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] val The new isEternal value
- */
- public void setIsEternal( boolean val );
-
-
- /**
- * Adds a ElementEventHandler. Handler's can be registered for multiple
- * events. A registered handler will be called at every recognized event.
- *
- [EMAIL PROTECTED] eventHandler The feature to be added to the
ElementEventHandler
- */
- public void addElementEventHandler( IElementEventHandler eventHandler );
-
- /**
- * Gets the elementEventHandlers.
- *
- [EMAIL PROTECTED] The elementEventHandlers value
- */
+ /**
+ * Sets the version attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] version The new version value
+ */
+ public void setVersion( long version );
+
+ /**
+ * Sets the maxLife attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] mls The new {3} value
+ */
+ public void setMaxLifeSeconds( long mls );
+
+ /**
+ * Sets the maxLife attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public long getMaxLifeSeconds();
+
+ /**
+ * Sets the idleTime attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] idle The new idleTime value
+ */
+ public void setIdleTime( long idle );
+
+ //public void setListener( int event, CacheEventListener listerner) {}
+
+ /**
+ * Size in bytes.
+ *
+ [EMAIL PROTECTED] size The new size value
+ */
+ public void setSize( int size );
+
+ /**
+ * Gets the size attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The size value
+ */
+ public int getSize();
+
+ /**
+ * Gets the createTime attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The createTime value
+ */
+ public long getCreateTime();
+
+ /**
+ * Gets the LastAccess attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The LastAccess value
+ */
+ public long getLastAccessTime();
+
+ /**
+ * Sets the LastAccessTime as now of the IElementAttributes object
+ */
+ public void setLastAccessTimeNow();
+
+ /**
+ * Gets the version attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The version value
+ */
+ public long getVersion();
+
+ /**
+ * Gets the idleTime attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The idleTime value
+ */
+ public long getIdleTime();
+
+ /**
+ * Gets the time left to live of the IAttributes object
+ *
+ [EMAIL PROTECTED] The t value
+ */
+ public long getTimeToLiveSeconds();
+
+ /**
+ * Returns a copy of the object.
+ *
+ [EMAIL PROTECTED] IElementAttributes
+ */
+ public IElementAttributes copy();
+
+ /**
+ * Gets the {3} attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsDistribute();
+
+ /**
+ * Sets the isDistribute attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isDistribute value
+ */
+ public void setIsDistribute( boolean val );
+
+ // lateral
+
+ /**
+ * can this item be flushed to disk
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsSpool();
+
+ /**
+ * Sets the isSpool attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isSpool value
+ */
+ public void setIsSpool( boolean val );
+
+ /**
+ * Is this item laterally distributable
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsLateral();
+
+ /**
+ * Sets the isLateral attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isLateral value
+ */
+ public void setIsLateral( boolean val );
+
+ /**
+ * Can this item be sent to the remote cache
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsRemote();
+
+ /**
+ * Sets the isRemote attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isRemote value
+ */
+ public void setIsRemote( boolean val );
+
+ /**
+ * can turn off expiration
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsEternal();
+
+ /**
+ * Sets the isEternal attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isEternal value
+ */
+ public void setIsEternal( boolean val );
+
+ /**
+ * Adds a ElementEventHandler. Handler's can be registered for multiple
+ * events. A registered handler will be called at every recognized event.
+ *
+ [EMAIL PROTECTED] eventHandler The feature to be added to the
ElementEventHandler
+ */
+ public void addElementEventHandler( IElementEventHandler eventHandler );
+
+ /**
+ * Gets the elementEventHandlers.
+ *
+ [EMAIL PROTECTED] The elementEventHandlers value
+ */
+
+
+ /**
+ * Sets the eventHandlers of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] eventHandlers value
+ */
+ public void addElementEventHandlers( ArrayList eventHandlers );
- public ArrayList getElementEventHandlers();
+ public ArrayList getElementEventHandlers();
}
1.6 +464 -460
jakarta-turbine-jcs/src/java/org/apache/jcs/engine/ElementAttributes.java
Index: ElementAttributes.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/ElementAttributes.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ElementAttributes.java 15 Apr 2004 19:22:49 -0000 1.5
+++ ElementAttributes.java 21 Apr 2004 01:00:43 -0000 1.6
@@ -1,6 +1,5 @@
package org.apache.jcs.engine;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -17,7 +16,6 @@
* limitations under the License.
*/
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -25,6 +23,7 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Iterator;
import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
@@ -35,477 +34,482 @@
*
[EMAIL PROTECTED] $Id: ILateralCacheTCPListener.java,v 1.2 2002/01/18 22:08:26
*/
-public class ElementAttributes implements IElementAttributes, Serializable,
Cloneable
+public class ElementAttributes
+ implements IElementAttributes, Serializable, Cloneable
{
- /**
- * Is this item distributable at all.
- */
- public boolean IS_DISTRIBUTE = false;
- // lateral
-
- /**
- * can this item be flushed to disk
- */
- public boolean IS_SPOOL = false;
-
- /**
- * Is this item laterally distributable
- */
- public boolean IS_LATERAL = false;
-
- /**
- * Can this item be sent to the remote cache
- */
- public boolean IS_REMOTE = false;
-
- /**
- * can turn off expiration
- */
- public boolean IS_ETERNAL = true;
-
- /**
- * Description of the Field
- */
- public long version = 0;
-
- /**
- * Max life seconds
- */
- public long mls = -1;
-
- /**
- * Description of the Field
- */
- public long idle = -1;
-
- /**
- * The byte size of teh field. Must be manually set.
- */
- public int size = 0;
-
- /**
- * The creation time
- */
- public long createTime = 0;
-
- /**
- * The last access time
- */
- public long lastAccessTime = 0;
-
- /**
- * The last access time
- */
- public ArrayList eventHandlers;
-
-
- /**
- * Constructor for the IElementAttributes object
- */
- public ElementAttributes()
- {
- this.createTime = System.currentTimeMillis();
- this.lastAccessTime = this.createTime;
- }
+ /**
+ * Is this item distributable at all.
+ */
+ public boolean IS_DISTRIBUTE = false;
+
+ // lateral
+
+ /**
+ * can this item be flushed to disk
+ */
+ public boolean IS_SPOOL = false;
+
+ /**
+ * Is this item laterally distributable
+ */
+ public boolean IS_LATERAL = false;
+
+ /**
+ * Can this item be sent to the remote cache
+ */
+ public boolean IS_REMOTE = false;
+
+ /**
+ * can turn off expiration
+ */
+ public boolean IS_ETERNAL = true;
+
+ /**
+ * Description of the Field
+ */
+ public long version = 0;
+
+ /**
+ * Max life seconds
+ */
+ public long mls = -1;
+
+ /**
+ * Description of the Field
+ */
+ public long idle = -1;
+
+ /**
+ * The byte size of teh field. Must be manually set.
+ */
+ public int size = 0;
+
+ /**
+ * The creation time
+ */
+ public long createTime = 0;
+
+ /**
+ * The last access time
+ */
+ public long lastAccessTime = 0;
+
+ /**
+ * The last access time
+ */
+ public ArrayList eventHandlers;
+
+ /**
+ * Constructor for the IElementAttributes object
+ */
+ public ElementAttributes()
+ {
+ this.createTime = System.currentTimeMillis();
+ this.lastAccessTime = this.createTime;
+ }
+
+ /**
+ * Constructor for the IElementAttributes object
+ *
+ [EMAIL PROTECTED] attr
+ */
+ private ElementAttributes( ElementAttributes attr )
+ {
+ IS_ETERNAL = attr.IS_ETERNAL;
- /**
- * Constructor for the IElementAttributes object
- *
- [EMAIL PROTECTED] attr
- */
- private ElementAttributes( ElementAttributes attr )
- {
-
- IS_ETERNAL = attr.IS_ETERNAL;
+ // waterfal onto disk, for pure disk set memory to 0
+ IS_SPOOL = attr.IS_SPOOL;
- // waterfal onto disk, for pure disk set memory to 0
- IS_SPOOL = attr.IS_SPOOL;
+ IS_DISTRIBUTE = attr.IS_DISTRIBUTE;
- IS_DISTRIBUTE = attr.IS_DISTRIBUTE;
-
- // lateral
- IS_LATERAL = attr.IS_LATERAL;
-
- // central rmi store
- IS_REMOTE = attr.IS_REMOTE;
-
- mls = attr.mls;
- // timetolive
- idle = attr.idle;
- size = attr.size;
-
- }
+ // lateral
+ IS_LATERAL = attr.IS_LATERAL;
+ // central rmi store
+ IS_REMOTE = attr.IS_REMOTE;
- /**
- * Description of the Method
- *
- [EMAIL PROTECTED]
- */
- public IElementAttributes copy()
+ mls = attr.mls;
+ // timetolive
+ idle = attr.idle;
+ size = attr.size;
+
+ }
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED]
+ */
+ public IElementAttributes copy()
+ {
+ try
{
- try
- {
// ElementAttributes attr = ( ElementAttributes ) this.clone();
// attr.createTime = System.currentTimeMillis();
// attr.setLastAccessTimeNow();
// return attr;
- // need to make this more efficient. Just want to insure
- // a proper copy
- ElementAttributes attr = new ElementAttributes();
- attr.setIdleTime( this.getIdleTime() );
- attr.setIsEternal( this.getIsEternal() );
- attr.setIsDistribute( this.getIsDistribute() );
- attr.setIsLateral( this.getIsLateral() );
- attr.setIsRemote( this.getIsRemote() );
- attr.setIsSpool( this.getIsSpool() );
- attr.setMaxLifeSeconds( this.getMaxLifeSeconds() );
- return attr;
- }
- catch ( Exception e )
- {
- return new ElementAttributes();
- }
- }
-
-
- /**
- * Description of the Method
- *
- [EMAIL PROTECTED]
- */
- public Object clone2()
- {
-
- try
- {
- ByteArrayOutputStream baos =
- new ByteArrayOutputStream( 100 );
- ObjectOutputStream oos = new
- ObjectOutputStream( baos );
- oos.writeObject( this );
- byte buf[] = baos.toByteArray();
- oos.close();
-
- // deserialize byte array into ArrayList
-
- ByteArrayInputStream bais =
- new ByteArrayInputStream( buf );
- ObjectInputStream ois = new
- ObjectInputStream( bais );
- ElementAttributes attr =
- ( ElementAttributes ) ois.readObject();
- ois.close();
-
- attr.createTime = System.currentTimeMillis();
- return attr;
- }
- catch ( Exception e )
- {
- }
- return null;
- }
-
- /**
- * Sets the version attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] version The new version value
- */
- public void setVersion( long version )
- {
- this.version = version;
- }
-
-
- /**
- * Sets the maxLifeSeconds attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] mls The new {3} value
- */
- public void setMaxLifeSeconds( long mls )
- {
- this.mls = mls;
- }
-
- /**
- * Gets the {3} attribute of the ElementAttributes object
- *
- [EMAIL PROTECTED] The {3} value
- */
- public long getMaxLifeSeconds()
- {
- return this.mls;
- }
-
-
- /**
- * Sets the idleTime attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] idle The new idleTime value
- */
- public void setIdleTime( long idle )
- {
- this.idle = idle;
- }
-
-
- //public void setListener( int event, CacheEventListener listerner) {}
-
- /**
- * Size in bytes.
- *
- [EMAIL PROTECTED] size The new size value
- */
- public void setSize( int size )
- {
- this.size = size;
- }
-
-
- /**
- * Gets the size attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] The size value
- */
- public int getSize()
- {
- return size;
- }
-
-
- /**
- * Gets the createTime attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] The createTime value
- */
- public long getCreateTime()
- {
- return createTime;
- }
-
-
- /**
- * Sets the createTime attribute of the IElementAttributes object
- */
- public void setCreateTime()
- {
- createTime = System.currentTimeMillis();
- }
-
-
- /**
- * Gets the version attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] The version value
- */
- public long getVersion()
- {
- return version;
- }
-
-
- /**
- * Gets the idleTime attribute of the IElementAttributes object. Keeping
- * track of this will require storing the last access time. This could get
- * expensive.
- *
- [EMAIL PROTECTED] The idleTime value
- */
- public long getIdleTime()
- {
- return this.idle;
- }
-
-
- /**
- * If the returned value is negative, the item has expired
- *
- [EMAIL PROTECTED] The timeToLive value
- */
- public long getTimeToLiveSeconds()
- {
- long now = System.currentTimeMillis();
- return ( this.getCreateTime() + ( this.getMaxLifeSeconds() * 1000 ) ) - now;
- }
-
-
- /**
- * Gets the LastAccess attribute of the IAttributes object
- *
- [EMAIL PROTECTED] The LastAccess value
- */
- public long getLastAccessTime()
- {
- return this.lastAccessTime;
- }
-
- /**
- * Sets the LastAccessTime as now of the IElementAttributes object
- */
- public void setLastAccessTimeNow()
- {
- this.lastAccessTime = System.currentTimeMillis();
- }
-
-
- /**
- * Gets the {3} attribute of the IElementAttributes object
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsDistribute()
- {
- return this.IS_DISTRIBUTE;
- }
-
- /**
- * Sets the isDistribute attribute of the ElementAttributes object
- *
- [EMAIL PROTECTED] val The new isDistribute value
- */
- public void setIsDistribute( boolean val )
- {
- this.IS_DISTRIBUTE = val;
- }
-
- /**
- * can this item be flushed to disk
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsSpool()
- {
- return this.IS_SPOOL;
- }
-
- /**
- * Sets the isSpool attribute of the ElementAttributes object
- *
- [EMAIL PROTECTED] val The new isSpool value
- */
- public void setIsSpool( boolean val )
- {
- this.IS_SPOOL = val;
- }
-
- /**
- * Is this item laterally distributable
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsLateral()
- {
- return this.IS_LATERAL;
- }
+ // need to make this more efficient. Just want to insure
+ // a proper copy
+ ElementAttributes attr = new ElementAttributes();
+ attr.setIdleTime( this.getIdleTime() );
+ attr.setIsEternal( this.getIsEternal() );
+ attr.setIsDistribute( this.getIsDistribute() );
+ attr.setIsLateral( this.getIsLateral() );
+ attr.setIsRemote( this.getIsRemote() );
+ attr.setIsSpool( this.getIsSpool() );
+ attr.setMaxLifeSeconds( this.getMaxLifeSeconds() );
+ attr.addElementEventHandlers( this.eventHandlers );
+ return attr;
+ }
+ catch ( Exception e )
+ {
+ return new ElementAttributes();
+ }
+ }
+
+ /**
+ * Description of the Method
+ *
+ [EMAIL PROTECTED]
+ */
+ public Object clone2()
+ {
+
+ try
+ {
+ ByteArrayOutputStream baos =
+ new ByteArrayOutputStream( 100 );
+ ObjectOutputStream oos = new
+ ObjectOutputStream( baos );
+ oos.writeObject( this );
+ byte buf[] = baos.toByteArray();
+ oos.close();
+
+ // deserialize byte array into ArrayList
+
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream( buf );
+ ObjectInputStream ois = new
+ ObjectInputStream( bais );
+ ElementAttributes attr =
+ ( ElementAttributes ) ois.readObject();
+ ois.close();
+
+ attr.createTime = System.currentTimeMillis();
+ return attr;
+ }
+ catch ( Exception e )
+ {
+ }
+ return null;
+ }
+
+ /**
+ * Sets the version attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] version The new version value
+ */
+ public void setVersion( long version )
+ {
+ this.version = version;
+ }
+
+ /**
+ * Sets the maxLifeSeconds attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] mls The new {3} value
+ */
+ public void setMaxLifeSeconds( long mls )
+ {
+ this.mls = mls;
+ }
+
+ /**
+ * Gets the {3} attribute of the ElementAttributes object
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public long getMaxLifeSeconds()
+ {
+ return this.mls;
+ }
+
+ /**
+ * Sets the idleTime attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] idle The new idleTime value
+ */
+ public void setIdleTime( long idle )
+ {
+ this.idle = idle;
+ }
+
+ //public void setListener( int event, CacheEventListener listerner) {}
+
+ /**
+ * Size in bytes.
+ *
+ [EMAIL PROTECTED] size The new size value
+ */
+ public void setSize( int size )
+ {
+ this.size = size;
+ }
+
+ /**
+ * Gets the size attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] The size value
+ */
+ public int getSize()
+ {
+ return size;
+ }
+
+ /**
+ * Gets the createTime attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] The createTime value
+ */
+ public long getCreateTime()
+ {
+ return createTime;
+ }
+
+ /**
+ * Sets the createTime attribute of the IElementAttributes object
+ */
+ public void setCreateTime()
+ {
+ createTime = System.currentTimeMillis();
+ }
+
+ /**
+ * Gets the version attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] The version value
+ */
+ public long getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * Gets the idleTime attribute of the IElementAttributes object. Keeping
+ * track of this will require storing the last access time. This could get
+ * expensive.
+ *
+ [EMAIL PROTECTED] The idleTime value
+ */
+ public long getIdleTime()
+ {
+ return this.idle;
+ }
+
+ /**
+ * If the returned value is negative, the item has expired
+ *
+ [EMAIL PROTECTED] The timeToLive value
+ */
+ public long getTimeToLiveSeconds()
+ {
+ long now = System.currentTimeMillis();
+ return ( this.getCreateTime() + ( this.getMaxLifeSeconds() * 1000 ) ) - now;
+ }
+
+ /**
+ * Gets the LastAccess attribute of the IAttributes object
+ *
+ [EMAIL PROTECTED] The LastAccess value
+ */
+ public long getLastAccessTime()
+ {
+ return this.lastAccessTime;
+ }
+
+ /**
+ * Sets the LastAccessTime as now of the IElementAttributes object
+ */
+ public void setLastAccessTimeNow()
+ {
+ this.lastAccessTime = System.currentTimeMillis();
+ }
+
+ /**
+ * Gets the {3} attribute of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsDistribute()
+ {
+ return this.IS_DISTRIBUTE;
+ }
+
+ /**
+ * Sets the isDistribute attribute of the ElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isDistribute value
+ */
+ public void setIsDistribute( boolean val )
+ {
+ this.IS_DISTRIBUTE = val;
+ }
+
+ /**
+ * can this item be flushed to disk
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsSpool()
+ {
+ return this.IS_SPOOL;
+ }
+
+ /**
+ * Sets the isSpool attribute of the ElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isSpool value
+ */
+ public void setIsSpool( boolean val )
+ {
+ this.IS_SPOOL = val;
+ }
+
+ /**
+ * Is this item laterally distributable
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsLateral()
+ {
+ return this.IS_LATERAL;
+ }
+
+ /**
+ * Sets the isLateral attribute of the ElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isLateral value
+ */
+ public void setIsLateral( boolean val )
+ {
+ this.IS_LATERAL = val;
+ }
+
+ /**
+ * Can this item be sent to the remote cache
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsRemote()
+ {
+ return this.IS_REMOTE;
+ }
+
+ /**
+ * Sets the isRemote attribute of the ElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isRemote value
+ */
+ public void setIsRemote( boolean val )
+ {
+ this.IS_REMOTE = val;
+ }
+
+ /**
+ * can turn off expiration
+ *
+ [EMAIL PROTECTED] The {3} value
+ */
+ public boolean getIsEternal()
+ {
+ return this.IS_ETERNAL;
+ }
+
+ /**
+ * Sets the isEternal attribute of the ElementAttributes object
+ *
+ [EMAIL PROTECTED] val The new isEternal value
+ */
+ public void setIsEternal( boolean val )
+ {
+ this.IS_ETERNAL = val;
+ }
+
+ /**
+ * Adds a ElementEventHandler. Handler's can be registered for multiple
+ * events. A registered handler will be called at every recognized event.
+ *
+ * The alternative would be to register handlers for each event. Or maybe
+ * The handler interface should ahve a method to return whether it cares
+ * about certain events.
+ *
+ [EMAIL PROTECTED] eventHandler The ElementEventHandler to be added to the list.
+ */
+ public void addElementEventHandler( IElementEventHandler eventHandler )
+ {
+ // lazy here, no concurrency problems expected
+ if ( this.eventHandlers == null )
+ {
+ this.eventHandlers = new ArrayList();
+ }
+ this.eventHandlers.add( eventHandler );
+ }
+
+ /**
+ * Sets the eventHandlers of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] eventHandlers value
+ */
+ public void addElementEventHandlers( ArrayList eventHandlers )
+ {
+ if ( eventHandlers == null )
+ {
+ return;
+ }
+
+ for ( Iterator iter = eventHandlers.iterator(); iter.hasNext(); )
+ {
+ addElementEventHandler( ( IElementEventHandler ) iter.next() );
+ }
+ }
+
+ /**
+ * Gets the elementEventHandlers. Returns null if none exist. Makes
+ * checking easy.
+ *
+ [EMAIL PROTECTED] The elementEventHandlers value
+ */
+
+ public ArrayList getElementEventHandlers()
+ {
+ return this.eventHandlers;
+ }
+
+ /**
+ * For logging and debugging the element IElementAttributes.
+ *
+ [EMAIL PROTECTED]
+ */
+ public String toString()
+ {
+ StringBuffer dump = new StringBuffer();
+
+ dump.append( "[ IS_LATERAL = " ).append( IS_LATERAL )
+ .append( ", IS_SPOOL = " ).append( IS_SPOOL )
+ .append( ", IS_REMOTE = " ).append( IS_REMOTE )
+ .append( ", IS_ETERNAL = " ).append( IS_ETERNAL )
+ .append( ", MaxLifeSeconds = " ).append( this.getMaxLifeSeconds() )
+ .append( ", IdleTime = " ).append( this.getIdleTime() )
+ .append( ", CreateTime = " ).append( this.getCreateTime() )
+ .append( ", LastAccessTime = " ).append( this.getLastAccessTime() )
+ .append( ", getTimeToLiveSeconds() = " ).append( String.valueOf(
+ getTimeToLiveSeconds() ) )
+ .append( ", createTime = " ).append( String.valueOf( createTime ) )
+ .append( " ]" );
- /**
- * Sets the isLateral attribute of the ElementAttributes object
- *
- [EMAIL PROTECTED] val The new isLateral value
- */
- public void setIsLateral( boolean val )
- {
- this.IS_LATERAL = val;
- }
-
- /**
- * Can this item be sent to the remote cache
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsRemote()
- {
- return this.IS_REMOTE;
- }
-
- /**
- * Sets the isRemote attribute of the ElementAttributes object
- *
- [EMAIL PROTECTED] val The new isRemote value
- */
- public void setIsRemote( boolean val )
- {
- this.IS_REMOTE = val;
- }
-
- /**
- * can turn off expiration
- *
- [EMAIL PROTECTED] The {3} value
- */
- public boolean getIsEternal()
- {
- return this.IS_ETERNAL;
- }
-
- /**
- * Sets the isEternal attribute of the ElementAttributes object
- *
- [EMAIL PROTECTED] val The new isEternal value
- */
- public void setIsEternal( boolean val )
- {
- this.IS_ETERNAL = val;
- }
-
-
- /**
- * Adds a ElementEventHandler. Handler's can be registered for multiple
- * events. A registered handler will be called at every recognized event.
- *
- * The alternative would be to register handlers for each event. Or maybe
- * The handler interface should ahve a method to return whether it cares
- * about certain events.
- *
- [EMAIL PROTECTED] eventHandler The ElementEventHandler to be added to the
list.
- */
- public void addElementEventHandler( IElementEventHandler eventHandler )
- {
- // lazy here, no concurrency problems expected
- if ( this.eventHandlers == null )
- {
- this.eventHandlers = new ArrayList();
- }
- this.eventHandlers.add( eventHandler );
- }
-
- /**
- * Gets the elementEventHandlers. Returns null if none exist. Makes
- * checking easy.
- *
- [EMAIL PROTECTED] The elementEventHandlers value
- */
-
- public ArrayList getElementEventHandlers()
- {
- return this.eventHandlers;
- }
-
-
- /**
- * For logging and debugging the element IElementAttributes.
- *
- [EMAIL PROTECTED]
- */
- public String toString()
- {
- StringBuffer dump = new StringBuffer();
-
- dump.append( "[ IS_LATERAL = " ).append( IS_LATERAL )
- .append( ", IS_SPOOL = " ).append( IS_SPOOL )
- .append( ", IS_REMOTE = " ).append( IS_REMOTE )
- .append( ", IS_ETERNAL = " ).append( IS_ETERNAL )
- .append( ", MaxLifeSeconds = " ).append( this.getMaxLifeSeconds() )
- .append( ", IdleTime = " ).append( this.getIdleTime() )
- .append( ", CreateTime = " ).append( this.getCreateTime() )
- .append( ", LastAccessTime = " ).append( this.getLastAccessTime() )
- .append( ", getTimeToLiveSeconds() = " ).append( String.valueOf(
getTimeToLiveSeconds() ) )
- .append( ", createTime = " ).append( String.valueOf( createTime ) )
- .append( " ]" );
-
- return dump.toString();
- }
+ return dump.toString();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]