cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1506144 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ rt/rs/client/src/main/java/org/...
Date Tue, 23 Jul 2013 16:19:22 GMT
Author: sergeyb
Date: Tue Jul 23 16:19:22 2013
New Revision: 1506144

URL: http://svn.apache.org/r1506144
Log:
[CXF-5146] More work to do with having Typevariables recognized by Jackson

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Tue Jul 23 16:19:22 2013
@@ -1265,16 +1265,25 @@ public final class InjectionUtils {
             // to invoked.getReturnType(); same applies to the case when a method returns
Response
             type = targetObject.getClass(); 
         } else {
-            type = invoked.getGenericReturnType();
-            if (type instanceof TypeVariable) {
-                type = InjectionUtils.getSuperType(invoked.getDeclaringClass(), 
-                                                   (TypeVariable<?>)type);
-            }
+            type = processGenericTypeIfNeeded(invoked.getDeclaringClass(), invoked.getGenericReturnType());
+            
         }
         
         return type;
     }
     
+    public static Type processGenericTypeIfNeeded(Class<?> cls, Type type) {
+        if (type instanceof TypeVariable) {
+            return InjectionUtils.getSuperType(cls, (TypeVariable<?>)type);
+        } else if (type instanceof ParameterizedType
+            && ((ParameterizedType)type).getActualTypeArguments()[0] instanceof TypeVariable
+            && isSupportedCollectionOrArray(getRawType(type))) {
+            return new ParameterizedCollectionType(InjectionUtils.getActualType(type, 0));
+        } else {
+            return type;
+        }
+    }
+    
     public static Object getEntity(Object o) {
         return o instanceof GenericEntity ? ((GenericEntity<?>)o).getEntity() : o;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Tue
Jul 23 16:19:22 2013
@@ -27,7 +27,6 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -774,21 +773,20 @@ public final class JAXRSUtils {
         
         
         Method method = ori.getMethodToInvoke();
-        Class<?>[] parameterTypes = method.getParameterTypes();
-        Parameter[] paramsInfo = ori.getParameters().toArray(new Parameter[ori.getParameters().size()]);
 
         Method annotatedMethod = ori.getAnnotatedMethod();
-        Type[] genericParameterTypes = annotatedMethod == null ? method.getGenericParameterTypes()

-                                      : annotatedMethod.getGenericParameterTypes();
-        Annotation[][] anns = annotatedMethod == null ? null : annotatedMethod.getParameterAnnotations();
+        Method actualMethod = annotatedMethod == null ? method : annotatedMethod;
+        
+        Class<?>[] parameterTypes = actualMethod.getParameterTypes();
+        Parameter[] paramsInfo = ori.getParameters().toArray(new Parameter[ori.getParameters().size()]);
 
+        
+        Type[] genericParameterTypes = actualMethod.getGenericParameterTypes();
+        Annotation[][] anns = actualMethod.getParameterAnnotations();
         List<Object> params = new ArrayList<Object>(parameterTypes.length);
 
         for (int i = 0; i < parameterTypes.length; i++) {
             Class<?> param = parameterTypes[i]; 
-            Type genericParam = genericParameterTypes[i];
-            if (genericParam instanceof TypeVariable) {
-                genericParam = InjectionUtils.getSuperType(ori.getClassResourceInfo().getServiceClass(),

-                                                           (TypeVariable<?>)genericParam);
-            }
+            Type genericParam = InjectionUtils.processGenericTypeIfNeeded(
+                ori.getClassResourceInfo().getServiceClass(), genericParameterTypes[i]);
             if (param == Object.class) {
                 param = (Class<?>)genericParam; 
             } else if (genericParam == Object.class) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ParameterizedCollectionType.java
Tue Jul 23 16:19:22 2013
@@ -23,11 +23,11 @@ import java.lang.reflect.ParameterizedTy
 import java.lang.reflect.Type;
 import java.util.Collection;
 
-public final class ParameterizedCollectionType<T> implements ParameterizedType {
-    private final Class<T> collectionMemberClass;
+public final class ParameterizedCollectionType implements ParameterizedType {
+    private final Class<?> collectionMemberClass;
     private final Type[] typeArgs;
 
-    public ParameterizedCollectionType(Class<T> collectionMemberClass) {
+    public ParameterizedCollectionType(Class<?> collectionMemberClass) {
         this.collectionMemberClass = collectionMemberClass;
         this.typeArgs = new Type[] {collectionMemberClass};
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue Jul 23 16:19:22 2013
@@ -407,7 +407,7 @@ public class JAXBElementProviderTest ext
         TagVO2 tag = new TagVO2("a", "b");
         List<TagVO2> tags = Collections.singletonList(tag);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        provider.writeTo(tags, List.class, new ParameterizedCollectionType<TagVO2>(TagVO2.class),
+        provider.writeTo(tags, List.class, new ParameterizedCollectionType(TagVO2.class),
                        new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String,
Object>(), bos);
         assertTrue(bos.toString().contains("prefix:thetag"));
         assertFalse(bos.toString().contains("ns1:thetag"));

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Tue Jul 23 16:19:22 2013
@@ -143,7 +143,8 @@ public class JAXRSUtilsTest extends Asse
         headers.putSingle("Content-Type", ct);
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, messageImpl);
         assertEquals("2 form params should've been identified", 2, params.size());
         assertEquals("First Form Parameter not matched correctly",
@@ -820,7 +821,8 @@ public class JAXRSUtilsTest extends Asse
         MessageImpl messageImpl = new MessageImpl();
         
         messageImpl.put(Message.QUERY_STRING, "query=24&query2");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(4, params.size());
@@ -837,7 +839,8 @@ public class JAXRSUtilsTest extends Asse
         MessageImpl messageImpl = new MessageImpl();
         
         messageImpl.put(Message.QUERY_STRING, "query=1&query=2");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(1, params.size());
@@ -853,7 +856,8 @@ public class JAXRSUtilsTest extends Asse
         MessageImpl messageImpl = new MessageImpl();
         
         messageImpl.put(Message.QUERY_STRING, "query=1&query=2");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(1, params.size());
@@ -871,7 +875,8 @@ public class JAXRSUtilsTest extends Asse
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, 
                 "query2=query2Value&query2=query2Value2&query3=1&query3=2&query4");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(6, params.size());
@@ -916,7 +921,8 @@ public class JAXRSUtilsTest extends Asse
         MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
         headers.add("Cookie", "c1=c1Value");
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(params.size(), 4);
@@ -940,7 +946,8 @@ public class JAXRSUtilsTest extends Asse
         headers.add("Cookie", "c1=c1Value; c2=c2Value");
         headers.add("Cookie", "c3=c3Value");
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(params.size(), 3);
@@ -956,7 +963,8 @@ public class JAXRSUtilsTest extends Asse
         UUID u = UUID.randomUUID();
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "p1=" + u.toString() + "&p2=1&p3=2");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(3, params.size());
@@ -972,7 +980,8 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testFromValueParam", argType);
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "p1=Europe%2FLondon");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(1, params.size());
@@ -989,7 +998,8 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testCustomerParam", argType);
         
         messageImpl.put(Message.QUERY_STRING, "p1=Fred&p2=Barry&p3=Jack&p4=John");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(3, params.size());
@@ -1019,7 +1029,8 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testLocaleParam", argType);
         
         messageImpl.put(Message.QUERY_STRING, "p1=en_us");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(1, params.size());
@@ -1037,7 +1048,8 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testGenericObjectParam", argType);
         
         messageImpl.put(Message.QUERY_STRING, "p1=thequery");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(1, params.size());
@@ -1055,7 +1067,8 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testCustomerParam", argType);
         
         messageImpl.put(Message.QUERY_STRING, "p3=jack");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(3, params.size());
@@ -1071,7 +1084,8 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testCustomerParam2", argType);
         
         messageImpl.put(Message.QUERY_STRING, "p1=Fred&p1=Barry");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals(1, params.size());
@@ -1087,9 +1101,10 @@ public class JAXRSUtilsTest extends Asse
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "p1=1");
         try {
-            JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
-                                                           null, 
-                                                           messageImpl);
+            JAXRSUtils.processParameters(new OperationResourceInfo(m, 
+                                             new ClassResourceInfo(Customer.class)),
+                                         null, 
+                                         messageImpl);
             fail("HashMap can not be handled as parameter");
         } catch (WebApplicationException ex) {
             assertEquals(500, ex.getResponse().getStatus());
@@ -1107,9 +1122,10 @@ public class JAXRSUtilsTest extends Asse
         MessageImpl messageImpl = new MessageImpl();
         messageImpl.put(Message.QUERY_STRING, "p1=3");
         try {
-            JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
-                                                           null, 
-                                                           messageImpl);
+            JAXRSUtils.processParameters(new OperationResourceInfo(m, 
+                                             new ClassResourceInfo(Customer.class)),
+                                         null, 
+                                         messageImpl);
             fail("CustomerGender have no instance with name 3");
         } catch (WebApplicationException ex) {
             assertEquals(404, ex.getResponse().getStatus());
@@ -1144,7 +1160,8 @@ public class JAXRSUtilsTest extends Asse
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "a=aValue");
 
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            null, messageImpl);
         assertEquals(1, params.size());
         
@@ -1159,7 +1176,8 @@ public class JAXRSUtilsTest extends Asse
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "a=aValue");
 
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            null, messageImpl);
         assertEquals(1, params.size());
         
