cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5969] Passing generic type to ParamConverter
Date Mon, 25 Aug 2014 16:38:36 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 62ab4a935 -> a5a3b766a


[CXF-5969] Passing generic type to ParamConverter


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a5a3b766
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a5a3b766
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a5a3b766

Branch: refs/heads/3.0.x-fixes
Commit: a5a3b766ad62f30c50d10f97b605a4e64e377c27
Parents: 62ab4a9
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Aug 25 17:36:05 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Aug 25 17:38:10 2014 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/provider/PrimitiveTextProvider.java |  1 +
 .../cxf/jaxrs/provider/ProviderFactory.java       |  6 ++++--
 .../apache/cxf/jaxrs/utils/InjectionUtils.java    | 18 ++++++++++--------
 .../cxf/jaxrs/provider/ProviderFactoryTest.java   |  2 +-
 .../cxf/jaxrs/utils/InjectionUtilsTest.java       |  4 +++-
 .../apache/cxf/jaxrs/client/AbstractClient.java   |  3 ++-
 .../ext/search/AbstractSearchConditionParser.java |  3 ++-
 7 files changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
index 97561f5..b552d93 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
@@ -57,6 +57,7 @@ public class PrimitiveTextProvider<T>
                     string, 
                     false,
                     type,
+                    genType,
                     anns,
                     ParameterType.REQUEST_BODY, null);
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index 35469f6..f95a829 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -269,12 +269,14 @@ public abstract class ProviderFactory {
         return null;
     }
     
