org.jclouds.rest.internal
Class AsyncRestClientProxy<T>
java.lang.Object
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.
- if the method has a
Provides
annotation, it responds via a Injector
lookup
- 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.
- ex. if the method with
Delegate
has a Path
annotation, and the returnval
interface also has Path
, these values are combined.
- if
RestAnnotationProcessor.delegationMap
contains a mapping for this, and the
returnVal is properly assigned as a ListenableFuture
, it responds with an http
implementation.
- otherwise a RuntimeException is thrown with a message including:
method is intended
solely to set constants
- Author:
- Adrian Cole
requestTimeoutMilliseconds
@Inject(optional=true)
@Named(value="jclouds.request-timeout")
protected long requestTimeoutMilliseconds
- maximum duration of an unwrapped http Request
logger
protected Logger logger
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)
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.