@@ -1174,7 +1192,8 @@ public class JAXRSUtilsTest extends Asse
         Message messageImpl = createMessage();
         messageImpl.put(Message.QUERY_STRING, "a=aValue");
 
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            null, messageImpl);
         assertEquals(1, params.size());
         
@@ -1269,7 +1288,8 @@ public class JAXRSUtilsTest extends Asse
         String body = "a=aValue&b=123&cb=true";
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
         
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals("Bean should be created", 1, params.size());
@@ -1319,7 +1339,8 @@ public class JAXRSUtilsTest extends Asse
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         String body = "g.b=1&g.b=2";
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            null, 
                                                            messageImpl);
         assertEquals("Bean should be created", 1, params.size());
@@ -1338,7 +1359,8 @@ public class JAXRSUtilsTest extends Asse
                                       MessageImpl simpleMessageImpl,
                                       MultivaluedMap<String, String> complexValues,
                                       MessageImpl complexMessageImpl) throws Exception {
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),
                                                            simpleValues, 
                                                            simpleMessageImpl);
         assertEquals("Bean should be created", 1, params.size());
@@ -1348,9 +1370,10 @@ public class JAXRSUtilsTest extends Asse
         assertEquals("aValue", cb.getA());
         assertEquals(new Long(123), cb.getB());
 
