cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1089490 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/s...
Date Wed, 06 Apr 2011 15:23:48 GMT
Author: sergeyb
Date: Wed Apr  6 15:23:48 2011
New Revision: 1089490

URL: http://svn.apache.org/viewvc?rev=1089490&view=rev
Log:
Merged revisions 1089487 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1089487 | sergeyb | 2011-04-06 16:17:15 +0100 (Wed, 06 Apr 2011) | 1 line
  
  [CXF-3443] Checking XmlJavaTypeAdapters for all types of JAX-RS parameters
........

Added:
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXBUtils.java
      - copied unchanged from r1089487, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXBUtils.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr  6 15:23:48 2011
@@ -1 +1 @@
-/cxf/trunk:1089407
+/cxf/trunk:1089407,1089487

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Wed Apr  6 15:23:48 2011
@@ -54,7 +54,6 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlAnyElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
@@ -504,28 +503,8 @@ public abstract class AbstractJAXBProvid
     }
     
     protected static Object checkAdapter(Object obj, Class<?> cls, Annotation[] anns,
boolean marshal) {
-        return useAdapter(obj, getAdapter(obj.getClass(), anns), marshal); 
-    }
-    
-    @SuppressWarnings("unchecked")
-    protected static Object useAdapter(Object obj, XmlJavaTypeAdapter typeAdapter, boolean
marshal) {
-        if (typeAdapter != null) {
-            if (InjectionUtils.isSupportedCollectionOrArray(typeAdapter.value().getClass()))
{
-                return obj;
-            }
-            try {
-                XmlAdapter xmlAdapter = typeAdapter.value().newInstance();
-                if (marshal) {
-                    return xmlAdapter.marshal(obj);
-                } else {
-                    return xmlAdapter.unmarshal(obj);
-                }
-            } catch (Exception ex) {
-                LOG.warning("Problem using the XmlJavaTypeAdapter");
-                ex.printStackTrace();
-            }
-        }
-        return obj;
+        return org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(obj, getAdapter(obj.getClass(),
anns), 
+                                                               marshal); 
     }
     
     protected static XmlJavaTypeAdapter getAdapter(Class<?> objectClass, Annotation[]
anns) {
@@ -710,7 +689,8 @@ public abstract class AbstractJAXBProvid
                     adapterChecked = true;
                     List<Object> newList = new ArrayList<Object>(theList.size());
                     for (Object o : theList) {
-                        newList.add(useAdapter(((JAXBElement)o).getValue(), adapter, false));
+                        newList.add(org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(
+                                        ((JAXBElement)o).getValue(), adapter, false));
                     }
                     theList = newList;
                 }
