djencks 2005/02/02 11:28:18
Modified: modules/core/src/java/org/openejb/entity/bmp
BMPRemoveMethod.java
Log:
GERONIMO-565. Removing an entity bean should cancel its timers
Revision Changes Path
1.3 +14 -2
openejb/modules/core/src/java/org/openejb/entity/bmp/BMPRemoveMethod.java
Index: BMPRemoveMethod.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/bmp/BMPRemoveMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BMPRemoveMethod.java 21 Mar 2004 21:26:35 -0000 1.2
+++ BMPRemoveMethod.java 2 Feb 2005 16:28:18 -0000 1.3
@@ -47,6 +47,11 @@
*/
package org.openejb.entity.bmp;
+import java.util.Collection;
+import java.util.Iterator;
+import javax.ejb.TimerService;
+import javax.ejb.Timer;
+
import org.apache.geronimo.core.service.InvocationResult;
import org.openejb.EJBInvocation;
@@ -68,8 +73,15 @@
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
InvocationResult result = invoke(invocation, EJBOperation.EJBREMOVE);
if (result.isNormal()) {
- // clear id as we are no longer associated
EntityInstanceContext ctx = (EntityInstanceContext)
invocation.getEJBInstanceContext();
+ //cancel timers
+ TimerService timerService = ctx.getTimerService();
+ Collection timers = timerService.getTimers();
+ for (Iterator iterator = timers.iterator(); iterator.hasNext();)
{
+ Timer timer = (Timer) iterator.next();
+ timer.cancel();
+ }
+ // clear id as we are no longer associated
ctx.setId(null);
}
return result;