-        params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
-                                                       complexValues, 
-                                                       complexMessageImpl);
+        params = JAXRSUtils.processParameters(new OperationResourceInfo(m, 
+                                                  new ClassResourceInfo(Customer.class)),
+                                              complexValues, 
+                                              complexMessageImpl);
         assertEquals("Bean should be created", 1, params.size());
         Customer.CustomerBean cb1 = (Customer.CustomerBean)params.get(0);
         assertNotNull(cb1);
@@ -1429,7 +1452,8 @@ public class JAXRSUtilsTest extends Asse
         
         messageImpl.put(Message.QUERY_STRING, 
                         "query=first&query2=second&query3=3&query4=true&query5");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            null, messageImpl);
         assertEquals("First Query Parameter of multiple was not matched correctly", "first",

                      params.get(0));
@@ -1452,7 +1476,8 @@ public class JAXRSUtilsTest extends Asse
         MessageImpl messageImpl = new MessageImpl();
         
         messageImpl.put(Message.REQUEST_URI, "/foo;p4=0;p3=3/bar;p1=1;p2/baz;p4=4;p4=5;p5");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            null, messageImpl);
         assertEquals("5 Matrix params should've been identified", 6, params.size());
         
@@ -1481,7 +1506,8 @@ public class JAXRSUtilsTest extends Asse
         messageImpl.put(Message.REQUEST_URI, "/bar%20foo;p4=0%201");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         values.add("ps", "bar%20foo;p4=0%201");
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            values, 
                                                            messageImpl);
         assertEquals("2 params should've been identified", 2, params.size());
