1 package hudson.remoting; 2 3 import java.util.concurrent.ExecutionException ; 4 import java.util.concurrent.TimeUnit ; 5 import java.util.concurrent.TimeoutException ; 6 7 12 abstract class FutureAdapter<X,Y> implements Future<X> { 13 protected final Future<Y> core; 14 15 protected FutureAdapter(Future<Y> core) { 16 this.core = core; 17 } 18 19 public boolean cancel(boolean mayInterruptIfRunning) { 20 return core.cancel(mayInterruptIfRunning); 21 } 22 23 public boolean isCancelled() { 24 return core.isCancelled(); 25 } 26 27 public boolean isDone() { 28 return core.isDone(); 29 } 30 31 public X get() throws InterruptedException , ExecutionException { 32 return adapt(core.get()); 33 } 34 35 public X get(long timeout, TimeUnit unit) throws InterruptedException , ExecutionException , TimeoutException { 36 return adapt(core.get(timeout, unit)); 37 } 38 39 protected abstract X adapt(Y y) throws ExecutionException ; 40 } 41 | Popular Tags |