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

java.lang.Object
  extended by org.jclouds.rest.internal.RestAnnotationProcessor<T>

public class RestAnnotationProcessor<T>
extends Object

Creates http methods based on annotations on a class or interface.

Author:
Adrian Cole

Nested Class Summary
static class RestAnnotationProcessor.MethodKey
           
 
Field Summary
static String BOUNDARY
           
static com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<Boolean>> futureBooleanLiteral
           
static com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<HttpResponse>> futureHttpResponseLiteral
           
static com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<InputStream>> futureInputStreamLiteral
           
static com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<String>> futureStringLiteral
           
static com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<URI>> futureURILiteral
           
static com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<Void>> futureVoidLiteral
           
protected  Logger logger
           
 
Constructor Summary
RestAnnotationProcessor(com.google.inject.Injector injector, com.google.common.cache.LoadingCache<Class<?>,Boolean> seedAnnotationCache, com.google.common.cache.Cache<RestAnnotationProcessor.MethodKey,Method> delegationMap, String apiVersion, String buildVersion, ParseSax.Factory parserFactory, HttpUtils utils, ContentMetadataCodec contentMetadataCodec, com.google.inject.TypeLiteral<T> typeLiteral)
           
 
Method Summary
 void addHeaderIfAnnotationPresentOnMethod(com.google.common.collect.Multimap<String,String> headers, Method method, com.google.common.collect.Multimap<String,?> tokenValues)
           
 com.google.common.collect.Multimap<String,String> buildHeaders(com.google.common.collect.Multimap<String,?> tokenValues, Method method, Object... args)
           
static com.google.common.base.Function<Exception,?> createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(com.google.inject.Injector injector, Method method)
           
 GeneratedHttpRequest createRequest(Method method, Object... args)
           
static com.google.common.base.Function<HttpResponse,?> createResponseParser(ParseSax.Factory parserFactory, com.google.inject.Injector injector, Method method, HttpRequest request)
           
 GeneratedHttpRequest decorateRequest(GeneratedHttpRequest request)
           
static com.google.common.collect.Multimap<String,String> filterOutContentHeaders(com.google.common.collect.Multimap<String,String> headers)
           
static HttpRequest findHttpRequestInArgs(Object[] args)
           
static Payload findPayloadInArgs(Object[] args)
           
 Class<T> getDeclaring()
          the class that is being processed
 Method getDelegateOrNull(Method in)
           
static URI getEndpointInParametersOrNull(Method method, Object[] args, com.google.inject.Injector injector)
           
 String getHttpMethodOrConstantOrThrowException(Method method)
           
static Set<String> getHttpMethods(Method method)
           
static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getJAXBParserKeyForMethod(Method method)
           
static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getJsonParserKeyForMethod(Method method)
           
static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getJsonParserKeyForMethodAnType(Method method, Type returnVal)
           
 MapBinder getMapPayloadBinderOrNull(Method method, Object... args)
           
protected  com.google.common.base.Optional<?> getParamValue(Method method, Object[] args, Set<Annotation> extractors, Map.Entry<Integer,Set<Annotation>> entry, String paramKey)
           
static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getParserOrThrowException(Method method)
           
static Type getReturnTypeForMethod(Method method)
           
static Class<? extends ParseSax.HandlerWithResult<?>> getSaxResponseParserClassOrNull(Method method)
           
static com.google.common.base.Function<HttpResponse,?> getTransformerForMethod(Method method, com.google.inject.Injector injector)
           
