org.compass.core.executor.commonj
Class WorkCallableFutureAdapter<T>

java.lang.Object
  extended by org.compass.core.executor.commonj.WorkCallableFutureAdapter<T>
All Implemented Interfaces:
commonj.work.Work, Runnable, Future<T>

public class WorkCallableFutureAdapter<T>
extends Object
implements commonj.work.Work, Future<T>

An adapter from commonj work to a j.u.c Future. Will be executed by commonj as work, but can be returned as a Future with all its operations except for cancel.

Author:
kimchy

Constructor Summary
WorkCallableFutureAdapter(Callable<T> callable)
           
WorkCallableFutureAdapter(Runnable runnable)
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
 T get()
           
 T get(long timeout, TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDaemon()
           
 boolean isDone()
           
 void release()
           
 void run()
           
(package private)  void setException(Exception e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkCallableFutureAdapter

public WorkCallableFutureAdapter(Callable<T> callable)

WorkCallableFutureAdapter

public WorkCallableFutureAdapter(Runnable runnable)
Method Detail

isDaemon

public boolean isDaemon()
Specified by:
isDaemon in interface commonj.work.Work

run

public void run()
Specified by:
run in interface Runnable

release

public void release()
Specified by:
release in interface commonj.work.Work

setException

void setException(Exception e)

get

public T get()
      throws InterruptedException,
             ExecutionException
Specified by:
get in interface Future<T>
Throws:
InterruptedException
ExecutionException

get

public T get(long timeout,
             TimeUnit unit)
      throws InterruptedException,
             ExecutionException,
             TimeoutException
Specified by:
get in interface Future<T>
Throws:
InterruptedException
ExecutionException
TimeoutException

isDone

public boolean isDone()
Specified by:
isDone in interface Future<T>

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface Future<T>

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface Future<T>


Copyright (c) 2004-2009 The Compass Project.