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