static Map<Integer,Set<Annotation>> indexWithOnlyOneAnnotation(Method method, String description, com.google.common.cache.LoadingCache<Method,com.google.common.cache.LoadingCache<Integer,Set<Annotation>>> toRefine)
           
 void setCaller(ClassMethodArgs caller)
           
 boolean shouldAddHostHeader(Method method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger

BOUNDARY

public static final String BOUNDARY
See Also:
Constant Field Values

futureBooleanLiteral

public static final com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<Boolean>> futureBooleanLiteral

futureStringLiteral

public static final com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<String>> futureStringLiteral

futureVoidLiteral

public static final com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<Void>> futureVoidLiteral

futureURILiteral

public static final com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<URI>> futureURILiteral

futureInputStreamLiteral

public static final com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<InputStream>> futureInputStreamLiteral

futureHttpResponseLiteral

public static final com.google.inject.TypeLiteral<com.google.common.util.concurrent.ListenableFuture<HttpResponse>> futureHttpResponseLiteral
Constructor Detail

RestAnnotationProcessor

@Inject
public RestAnnotationProcessor(com.google.inject.Injector injector,
                                      com.google.common.cache.LoadingCache<Class<?>,Boolean> seedAnnotationCache,
                                      com.google.common.cache.Cache<RestAnnotationProcessor.MethodKey,Method> delegationMap,
                                      String apiVersion,
                                      String buildVersion,
                                      ParseSax.Factory parserFactory,
                                      HttpUtils utils,
                                      ContentMetadataCodec contentMetadataCodec,
                                      com.google.inject.TypeLiteral<T> typeLiteral)
Method Detail

createResponseParser

public static com.google.common.base.Function<HttpResponse,?> createResponseParser(ParseSax.Factory parserFactory,
                                                                                   com.google.inject.Injector injector,
                                                                                   Method method,
                                                                                   HttpRequest request)

getTransformerForMethod

public static com.google.common.base.Function<HttpResponse,?> getTransformerForMethod(Method method,
                                                                                      com.google.inject.Injector injector)

createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation

public static com.google.common.base.Function<Exception,?> createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(com.google.inject.Injector injector,
                                                                                                                           Method method)

getDelegateOrNull

public Method getDelegateOrNull(Method in)

setCaller

public void setCaller(ClassMethodArgs caller)

createRequest

public GeneratedHttpRequest createRequest(Method method,
                                          Object... args)

filterOutContentHeaders

public static com.google.common.collect.Multimap<String,String> filterOutContentHeaders(com.google.common.collect.Multimap<String,String> headers)

getEndpointInParametersOrNull

public static URI getEndpointInParametersOrNull(Method method,
                                                Object[] args,
                                                com.google.inject.Injector injector)

getParserOrThrowException

public static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getParserOrThrowException(Method method)

getJsonParserKeyForMethod

public static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getJsonParserKeyForMethod(Method method)

getJAXBParserKeyForMethod

public static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getJAXBParserKeyForMethod(Method method)

getReturnTypeForMethod

public static Type getReturnTypeForMethod(Method method)

getJsonParserKeyForMethodAnType

public static com.google.inject.Key<? extends com.google.common.base.Function<HttpResponse,?>> getJsonParserKeyForMethodAnType(Method method,
                                                                                                                               Type returnVal)

getSaxResponseParserClassOrNull

public static Class<? extends ParseSax.HandlerWithResult<?>> getSaxResponseParserClassOrNull(Method method)

getMapPayloadBinderOrNull

public MapBinder getMapPayloadBinderOrNull(Method method,
                                           Object... args)

getHttpMethods

public static Set<String> getHttpMethods(Method method)

getHttpMethodOrConstantOrThrowException

public String getHttpMethodOrConstantOrThrowException(Method method)

shouldAddHostHeader

public boolean shouldAddHostHeader(Method method)

decorateRequest

public GeneratedHttpRequest decorateRequest(GeneratedHttpRequest request)
                                     throws NegativeArraySizeException
Throws:
NegativeArraySizeException

indexWithOnlyOneAnnotation

public static Map<Integer,Set<Annotation>> indexWithOnlyOneAnnotation(Method method,
                                                                      String description,
                                                                      com.google.common.cache.LoadingCache<Method,com.google.common.cache.LoadingCache<Integer,Set<Annotation>>> toRefine)

buildHeaders

public com.google.common.collect.Multimap<String,String> buildHeaders(com.google.common.collect.Multimap<String,?> tokenValues,
                                                                      Method method,
                                                                      Object... args)

addHeaderIfAnnotationPresentOnMethod

public void addHeaderIfAnnotationPresentOnMethod(com.google.common.collect.Multimap<String,String> headers,
                                                 Method method,
                                                 com.google.common.collect.Multimap<String,?> tokenValues)

findHttpRequestInArgs

public static HttpRequest findHttpRequestInArgs(Object[] args)

findPayloadInArgs

public static Payload findPayloadInArgs(Object[] args)

getParamValue

protected com.google.common.base.Optional<?> getParamValue(Method method,
                                                           Object[] args,
                                                           Set<Annotation> extractors,
                                                           Map.Entry<Integer,Set<Annotation>> entry,
                                                           String paramKey)

getDeclaring

public Class<T> getDeclaring()
the class that is being processed



Copyright © 2009-2013 jclouds. All Rights Reserved.