1 22 package org.jboss.test.txtimer.test; 23 24 import java.util.HashMap ; 25 26 import javax.ejb.NoSuchObjectLocalException ; 27 import javax.ejb.TimedObject ; 28 import javax.ejb.Timer ; 29 30 import org.jboss.ejb.txtimer.TimedObjectId; 31 import org.jboss.ejb.txtimer.TimedObjectInvoker; 32 import org.jboss.mx.util.ObjectNameFactory; 33 34 40 public class SimpleTimedObjectInvoker implements TimedObjectInvoker 41 { 42 private TimedObjectId timedObjectId; 43 private HashMap objectMap = new HashMap (); 44 45 50 public void callTimeout(Timer timer) 51 { 52 TimedObject timedObject = (TimedObject )objectMap.get(timedObjectId); 53 if (timedObject == null) 54 throw new NoSuchObjectLocalException ("Cannot find TimedObject: " + timedObjectId); 55 timedObject.ejbTimeout(timer); 56 } 57 58 public TimedObjectId addTimedObject(TimedObject timedObject) 59 { 60 timedObjectId = new TimedObjectId(ObjectNameFactory.create("txtimer:timedObject=" + timedObject.hashCode())); 61 objectMap.put(timedObjectId, timedObject); 62 return timedObjectId; 63 } 64 } 65 | Popular Tags |