From 7388293178eb4781831429dd41a03bb0df45fd0e Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Tue, 16 Jun 2009 22:07:23 +0000 Subject: [PATCH] Issue 9: updated javadoc git-svn-id: http://jclouds.googlecode.com/svn/trunk@1433 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../org/jclouds/command/FutureCommand.java | 168 +++++++++--------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/core/src/main/java/org/jclouds/command/FutureCommand.java b/core/src/main/java/org/jclouds/command/FutureCommand.java index 9d265c321f..7f28a88121 100644 --- a/core/src/main/java/org/jclouds/command/FutureCommand.java +++ b/core/src/main/java/org/jclouds/command/FutureCommand.java @@ -27,116 +27,116 @@ import java.util.concurrent.*; import static com.google.common.base.Preconditions.checkNotNull; /** - * // TODO: Adrian: Document this! + * Command that returns an asynchronous result. Generic type parameters associate the request ( + * {@code Q}) with the response ({#code R}). When the response is parsed, it will return value ( + * {@code T}). * * @author Adrian Cole */ public class FutureCommand implements Future { - private final Q request; - private final ResponseRunnableFuture responseRunnableFuture; - private volatile int failureCount; + private final Q request; + private final ResponseRunnableFuture responseRunnableFuture; + private volatile int failureCount; - public int incrementFailureCount() { - return ++failureCount; - } + public int incrementFailureCount() { + return ++failureCount; + } - public int getFailureCount() { - return failureCount; - } + public int getFailureCount() { + return failureCount; + } - public FutureCommand(Q request, ResponseCallable responseCallable) { - this.request = checkNotNull(request, "request"); - this.responseRunnableFuture = new ResponseRunnableFutureTask( - checkNotNull(responseCallable, "responseCallable")); - } + public FutureCommand(Q request, ResponseCallable responseCallable) { + this.request = checkNotNull(request, "request"); + this.responseRunnableFuture = new ResponseRunnableFutureTask(checkNotNull( + responseCallable, "responseCallable")); + } - public Q getRequest() { - return request; - } + public Q getRequest() { + return request; + } - public ResponseRunnableFuture getResponseFuture() { - return responseRunnableFuture; - } + public ResponseRunnableFuture getResponseFuture() { + return responseRunnableFuture; + } - public void setException(Exception e) { - responseRunnableFuture.setException(e); - } + public void setException(Exception e) { + responseRunnableFuture.setException(e); + } - public boolean cancel(boolean b) { - return responseRunnableFuture.cancel(b); - } + public boolean cancel(boolean b) { + return responseRunnableFuture.cancel(b); + } - public boolean isCancelled() { - return responseRunnableFuture.isCancelled(); - } + public boolean isCancelled() { + return responseRunnableFuture.isCancelled(); + } - public boolean isDone() { - return responseRunnableFuture.isDone(); - } + public boolean isDone() { + return responseRunnableFuture.isDone(); + } - public T get() throws InterruptedException, ExecutionException { - return responseRunnableFuture.get(); - } + public T get() throws InterruptedException, ExecutionException { + return responseRunnableFuture.get(); + } - public T get(long l, TimeUnit timeUnit) throws InterruptedException, - ExecutionException, TimeoutException { - return responseRunnableFuture.get(l, timeUnit); - } + public T get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, + TimeoutException { + return responseRunnableFuture.get(l, timeUnit); + } - /** - * // TODO: Adrian: Document this! - * - * @author Adrian Cole - */ - public static class ResponseRunnableFutureTask extends FutureTask - implements ResponseRunnableFuture { - private final ResponseCallable callable; + /** + * // TODO: Adrian: Document this! + * + * @author Adrian Cole + */ + public static class ResponseRunnableFutureTask extends FutureTask implements + ResponseRunnableFuture { + private final ResponseCallable callable; - public ResponseRunnableFutureTask(ResponseCallable tCallable) { - super(tCallable); - this.callable = tCallable; - } + public ResponseRunnableFutureTask(ResponseCallable tCallable) { + super(tCallable); + this.callable = tCallable; + } - @Override - public String toString() { - return getClass().getSimpleName() + "{" + "tCallable=" + callable - + '}'; - } + @Override + public String toString() { + return getClass().getSimpleName() + "{" + "tCallable=" + callable + '}'; + } - public R getResponse() { - return callable.getResponse(); - } + public R getResponse() { + return callable.getResponse(); + } - public void setResponse(R response) { - callable.setResponse(response); - } + public void setResponse(R response) { + callable.setResponse(response); + } - /** - * opening this to public so that other errors can be associated with - * the request, for example i/o errors. - * - * @param throwable - */ - @Override - public void setException(Throwable throwable) { - super.setException(throwable); - } + /** + * opening this to public so that other errors can be associated with the request, for example + * i/o errors. + * + * @param throwable + */ + @Override + public void setException(Throwable throwable) { + super.setException(throwable); + } - } + } - public interface ResponseRunnableFuture extends Response, - Runnable, Future { - public void setException(Throwable throwable); - } + public interface ResponseRunnableFuture extends Response, Runnable, Future { + public void setException(Throwable throwable); + } - public interface ResponseCallable extends Response, Callable { - } + public interface ResponseCallable extends Response, Callable { + } - public interface Response { - public R getResponse(); + public interface Response { + public R getResponse(); - public void setResponse(R response); - } + public void setResponse(R response); + } }