1 22 package org.jboss.aspects.asynch; 23 24 import EDU.oswego.cs.dl.util.concurrent.FutureResult; 25 import org.jboss.aop.Dispatcher; 26 import org.jboss.util.id.GUID; 27 28 import java.lang.reflect.InvocationTargetException ; 29 30 36 public class FutureImpl 37 implements RemotableFuture 38 { 39 private FutureResult result; 40 private GUID remoteObjectID; 41 42 public FutureImpl(FutureResult result) 43 { 44 this.result = result; 45 } 46 47 public void setRemoteObjectID(GUID remoteObjectID) 48 { 49 this.remoteObjectID = remoteObjectID; 50 } 51 52 public void release() 53 { 54 if (remoteObjectID != null) 55 { 56 Dispatcher.singleton.unregisterTarget(remoteObjectID); 57 } 58 } 59 60 public Object get() throws InterruptedException , InvocationTargetException 61 { 62 try 63 { 64 Object rtn = result.get(); 65 release(); 66 return rtn; 67 } 68 catch (InvocationTargetException e) 69 { 70 release(); 71 throw e; 72 } 73 } 74 75 public Object get(long milliseconds) throws TimeoutException, InterruptedException , InvocationTargetException 76 { 77 try 78 { 79 Object rtn = result.timedGet(milliseconds); 80 release(); 81 return rtn; 82 } 83 catch (EDU.oswego.cs.dl.util.concurrent.TimeoutException e) 84 { 85 throw new TimeoutException(e); 86 } 87 catch (InvocationTargetException e) 88 { 89 release(); 90 throw e; 91 } 92 } 93 94 public boolean isDone() 95 { 96 return result.isReady(); 97 } 98 99 } 100 | Popular Tags |