@@ -718,14 +698,15 @@ public abstract class AbstractJAXBProvid
             if (origType.isArray()) {
                 T[] values = (T[])Array.newInstance(type, theList.size());
                 for (int i = 0; i < theList.size(); i++) {
-                    values[i] = (T)useAdapter(theList.get(i), adapter, false);
+                    values[i] = (T)org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(
+                                       theList.get(i), adapter, false);
                 }
                 return values;
             } else {
                 if (!adapterChecked && adapter != null) {
                     List<Object> newList = new ArrayList<Object>(theList.size());
                     for (Object o : theList) {
-                        newList.add(useAdapter(o, adapter, false));
+                        newList.add(org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(o, adapter,
false));
                     }
                     theList = newList;
                 }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Wed Apr  6 15:23:48 2011
@@ -59,6 +59,7 @@ import org.apache.cxf.jaxrs.ext.MessageC
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.JAXBUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
@@ -290,11 +291,11 @@ public class JAXBElementProvider extends
         os.write(startTag.getBytes());
         if (firstObj != null) {
             XmlJavaTypeAdapter adapter = getAdapter(firstObj.getClass(), anns);
-            marshalCollectionMember(useAdapter(firstObj, adapter, true), 
+            marshalCollectionMember(JAXBUtils.useAdapter(firstObj, adapter, true), 
                                     actualClass, genericType, encoding, os, m, 
                                     qname.getNamespaceURI());
             while (it.hasNext()) {
-                marshalCollectionMember(useAdapter(it.next(), adapter, true), actualClass,

+                marshalCollectionMember(JAXBUtils.useAdapter(it.next(), adapter, true), actualClass,

                                         genericType, encoding, os, m, 
                                         qname.getNamespaceURI());
             }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Wed Apr  6 15:23:48 2011
@@ -56,6 +56,7 @@ import org.apache.cxf.jaxrs.ext.MessageC
 import org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.CollectionWrapper;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.JAXBUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 import org.codehaus.jettison.mapped.Configuration;
 import org.codehaus.jettison.mapped.SimpleConverter;
@@ -351,11 +352,11 @@ public class JSONProvider extends Abstra
         os.write(startTag.getBytes());
         if (firstObj != null) {
             XmlJavaTypeAdapter adapter = getAdapter(firstObj.getClass(), anns);
-            marshalCollectionMember(useAdapter(firstObj, adapter, true),
+            marshalCollectionMember(JAXBUtils.useAdapter(firstObj, adapter, true),
                                     actualClass, genericType, encoding, os);
             while (it.hasNext()) {
                 os.write(",".getBytes());
-                marshalCollectionMember(useAdapter(it.next(), adapter, true), 
+                marshalCollectionMember(JAXBUtils.useAdapter(it.next(), adapter, true), 
                                         actualClass, genericType, encoding, os);
             }
         }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
Wed Apr  6 15:23:48 2011
@@ -52,6 +52,7 @@ public class PrimitiveTextProvider 
                     IOUtils.readStringFromStream(is), 
                     false,
                     type,
+                    anns,
                     ParameterType.REQUEST_BODY, null);
         
     }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Wed Apr  6 15:23:48 2011
@@ -271,7 +271,8 @@ public final class InjectionUtils {
     
     public static Object handleParameter(String value, 
                                          boolean decoded,
-                                         Class<?> pClass, 
+                                         Class<?> pClass,
+                                         Annotation[] paramAnns,
                                          ParameterType pType,
                                          Message message) {
         
@@ -340,6 +341,15 @@ public final class InjectionUtils {
         }
         
         if (result == null) {
+            // as the last resort, try XmlJavaTypeAdapters
+            try {
+                result = JAXBUtils.convertWithAdapter(value, paramAnns);
+            } catch (Throwable ex) {
+                // ignore - may be to do with JAXB classes not being available 
+            }
+        }
+        
+        if (result == null) {
             reportServerError("WRONG_PARAMETER_TYPE", pClass.getName());
         }
         
@@ -394,7 +404,8 @@ public final class InjectionUtils {
         return null;
     }
     
-    public static Object handleBean(Class<?> paramType, MultivaluedMap<String, String>
values,
+    public static Object handleBean(Class<?> paramType, Annotation[] paramAnns, 
+                                    MultivaluedMap<String, String> values,
                                     ParameterType pType, Message message, boolean decoded)
{
         Object bean = null;
         try {
@@ -480,18 +491,18 @@ public final class InjectionUtils {
                     for (MultivaluedMap<String, String> processedValues : processedValuesList)
{
                         if (InjectionUtils.isSupportedCollectionOrArray(type)) {
                             Object appendValue = InjectionUtils.injectIntoCollectionOrArray(type,
-                                                            genericType, processedValues,
+                                                            genericType, paramAnns, processedValues,
                                                             isbean, true,
                                                             pType, message);
                             paramValue = InjectionUtils.mergeCollectionsOrArrays(paramValue,
appendValue,
                                                             genericType);
                         } else if (isbean) {
-                            paramValue = InjectionUtils.handleBean(type, processedValues,
+                            paramValue = InjectionUtils.handleBean(type, paramAnns, processedValues,
                                                             pType, message, decoded);
                         } else {
                             paramValue = InjectionUtils.handleParameter(
                                 processedValues.values().iterator().next().get(0), 
-                                decoded, type, pType, message);
+                                decoded, type, paramAnns, pType, message);
                         }
 
                         if (paramValue != null) {
@@ -607,11 +618,14 @@ public final class InjectionUtils {
         return type;
         
     }
-    
-    private static Object injectIntoCollectionOrArray(Class<?> rawType, Type genericType,
+    //CHECKSTYLE:OFF
+    private static Object injectIntoCollectionOrArray(Class<?> rawType, 
+                                                      Type genericType,
+                                                      Annotation[] paramAnns, 
                                         MultivaluedMap<String, String> values,
                                         boolean isbean, boolean decoded,
                                         ParameterType pathParam, Message message) {
+     //CHECKSTYLE:ON    
         Class<?> type = getCollectionType(rawType);
 
         Class<?> realType = InjectionUtils.getActualType(genericType);
@@ -629,14 +643,14 @@ public final class InjectionUtils {
             theValues = Array.newInstance(realType, isbean ? 1 : values.values().iterator().next().size());
         }
         if (isbean) {
-            Object o = InjectionUtils.handleBean(realType, values, pathParam, message, decoded);
+            Object o = InjectionUtils.handleBean(realType, paramAnns, values, pathParam,
message, decoded);
             addToCollectionValues(theValues, o, 0);
         } else {
             List<String> valuesList = values.values().iterator().next();
             valuesList = checkPathSegment(valuesList, realType, pathParam);
             for (int ind = 0; ind < valuesList.size(); ind++) {
                 Object o = InjectionUtils.handleParameter(valuesList.get(ind), decoded, 
-                                                          realType, pathParam, message);
+                                                          realType, paramAnns, pathParam,
message);
                 addToCollectionValues(theValues, o, ind);
             }
         }
@@ -673,14 +687,17 @@ public final class InjectionUtils {
         }
         return newValues;
     }
-    
+    // 
+    //CHECKSTYLE:OFF
     public static Object createParameterObject(List<String> paramValues,
                                                Class<?> paramType,
                                                Type genericType,
+                                               Annotation[] paramAnns,
                                                String defaultValue,
                                                boolean decoded,
                                                ParameterType pathParam,
                                                Message message) {
+    //CHECKSTYLE:ON    
         
         if (paramValues == null) {
             if (defaultValue != null) {
@@ -701,8 +718,8 @@ public final class InjectionUtils {
         if (InjectionUtils.isSupportedCollectionOrArray(paramType)) {
             MultivaluedMap<String, String> paramValuesMap = new MetadataMap<String,
String>();
             paramValuesMap.put("", paramValues);
-            value = InjectionUtils.injectIntoCollectionOrArray(paramType, genericType, paramValuesMap,
-                                                false, decoded, pathParam, message);
+            value = InjectionUtils.injectIntoCollectionOrArray(paramType, genericType, paramAnns,

+                                                paramValuesMap, false, decoded, pathParam,
message);
         } else {
             String result = null;
             if (paramValues.size() > 0) {
@@ -711,7 +728,8 @@ public final class InjectionUtils {
                                 : paramValues.get(0);
             }
             if (result != null) {
-                value = InjectionUtils.handleParameter(result, decoded, paramType, pathParam,
message);
+                value = InjectionUtils.handleParameter(result, decoded, paramType, 
+                                                       paramAnns, pathParam, message);
             }
         }
         return value;

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Wed Apr  6 15:23:48 2011
@@ -201,6 +201,7 @@ public final class JAXRSUtils {
             Object o = createHttpParameterValue(p, 
                                                 m.getParameterTypes()[0],
                                                 m.getGenericParameterTypes()[0],
+                                                m.getParameterAnnotations()[0],
                                                 message,
                                                 values,
                                                 ori);
@@ -212,6 +213,7 @@ public final class JAXRSUtils {
             Object o = createHttpParameterValue(p, 
                                                 f.getType(),
                                                 f.getGenericType(),
+                                                f.getAnnotations(),
                                                 message,
                                                 values,
                                                 ori);
@@ -602,6 +604,7 @@ public final class JAXRSUtils {
             return createHttpParameterValue(parameter,
                                             parameterClass,
                                             parameterType,
+                                            parameterAnns,
                                             message,
                                             values,
                                             ori);
@@ -611,6 +614,7 @@ public final class JAXRSUtils {
     public static Object createHttpParameterValue(Parameter parameter, 
                                             Class<?> parameterClass, 
                                             Type genericParam,
+                                            Annotation[] paramAnns,
                                             Message message,
                                             MultivaluedMap<String, String> values,
                                             OperationResourceInfo ori) {
@@ -624,33 +628,33 @@ public final class JAXRSUtils {
         Object result = null;
         
         if (parameter.getType() == ParameterType.PATH) {
-            result = readFromUriParam(message, parameter.getName(), parameterClass, genericParam,

-                                      values, defaultValue, !isEncoded);
+            result = readFromUriParam(message, parameter.getName(), parameterClass, genericParam,
+                                      paramAnns, values, defaultValue, !isEncoded);
         } 
         
         if (parameter.getType() == ParameterType.QUERY) {
-            result = readQueryString(parameter.getName(), parameterClass, genericParam, message,

-                                   defaultValue, !isEncoded);
+            result = readQueryString(parameter.getName(), parameterClass, genericParam, 
+                                     paramAnns, message, defaultValue, !isEncoded);
         }
         
         if (parameter.getType() == ParameterType.MATRIX) {
-            result = processMatrixParam(message, parameter.getName(), parameterClass, genericParam,

-                                      defaultValue, !isEncoded);
+            result = processMatrixParam(message, parameter.getName(), parameterClass, genericParam,
+                                        paramAnns, defaultValue, !isEncoded);
         }
         
         if (parameter.getType() == ParameterType.FORM) {
             result = processFormParam(message, parameter.getName(), parameterClass, genericParam,

-                                      defaultValue, !isEncoded);
+                                      paramAnns, defaultValue, !isEncoded);
         }
         
         if (parameter.getType() == ParameterType.COOKIE) {
             result = processCookieParam(message, parameter.getName(), parameterClass, genericParam,
-                                        defaultValue);
+                                        paramAnns, defaultValue);
         } 
         
         if (parameter.getType() == ParameterType.HEADER) {
-            result = processHeaderParam(message, parameter.getName(), parameterClass, genericParam,

-                                        defaultValue);
+            result = processHeaderParam(message, parameter.getName(), parameterClass, genericParam,
+                                        paramAnns, defaultValue);
         } 
 
         return result;
@@ -658,6 +662,7 @@ public final class JAXRSUtils {
     
     private static Object processMatrixParam(Message m, String key, 
                                              Class<?> pClass, Type genericType,
+                                             Annotation[] paramAnns,
                                              String defaultValue,
                                              boolean decode) {
         List<PathSegment> segments = JAXRSUtils.getPathSegments(
@@ -674,12 +679,13 @@ public final class JAXRSUtils {
             }
             
             if ("".equals(key)) {
-                return InjectionUtils.handleBean(pClass, params, ParameterType.MATRIX, m,
false);
+                return InjectionUtils.handleBean(pClass, paramAnns, params, ParameterType.MATRIX,
m, false);
             } else {
                 List<String> values = params.get(key);
                 return InjectionUtils.createParameterObject(values, 
                                                             pClass, 
                                                             genericType,
+                                                            paramAnns, 
                                                             defaultValue,
                                                             false,
                                                             ParameterType.MATRIX,
@@ -692,6 +698,7 @@ public final class JAXRSUtils {
     
     private static Object processFormParam(Message m, String key, 
                                            Class<?> pClass, Type genericType,
+                                           Annotation[] paramAnns,
                                            String defaultValue,
                                            boolean decode) {
         
@@ -727,13 +734,14 @@ public final class JAXRSUtils {
         }
         
         if ("".equals(key)) {
-            return InjectionUtils.handleBean(pClass, params, ParameterType.FORM, m, false);
+            return InjectionUtils.handleBean(pClass, paramAnns, params, ParameterType.FORM,
m, false);
         } else {
             List<String> results = params.get(key);
     
             return InjectionUtils.createParameterObject(results, 
                                                         pClass, 
                                                         genericType,
+                                                        paramAnns,
                                                         defaultValue,
                                                         false,
                                                         ParameterType.FORM,
@@ -751,8 +759,9 @@ public final class JAXRSUtils {
     
     private static Object processHeaderParam(Message m, 
                                              String header, 
-                                             Class<?> pClass, 
+                                             Class<?> pClass,
                                              Type genericType, 
+                                             Annotation[] paramAnns,
                                              String defaultValue) {
         
         List<String> values = new HttpHeadersImpl(m).getRequestHeader(header);
@@ -762,6 +771,7 @@ public final class JAXRSUtils {
         return InjectionUtils.createParameterObject(values, 
                                                     pClass, 
                                                     genericType,
+                                                    paramAnns,
                                                     defaultValue,
                                                     false,
                                                     ParameterType.HEADER,
@@ -771,7 +781,8 @@ public final class JAXRSUtils {
     }
 
     private static Object processCookieParam(Message m, String cookieName, 
-                              Class<?> pClass, Type genericType, String defaultValue)
{
+                              Class<?> pClass, Type genericType, 
+                              Annotation[] paramAnns, String defaultValue) {
         Cookie c = new HttpHeadersImpl(m).getCookies().get(cookieName);
         
         if (c == null && defaultValue != null) {
@@ -785,7 +796,8 @@ public final class JAXRSUtils {
             return c;
         }
         
-        return InjectionUtils.handleParameter(c.getValue(), false, pClass, ParameterType.COOKIE,
m);
+        return InjectionUtils.handleParameter(c.getValue(), false, pClass, paramAnns, 
+                                              ParameterType.COOKIE, m);
     }
     
     public static <T> T createContextValue(Message m, Type genericType, Class<T>
clazz) {
@@ -878,22 +890,24 @@ public final class JAXRSUtils {
         
         return clazz.cast(value);
     }
-
+    //CHECKSTYLE:OFF
     private static Object readFromUriParam(Message m,
                                            String parameterName,
                                            Class<?> paramType,
                                            Type genericType,
+                                           Annotation[] paramAnns,
                                            MultivaluedMap<String, String> values,
                                            String defaultValue,
                                            boolean decoded) {
-        
+    //CHECKSTYLE:ON    
         if ("".equals(parameterName)) {
-            return InjectionUtils.handleBean(paramType, values, ParameterType.PATH, m, decoded);
+            return InjectionUtils.handleBean(paramType, paramAnns, values, ParameterType.PATH,
m, decoded);
         } else {
             List<String> results = values.get(parameterName);
             return InjectionUtils.createParameterObject(results, 
                                                     paramType, 
                                                     genericType,
+                                                    paramAnns,
                                                     defaultValue,
                                                     decoded,
                                                     ParameterType.PATH,
@@ -907,6 +921,7 @@ public final class JAXRSUtils {
     private static Object readQueryString(String queryName,
                                           Class<?> paramType,
                                           Type genericType,
+                                          Annotation[] paramAnns,
                                           Message m, 
                                           String defaultValue,
                                           boolean decode) {
@@ -914,11 +929,12 @@ public final class JAXRSUtils {
         MultivaluedMap<String, String> queryMap = new UriInfoImpl(m, null).getQueryParameters(decode);
         
         if ("".equals(queryName)) {
-            return InjectionUtils.handleBean(paramType, queryMap, ParameterType.QUERY, m,
false);
+            return InjectionUtils.handleBean(paramType, paramAnns, queryMap, ParameterType.QUERY,
m, false);
         } else {
             return InjectionUtils.createParameterObject(queryMap.get(queryName), 
                                                         paramType, 
                                                         genericType,
+                                                        paramAnns,
                                                         defaultValue,
                                                         false,
                                                         ParameterType.QUERY, m);

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Wed Apr  6 15:23:48 2011
@@ -535,7 +535,7 @@ public final class ResourceUtils {
             } else {
                 Parameter p = ResourceUtils.getParameter(i, anns[i]);
                 values[i] = JAXRSUtils.createHttpParameterValue(
-                                p, params[i], genericTypes[i], m, templateValues, null);
+                                p, params[i], genericTypes[i], anns[i], m, templateValues,
null);
             }
         }
         return values;

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
Wed Apr  6 15:23:48 2011
@@ -55,6 +55,8 @@ import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Providers;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.apache.cxf.jaxrs.impl.PathSegmentImpl;
 
@@ -171,6 +173,13 @@ public class Customer extends AbstractCu
     public void testQueryBean(@QueryParam("") CustomerBean cb) {
         
     }
+    
+    public void testXmlAdapter(@QueryParam("a") 
+                               @XmlJavaTypeAdapter(CustomerBeanAdapter.class) 
+                               CustomerBean cb) {
+        
+    }
+    
     public void testPathBean(@PathParam("") CustomerBean cb) {
         
     }
@@ -411,4 +420,21 @@ public class Customer extends AbstractCu
     public void testContextResolvers(@Context ContextResolver<JAXBContext> resolver)
{
         // complete
     }
+    
+    public static class CustomerBeanAdapter extends XmlAdapter<String, CustomerBean>
{
+
+        @Override
+        public CustomerBean unmarshal(String value) throws Exception {
+            CustomerBean bean = new CustomerBean();
+            bean.setA(value);
+            return bean;
+        }
+
+        @Override
+        public String marshal(CustomerBean v) throws Exception {
+            // TODO Auto-generated method stub
+            return null;
+        }
+        
+    }
 };

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1089490&r1=1089489&r2=1089490&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Wed Apr  6 15:23:48 2011
@@ -854,6 +854,22 @@ public class JAXRSUtilsTest extends Asse
     }
     
     @Test
+    public void testXmlAdapterBean() throws Exception {
+        Class[] argType = {Customer.CustomerBean.class};
+        Method m = Customer.class.getMethod("testXmlAdapter", argType);
+        Message messageImpl = createMessage();
+        messageImpl.put(Message.QUERY_STRING, "a=aValue");
+
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
+                                                           null, messageImpl);
+        assertEquals(1, params.size());
+        
+        Customer.CustomerBean bean = (Customer.CustomerBean)params.get(0);
+        assertEquals("aValue", bean.getA());
+    }
+    
+    
+    @Test
     public void testPathParametersBean() throws Exception {
         Class[] argType = {Customer.CustomerBean.class};
         Method m = Customer.class.getMethod("testPathBean", argType);



Mime
View raw message