-    public <T> ParamConverter<T> createParameterHandler(Class<T> paramType,
Annotation[] anns) {
+    public <T> ParamConverter<T> createParameterHandler(Class<T> paramType,

+                                                        Type genericType,
+                                                        Annotation[] anns) {
         
         if (newParamConverters != null) {
             anns = anns != null ? anns : new Annotation[]{};
             for (ParamConverterProvider newParamConverter : newParamConverters) {
-                ParamConverter<T> converter = newParamConverter.getConverter(paramType,
paramType, anns);
+                ParamConverter<T> converter = newParamConverter.getConverter(paramType,
genericType, anns);
                 if (converter != null) {
                     return converter;
                 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index bc50373..4b364ab 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -335,6 +335,7 @@ public final class InjectionUtils {
     public static <T> T handleParameter(String value, 
                                         boolean decoded,
                                         Class<T> pClass,
+                                        Type genericType,
                                         Annotation[] paramAnns,
                                         ParameterType pType,
                                         Message message) {
@@ -352,7 +353,7 @@ public final class InjectionUtils {
         
         value = decodeValue(value, decoded, pType);
         
-        Object result = createFromParameterHandler(value, pClass, paramAnns, message);
+        Object result = createFromParameterHandler(value, pClass, genericType, paramAnns,
message);
         if (result != null) {
             return pClass.cast(result);
         }
@@ -431,12 +432,13 @@ public final class InjectionUtils {
 
     public static <T> T createFromParameterHandler(String value, 
                                                     Class<T> pClass,
+                                                    Type genericType,
                                                     Annotation[] anns,
                                                     Message message) {
         T result = null;
         if (message != null) {
             ServerProviderFactory pf = ServerProviderFactory.getInstance(message);
-            ParamConverter<T> pm = pf.createParameterHandler(pClass, anns);
+            ParamConverter<T> pm = pf.createParameterHandler(pClass, genericType, anns);
             if (pm != null) {
                 result = pm.fromString(value);
             }
@@ -628,7 +630,7 @@ public final class InjectionUtils {
                         } else {
                             paramValue = InjectionUtils.handleParameter(
                                 processedValues.values().iterator().next().get(0), 
-                                decoded, type, paramAnns, pType, message);
+                                decoded, type, type, paramAnns, pType, message);
                         }
 
                         if (paramValue != null) {
@@ -678,7 +680,7 @@ public final class InjectionUtils {
                 List<String> valuesList = processedValuesEntry.getValue();
                 for (String value : valuesList) {
                     Object o = InjectionUtils.handleParameter(value,
-                                       decoded, valueType, paramAnns, pathParam, message);
+                                       decoded, valueType, valueType, paramAnns, pathParam,
message);
                     theValues.add(convertStringToPrimitive(processedValuesEntry.getKey(),
keyType), o);
                 }
             }
@@ -691,7 +693,7 @@ public final class InjectionUtils {
                 List<String> valuesList = processedValuesEntry.getValue();
                 for (String value : valuesList) {
                     Object o = InjectionUtils.handleParameter(value,
-                                       decoded, valueType, paramAnns, pathParam, message);
+                                       decoded, valueType, valueType, paramAnns, pathParam,
message);
                     theValues.put(
                         convertStringToPrimitive(processedValuesEntry.getKey(), keyType),

                         o);
@@ -860,7 +862,7 @@ public final class InjectionUtils {
             valuesList = checkPathSegment(valuesList, realType, pathParam);
             for (int ind = 0; ind < valuesList.size(); ind++) {
                 Object o = InjectionUtils.handleParameter(valuesList.get(ind), decoded, 
-                                                          realType, paramAnns, pathParam,
message);
+                                                          realType, realType, paramAnns,
pathParam, message);
                 addToCollectionValues(theValues, o, ind);
             }
         }
@@ -941,7 +943,7 @@ public final class InjectionUtils {
                                 : paramValues.get(0);
             }
             if (result != null) {
-                value = InjectionUtils.handleParameter(result, decoded, paramType, 
+                value = InjectionUtils.handleParameter(result, decoded, paramType, genericType,
                                                        paramAnns, pathParam, message);
             }
         }
@@ -1284,7 +1286,7 @@ public final class InjectionUtils {
     }
     public static Object convertStringToPrimitive(String value, Class<?> cls, Annotation[]
anns) {
         Message m = JAXRSUtils.getCurrentMessage();
-        Object obj = createFromParameterHandler(value, cls, anns, m);
+        Object obj = createFromParameterHandler(value, cls, cls, anns, m);
         if (obj != null) {
             return obj;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
index 0f5631c..150a07d 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
@@ -272,7 +272,7 @@ public class ProviderFactoryTest extends Assert {
         ProviderFactory pf = ServerProviderFactory.getInstance();
         ParamConverterProvider h = new CustomerParameterHandler();
         pf.registerUserProvider(h);
-        ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, null);
+        ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class,
null);
         assertSame(h2, h);
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
index 3ee89bf..630e73f 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/InjectionUtilsTest.java
@@ -57,6 +57,7 @@ public class InjectionUtilsTest extends Assert {
         Object id = InjectionUtils.handleParameter(value, 
                                                    true, 
                                                    Id.class, 
+                                                   Id.class,
                                                    new Annotation[] {}, 
                                                    ParameterType.PATH,  
                                                    createMessage());
@@ -138,7 +139,8 @@ public class InjectionUtilsTest extends Assert {
 
     @Test
     public void testInstantiateJAXBEnum() {
-        CarType carType = InjectionUtils.handleParameter("AUDI", false, CarType.class, null,
+        CarType carType = InjectionUtils.handleParameter("AUDI", false, CarType.class, 
+                                                         CarType.class, null,
                                                          ParameterType.QUERY, null);
         assertEquals("Type is wrong", CarType.AUDI, carType);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
index 53fca45..46acbfb 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
@@ -722,7 +722,8 @@ public abstract class AbstractClient implements Client {
             Class<?> pClass = pValue.getClass();
             
             @SuppressWarnings("unchecked")
-            ParamConverter<Object> prov = (ParamConverter<Object>)pf.createParameterHandler(pClass,
anns);
+            ParamConverter<Object> prov = 
+                (ParamConverter<Object>)pf.createParameterHandler(pClass, pClass, anns);
             if (prov != null) {
                 return prov.toString(pValue);
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/a5a3b766/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
index 94eb45f..2ad62bc 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/AbstractSearchConditionParser.java
@@ -261,7 +261,8 @@ public abstract class AbstractSearchConditionParser<T> implements
SearchConditio
     private Object convertToDate(Class<?> valueType, String value) throws SearchParseException
{
         
         Message m = JAXRSUtils.getCurrentMessage();
-        Object obj = InjectionUtils.createFromParameterHandler(value, valueType, new Annotation[]{},
m);
+        Object obj = InjectionUtils.createFromParameterHandler(value, valueType, valueType,

+                                                               new Annotation[]{}, m);
         if (obj != null) {
             return obj;
         }


Mime
View raw message