@@ -1516,7 +1542,8 @@ public class JAXRSUtilsTest extends Asse
         }
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         messageImpl.setContent(InputStream.class, new ByteArrayInputStream(body.getBytes()));
-        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,

+                                                               new ClassResourceInfo(Customer.class)),

                                                            null, messageImpl);
         assertEquals("2 form params should've been identified", 2, params.size());
         

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Tue Jul 23 16:19:22 2013
@@ -24,7 +24,6 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -592,11 +591,9 @@ public class ClientProxyImpl extends Abs
                     && ((InputStream)r.getEntity()).available() == 0)) {
                 return r;
             }
-            Type genericType = method.getGenericReturnType();
-            if (genericType instanceof TypeVariable) {
-                genericType = InjectionUtils.getSuperType(method.getDeclaringClass(), 
-                                                   (TypeVariable<?>)genericType);
-            }
+            Type genericType = 
+                InjectionUtils.processGenericTypeIfNeeded(method.getDeclaringClass(), 
+                                                          method.getGenericReturnType());
             return readBody(r, 
                             outMessage, 
                             method.getReturnType(), 
@@ -654,6 +651,9 @@ public class ClientProxyImpl extends Abs
                     if (bodyType != null) {
                         paramType = bodyType;
                     }
+                    paramType = InjectionUtils.processGenericTypeIfNeeded(method.getDeclaringClass(),
+                                                                          paramType);
+                    
                     writeBody(body, outMessage, bodyClass, paramType,
                               anns, os);
                 } else {

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Tue Jul
23 16:19:22 2013
@@ -483,7 +483,7 @@ public class WebClient extends AbstractC
     public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod,
Object body, 
                                                     Class<T> memberClass) {
         Response r = doInvoke(httpMethod, body, null, 
-                              Collection.class, new ParameterizedCollectionType<T>(memberClass));
+                              Collection.class, new ParameterizedCollectionType(memberClass));
         return CastUtils.cast((Collection<?>)r.getEntity(), memberClass);
     }
     
@@ -494,7 +494,7 @@ public class WebClient extends AbstractC
      * @return JAX-RS Response
      */
     public <T> Response postCollection(Object collection, Class<T> memberClass)
{
-        return doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType<T>(memberClass),
+        return doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass),
                         Response.class, Response.class);
     }
     
@@ -507,7 +507,7 @@ public class WebClient extends AbstractC
      */
     public <T1, T2> T2 postCollection(Object collection, Class<T1> memberClass,

                                             Class<T2> responseClass) {
-        Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType<T1>(memberClass),
+        Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass),
                               responseClass, responseClass);
         return responseClass.cast(responseClass == Response.class ? r : r.getEntity());
     }
@@ -522,8 +522,8 @@ public class WebClient extends AbstractC
     public <T1, T2> Collection<? extends T2> postAndGetCollection(Object collection,

                                                                   Class<T1> memberClass,

                                                                   Class<T2> responseClass)
{
-        Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType<T1>(memberClass),

-                              Collection.class, new ParameterizedCollectionType<T2>(responseClass));
+        Response r = doInvoke(HttpMethod.POST, collection, new ParameterizedCollectionType(memberClass),

+                              Collection.class, new ParameterizedCollectionType(responseClass));
         return CastUtils.cast((Collection<?>)r.getEntity(), responseClass);
     }
     
