cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] git commit: Updating JAXRS ClientProxy to use bean parameter annotations
Date Tue, 11 Mar 2014 11:07:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 9a8a73d6a -> 822b63baf


Updating JAXRS ClientProxy to use bean parameter annotations


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

Branch: refs/heads/2.7.x-fixes
Commit: 0016c11240ff4d6910821d6b912098c3a1270f0d
Parents: c729193
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Mar 10 22:10:40 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Mar 11 11:06:58 2014 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/client/ClientProxyImpl.java       | 52 +++++++++++++-------
 1 file changed, 34 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0016c112/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
index 7dd2ca5..a2543b7 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
@@ -457,18 +457,18 @@ public class ClientProxyImpl extends AbstractClient implements
             }
         }
         for (Parameter p : beanParams) {
-            Map<String, Object> values = getValuesFromBeanParam(params[p.getIndex()],
QueryParam.class);
-            for (Map.Entry<String, Object> entry : values.entrySet()) {
+            Map<String, BeanPair> values = getValuesFromBeanParam(params[p.getIndex()],
QueryParam.class);
+            for (Map.Entry<String, BeanPair> entry : values.entrySet()) {
                 if (entry.getValue() != null) {
                     addMatrixQueryParamsToBuilder(ub, entry.getKey(), ParameterType.QUERY,
-                                                  null, entry.getValue());
+                                                  entry.getValue().getAnns(), entry.getValue().getValue());
                 }
             }
         }
     }
     
-    private Map<String, Object> getValuesFromBeanParam(Object bean, Class<? extends
Annotation> annClass) {
-        Map<String, Object> values = new HashMap<String, Object>();
+    private Map<String, BeanPair> getValuesFromBeanParam(Object bean, Class<? extends
Annotation> annClass) {
+        Map<String, BeanPair> values = new HashMap<String, BeanPair>();
         
         for (Method m : bean.getClass().getMethods()) {
             Annotation annotation = m.getAnnotation(annClass);
@@ -478,7 +478,7 @@ public class ClientProxyImpl extends AbstractClient implements
                     Method getter = bean.getClass().getMethod("get" + propertyName, new Class[]{});
                     Object value = getter.invoke(bean, new Object[]{});
                     String annotationValue = AnnotationUtils.getAnnotationValue(annotation);
-                    values.put(annotationValue, value);
+                    values.put(annotationValue, new BeanPair(value, m.getParameterAnnotations()[0]));
                 } catch (Throwable t) {
                     // ignore
                 }
@@ -500,11 +500,11 @@ public class ClientProxyImpl extends AbstractClient implements
             }
         }
         for (Parameter p : beanParams) {
-            Map<String, Object> values = getValuesFromBeanParam(params[p.getIndex()],
MatrixParam.class);
-            for (Map.Entry<String, Object> entry : values.entrySet()) {
+            Map<String, BeanPair> values = getValuesFromBeanParam(params[p.getIndex()],
MatrixParam.class);
+            for (Map.Entry<String, BeanPair> entry : values.entrySet()) {
                 if (entry.getValue() != null) {
                     addMatrixQueryParamsToBuilder(ub, entry.getKey(), ParameterType.MATRIX,
-                                                  null, entry.getValue());
+                                                  entry.getValue().getAnns(), entry.getValue().getValue());
                 }
             }
         }
@@ -522,9 +522,9 @@ public class ClientProxyImpl extends AbstractClient implements
             addFormValue(form, p.getName(), params[p.getIndex()], getParamAnnotations(m,
p));
         }
         for (Parameter p : beanParams) {
-            Map<String, Object> values = getValuesFromBeanParam(params[p.getIndex()],
FormParam.class);
-            for (Map.Entry<String, Object> entry : values.entrySet()) {
-                addFormValue(form, entry.getKey(), entry.getValue(), null);
+            Map<String, BeanPair> values = getValuesFromBeanParam(params[p.getIndex()],
FormParam.class);
+            for (Map.Entry<String, BeanPair> entry : values.entrySet()) {
+                addFormValue(form, entry.getKey(), entry.getValue().getValue(), entry.getValue().getAnns());
             }
         }
         
@@ -577,11 +577,11 @@ public class ClientProxyImpl extends AbstractClient implements
             }
         }
         for (Parameter p : beanParams) {
-            Map<String, Object> values = getValuesFromBeanParam(params[p.getIndex()],
HeaderParam.class);
-            for (Map.Entry<String, Object> entry : values.entrySet()) {
+            Map<String, BeanPair> values = getValuesFromBeanParam(params[p.getIndex()],
HeaderParam.class);
+            for (Map.Entry<String, BeanPair> entry : values.entrySet()) {
                 if (entry.getValue() != null) {
                     headers.add(entry.getKey(), 
-                                convertParamValue(entry.getValue(), getParamAnnotations(m,
p)));
+                                convertParamValue(entry.getValue().getValue(), entry.getValue().getAnns()));
                 }
             }
         }
@@ -607,12 +607,13 @@ public class ClientProxyImpl extends AbstractClient implements
             }
         }
         for (Parameter p : beanParams) {
-            Map<String, Object> values = getValuesFromBeanParam(params[p.getIndex()],
CookieParam.class);
-            for (Map.Entry<String, Object> entry : values.entrySet()) {
+            Map<String, BeanPair> values = getValuesFromBeanParam(params[p.getIndex()],
CookieParam.class);
+            for (Map.Entry<String, BeanPair> entry : values.entrySet()) {
                 if (entry.getValue() != null) {
                     headers.add(HttpHeaders.COOKIE, 
                                 entry.getKey() + "=" 
-                                + convertParamValue(entry.getValue(), getParamAnnotations(m,
p)));
+                                + convertParamValue(entry.getValue().getValue(), 
+                                                    entry.getValue().getAnns()));
                 }
             }
         }
@@ -794,5 +795,20 @@ public class ClientProxyImpl extends AbstractClient implements
         }
         
     }
+
+    private static class BeanPair {
+        private Object value;
+        private Annotation[] anns;
+        public BeanPair(Object value, Annotation[] anns) {
+            this.value = value;
+            this.anns = anns;
+        }
+        public Object getValue() {
+            return value;
+        }
+        public Annotation[] getAnns() {
+            return anns;
+        }
+    }
     
 }


Mime
View raw message