Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0B41E10DED for ; Mon, 10 Mar 2014 22:11:11 +0000 (UTC) Received: (qmail 54574 invoked by uid 500); 10 Mar 2014 22:11:07 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 54519 invoked by uid 500); 10 Mar 2014 22:11:06 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 54474 invoked by uid 99); 10 Mar 2014 22:11:01 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Mar 2014 22:11:01 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5710C93DCE7; Mon, 10 Mar 2014 22:11:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: <6d34c1b9fa714c82a8894f2b9c4587b6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Updating JAXRS ClientProxy to use bean parameter annotations Date: Mon, 10 Mar 2014 22:11:01 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/master d9a1164c3 -> 635578a9d 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/635578a9 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/635578a9 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/635578a9 Branch: refs/heads/master Commit: 635578a9d0a4cc1087795c26479585998d4a828f Parents: d9a1164 Author: Sergey Beryozkin Authored: Mon Mar 10 22:10:40 2014 +0000 Committer: Sergey Beryozkin Committed: Mon Mar 10 22:10:40 2014 +0000 ---------------------------------------------------------------------- .../cxf/jaxrs/client/ClientProxyImpl.java | 51 +++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/635578a9/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java ---------------------------------------------------------------------- diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java index 0d1f148..e6690e8 100644 --- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java +++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java @@ -460,18 +460,18 @@ public class ClientProxyImpl extends AbstractClient implements } } for (Parameter p : beanParams) { - Map values = getValuesFromBeanParam(params[p.getIndex()], QueryParam.class); - for (Map.Entry entry : values.entrySet()) { + Map values = getValuesFromBeanParam(params[p.getIndex()], QueryParam.class); + for (Map.Entry entry : values.entrySet()) { if (entry.getValue() != null) { addMatrixQueryParamsToBuilder(ub, entry.getKey(), ParameterType.QUERY, - null, entry.getValue()); + entry.getValue().getAnns(), entry.getValue().getValue()); } } } } - private Map getValuesFromBeanParam(Object bean, Class annClass) { - Map values = new HashMap(); + private Map getValuesFromBeanParam(Object bean, Class annClass) { + Map values = new HashMap(); for (Method m : bean.getClass().getMethods()) { Annotation annotation = m.getAnnotation(annClass); @@ -481,7 +481,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 } @@ -503,11 +503,11 @@ public class ClientProxyImpl extends AbstractClient implements } } for (Parameter p : beanParams) { - Map values = getValuesFromBeanParam(params[p.getIndex()], MatrixParam.class); - for (Map.Entry entry : values.entrySet()) { + Map values = getValuesFromBeanParam(params[p.getIndex()], MatrixParam.class); + for (Map.Entry entry : values.entrySet()) { if (entry.getValue() != null) { addMatrixQueryParamsToBuilder(ub, entry.getKey(), ParameterType.MATRIX, - null, entry.getValue()); + entry.getValue().getAnns(), entry.getValue().getValue()); } } } @@ -525,9 +525,9 @@ public class ClientProxyImpl extends AbstractClient implements addFormValue(form, p.getName(), params[p.getIndex()], getParamAnnotations(m, p)); } for (Parameter p : beanParams) { - Map values = getValuesFromBeanParam(params[p.getIndex()], FormParam.class); - for (Map.Entry entry : values.entrySet()) { - addFormValue(form, entry.getKey(), entry.getValue(), null); + Map values = getValuesFromBeanParam(params[p.getIndex()], FormParam.class); + for (Map.Entry entry : values.entrySet()) { + addFormValue(form, entry.getKey(), entry.getValue().getValue(), entry.getValue().getAnns()); } } @@ -579,11 +579,11 @@ public class ClientProxyImpl extends AbstractClient implements } } for (Parameter p : beanParams) { - Map values = getValuesFromBeanParam(params[p.getIndex()], HeaderParam.class); - for (Map.Entry entry : values.entrySet()) { + Map values = getValuesFromBeanParam(params[p.getIndex()], HeaderParam.class); + for (Map.Entry entry : values.entrySet()) { if (entry.getValue() != null) { headers.add(entry.getKey(), - convertParamValue(entry.getValue(), getParamAnnotations(m, p))); + convertParamValue(entry.getValue().getValue(), entry.getValue().getAnns())); } } } @@ -609,12 +609,13 @@ public class ClientProxyImpl extends AbstractClient implements } } for (Parameter p : beanParams) { - Map values = getValuesFromBeanParam(params[p.getIndex()], CookieParam.class); - for (Map.Entry entry : values.entrySet()) { + Map values = getValuesFromBeanParam(params[p.getIndex()], CookieParam.class); + for (Map.Entry 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())); } } } @@ -805,4 +806,18 @@ 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; + } + } }