@@ -537,7 +537,7 @@ public class WebClient extends AbstractC
     public <T> Collection<? extends T> postObjectGetCollection(Object body, 
                                                                   Class<T> responseClass)
{
         Response r = doInvoke(HttpMethod.POST, body, null, Collection.class, 
-                              new ParameterizedCollectionType<T>(responseClass));
+                              new ParameterizedCollectionType(responseClass));
         return CastUtils.cast((Collection<?>)r.getEntity(), responseClass);
     }
         

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
Tue Jul 23 16:19:22 2013
@@ -21,7 +21,9 @@ package org.apache.cxf.systest.jaxrs;
 
 
 import java.io.ByteArrayOutputStream;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.annotation.PostConstruct;
@@ -111,6 +113,16 @@ public class BookStoreSpring {
     }
     
     @SuppressWarnings("unchecked")
+    @GET
+    @Path("/books/superbooks")
+    @Produces("application/json")
+    public <T extends Book> List<T> getSuperBookCollectionJson() {
+        SuperBook book = new SuperBook("SuperBook", 999L);
+        
+        return Collections.singletonList((T)book);
+    }
+    
+    @SuppressWarnings("unchecked")
     @POST
     @Path("/books/superbook")
     @Consumes("application/json")
@@ -119,6 +131,18 @@ public class BookStoreSpring {
         return (T)(SuperBook)book;
     }
     
+    @SuppressWarnings("unchecked")
+    @POST
+    @Path("/books/superbooks")
+    @Consumes("application/json")
+    @Produces("application/json")
+    public <T extends Book> List<T> echoSuperBookCollectionJson(List<T>
book) {
+        if (book.get(0) instanceof SuperBook) {
+            return book;
+        }
+        throw new WebApplicationException(400);
+    }
+    
     @POST
     @Path("/books/xsitype")
     @Produces("application/xml")

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java?rev=1506144&r1=1506143&r2=1506144&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceJacksonSpringProviderTest.java
Tue Jul 23 16:19:22 2013
@@ -24,6 +24,7 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 
 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
 
@@ -75,6 +76,29 @@ public class JAXRSClientServerResourceJa
     }
     
     @Test
+    public void testGetSuperBookCollectionProxy() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/store2";
+        BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class,

+            Collections.singletonList(new JacksonJsonProvider()));
+        List<SuperBook> books = proxy.getSuperBookCollectionJson();
+        assertEquals(999L, books.get(0).getId());
+    }
+    
+    @Test
+    public void testEchoSuperBookCollectionProxy() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/store2";
+        BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class,

+            Collections.singletonList(new JacksonJsonProvider()));
+        List<SuperBook> books = 
+            proxy.echoSuperBookCollectionJson(Collections.singletonList(new SuperBook("Super",
124L)));
+        assertEquals(124L, books.get(0).getId());
+    }
+    
+    @Test
     public void testEchoSuperBookProxy() throws Exception {
         
         String endpointAddress =
@@ -98,6 +122,20 @@ public class JAXRSClientServerResourceJa
         Book book = collection.iterator().next();
         assertEquals(123L, book.getId());
     }
+    
+    @Test
+    public void testGetCollectionOfSuperBooks() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/webapp/store2/books/superbooks"; 
+        WebClient wc = WebClient.create(endpointAddress,
+            Collections.singletonList(new JacksonJsonProvider()));
+        wc.accept("application/json");
+        Collection<? extends Book> collection = wc.getCollection(Book.class);
+        assertEquals(1, collection.size());
+        Book book = collection.iterator().next();
+        assertEquals(999L, book.getId());
+    }
         
     
     private String getStringFromInputStream(InputStream in) throws Exception {



Mime
View raw message