org.jclouds.http
Class TransformingHttpCommandImpl<T>

java.lang.Object
  extended by org.jclouds.http.TransformingHttpCommandImpl<T>
All Implemented Interfaces:
HttpCommand, TransformingHttpCommand<T>

public class TransformingHttpCommandImpl<T>
extends Object
implements TransformingHttpCommand<T>

Executor which will invoke and transform the response of an EndpointCommand into generic type .

Author:
Adrian Cole
See Also:
TransformingHttpCommand

Field Summary
protected  Exception exception
           
protected  TransformingHttpCommandExecutorService executorService
           
protected  int failureCount
           
protected  Logger logger
           
protected  int redirectCount
           
protected  HttpRequest request
           
protected  com.google.common.base.Function<HttpResponse,T> transformer
           
 
Constructor Summary
TransformingHttpCommandImpl(TransformingHttpCommandExecutorService executorService, HttpRequest request, com.google.common.base.Function<HttpResponse,T> transformer)
           
 
Method Summary
 boolean equals(Object that)
           
 com.google.common.util.concurrent.ListenableFuture<T> execute()
          invoke and transform the response <R> into value type <T>
 HttpRequest getCurrentRequest()
          The request associated with this command.
 Exception getException()
          
 int getFailureCount()
          This displays the current number of error retries for this command.
 int getRedirectCount()
          This displays the current number of redirect attempts for this command.
 int hashCode()
           
 int incrementFailureCount()
          increment the current failure count.
 int incrementRedirectCount()
          increments the current number of redirect attempts for this command.
 boolean isReplayable()
          Commands need to be replayed, if redirected or on a retryable error.
 void setCurrentRequest(HttpRequest request)
          The request associated with this command.
 void setException(Exception exception)
          Used to prevent a command from being re-executed, or having its response parsed.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

executorService

protected final TransformingHttpCommandExecutorService executorService

transformer

protected final com.google.common.base.Function<HttpResponse,T> transformer

request

protected volatile HttpRequest request

failureCount

protected volatile int failureCount

redirectCount

protected volatile int redirectCount

exception

protected volatile Exception exception

logger

protected Logger logger
Constructor Detail

TransformingHttpCommandImpl

@Inject
public TransformingHttpCommandImpl(TransformingHttpCommandExecutorService executorService,
                                          HttpRequest request,
                                          com.google.common.base.Function<HttpResponse,T> transformer)
Method Detail

execute

public com.google.common.util.concurrent.ListenableFuture<T> execute()
                                                              throws ExecutionException
invoke and transform the response <R> into value type <T>

Specified by:
execute in interface TransformingHttpCommand<T>
Returns:
future containing the expected value
Throws:
ExecutionException - if there is a fatal error preventing the command from invoking

getFailureCount

public int getFailureCount()
This displays the current number of error retries for this command.

Specified by:
getFailureCount in interface HttpCommand
See Also:
org.jclouds.Constants.PROPERTY_MAX_RETRIES

incrementFailureCount

public int incrementFailureCount()
increment the current failure count.

Specified by:
incrementFailureCount in interface HttpCommand
See Also:
HttpCommand.getFailureCount()

setException

public void setException(Exception exception)
Used to prevent a command from being re-executed, or having its response parsed.

Specified by:
setException in interface HttpCommand

getException

public Exception getException()

Specified by:
getException in interface HttpCommand
See Also:
HttpCommand.setException(java.lang.Exception)

incrementRedirectCount

public int incrementRedirectCount()
increments the current number of redirect attempts for this command.

Specified by:
incrementRedirectCount in interface HttpCommand
See Also:
HttpCommand.getRedirectCount()

getRedirectCount

public int getRedirectCount()
This displays the current number of redirect attempts for this command.

Specified by:
getRedirectCount in interface HttpCommand
See Also:
org.jclouds.Constants.PROPERTY_MAX_REDIRECTS

isReplayable

public boolean isReplayable()
Commands need to be replayed, if redirected or on a retryable error. Typically, this implies the payload carried is not a streaming type.

Specified by:
isReplayable in interface HttpCommand

getCurrentRequest

public HttpRequest getCurrentRequest()
The request associated with this command.

Specified by:
getCurrentRequest in interface HttpCommand

setCurrentRequest

public void setCurrentRequest(HttpRequest request)
The request associated with this command.

Specified by:
setCurrentRequest in interface HttpCommand

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object that)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012 jclouds. All Rights Reserved.