All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.client.core.extractors.ResponseObjectProxy Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package org.jboss.resteasy.client.core.extractors;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;

/**
 * This class represents the proxying functionality for creating a
 * "rich response object" that has the @ResponseObject annotation. The method
 * implementations ware created in ResponseObjectEntityExtractorFactory
 *
 * @author Solomon Duskis
 * @version $Revision: 1 $
 * @see EntityExtractor, ResponseObjectEntityExtractorFactory
 */

@SuppressWarnings("unchecked")
public class ResponseObjectProxy implements EntityExtractor
{
   private Class returnType;
   private HashMap> methodHandlers;

   public ResponseObjectProxy(Method method, EntityExtractorFactory extractorFactory)
   {
      this.returnType = (Class) method.getReturnType();
      this.methodHandlers = new HashMap>();
      for (Method interfaceMethod : this.returnType.getMethods())
      {
         this.methodHandlers.put(interfaceMethod, extractorFactory.createExtractor(interfaceMethod));
      }
   }

   public Object extractEntity(ClientRequestContext context, Object... args)
   {
      Class[] intfs = {returnType};
      ClientResponseProxy clientProxy = new ClientResponseProxy(context, methodHandlers, returnType);
      return Proxy.newProxyInstance(returnType.getClassLoader(), intfs, clientProxy);
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy