Hello All,
I was attempting to create an implementation of IElementEventHandler and
I noticed that events are currently not being sent properly. I tracked
down the problem to the copy() method of ElementAttributes where the
event handlers are not being copied.
Here is a patch which should fix the problem. Would someone with CVS
commit privileges please look this over?
Cheers,
Mike
Index: src/java/org/apache/jcs/engine/ElementAttributes.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/Eleme
ntAttributes.java,v
retrieving revision 1.5
diff -u -r1.5 ElementAttributes.java
--- src/java/org/apache/jcs/engine/ElementAttributes.java 15 Apr 2004
19:22:49 -0000 1.5
+++ src/java/org/apache/jcs/engine/ElementAttributes.java 20 Apr 2004
20:32:02 -0000
@@ -23,12 +23,11 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
-
import java.util.ArrayList;
-
-import
org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
+import java.util.Iterator;
import org.apache.jcs.engine.behavior.IElementAttributes;
+import
org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
/**
* Element attribute descriptor class.
@@ -163,6 +162,7 @@
attr.setIsRemote( this.getIsRemote() );
attr.setIsSpool( this.getIsSpool() );
attr.setMaxLifeSeconds( this.getMaxLifeSeconds() );
+ attr.addElementEventHandlers( this.eventHandlers );
return attr;
}
catch ( Exception e )
@@ -230,6 +230,7 @@
this.mls = mls;
}
+
/**
* Gets the {3} attribute of the ElementAttributes object
*
@@ -473,6 +474,26 @@
}
/**
+ * Sets the eventHandlers of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> eventHandlers The new {3} 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.
*
@@ -483,8 +504,7 @@
{
return this.eventHandlers;
}
-
-
+
/**
* For logging and debugging the element IElementAttributes.
*
Index: src/java/org/apache/jcs/engine/behavior/IElementAttributes.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/behav
ior/IElementAttributes.java,v
retrieving revision 1.5
diff -u -r1.5 IElementAttributes.java
--- src/java/org/apache/jcs/engine/behavior/IElementAttributes.java 15
Apr 2004 19:22:53 -0000 1.5
+++ src/java/org/apache/jcs/engine/behavior/IElementAttributes.java 20
Apr 2004 20:32:02 -0000
@@ -209,6 +209,13 @@
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> eventHandler The feature to be
added
to the ElementEventHandler
*/
public void addElementEventHandler( IElementEventHandler
eventHandler );
+
+ /**
+ * Sets the eventHandlers of the IElementAttributes object
+ *
+ [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> eventHandlers The new {3} value
+ */
+ public void addElementEventHandlers( ArrayList eventHandlers );
/**
* Gets the elementEventHandlers.