org.jclouds.rest.internal
Class AsyncRestClientProxy<T>

java.lang.Object
  extended by org.jclouds.rest.internal.AsyncRestClientProxy<T>
All Implemented Interfaces:
InvocationHandler

@Singleton
public class AsyncRestClientProxy<T>
extends Object
implements InvocationHandler

Generates RESTful clients from appropriately annotated interfaces.

Particularly, this code delegates calls to other things.

  1. if the method has a Provides annotation, it responds via a Injector lookup
  2. if the method has a Delegate annotation, it responds with an instance of interface set in returnVal, adding the current JAXrs annotations to whatever are on that class.
  3. if RestAnnotationProcessor.delegationMap contains a mapping for this, and the returnVal is properly assigned as a ListenableFuture, it responds with an http implementation.
  4. otherwise a RuntimeException is thrown with a message including: method is intended solely to set constants

Author:
Adrian Cole

Nested Class Summary
static interface AsyncRestClientProxy.Factory
           
 
Field Summary
protected  Logger logger
           
protected  long requestTimeoutMilliseconds
          maximum duration of an unwrapped http Request
 
Constructor Summary
AsyncRestClientProxy(com.google.inject.Injector injector, AsyncRestClientProxy.Factory factory, RestAnnotationProcessor<T> util, com.google.inject.TypeLiteral<T> typeLiteral, com.google.common.cache.LoadingCache<ClassMethodArgs,Object> delegateMap)
           
 
Method Summary
 boolean equals(Object obj)
           
 int hashCode()
           
 Object invoke(Object o, Method method, Object[] args)
           
 boolean isRestCall(Method method)
           
 Object lookupValueFromGuice(Method method)
           
 Object propagateContextToDelegate(Method method, Object[] args)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

requestTimeoutMilliseconds

@Inject(optional=true)
@Named(value="jclouds.request-timeout")
protected long requestTimeoutMilliseconds
maximum duration of an unwrapped http Request


logger

protected Logger logger
Constructor Detail

AsyncRestClientProxy

@Inject
public AsyncRestClientProxy(com.google.inject.Injector injector,
                                   AsyncRestClientProxy.Factory factory,
                                   RestAnnotationProcessor<T> util,
                                   com.google.inject.TypeLiteral<T> typeLiteral,
                                   @Named(value="async")
                                   com.google.common.cache.LoadingCache<ClassMethodArgs,Object> delegateMap)
Method Detail

invoke

public Object invoke(Object o,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

isRestCall

public boolean isRestCall(Method method)

propagateContextToDelegate

public Object propagateContextToDelegate(Method method,
                                         Object[] args)
                                  throws ExecutionException
Throws:
ExecutionException

lookupValueFromGuice

public Object lookupValueFromGuice(Method method)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012 jclouds. All Rights Reserved.