Skip to content
Permalink
Browse files
[CXF-5562] Relaxing the checks when injecting via setters, no need to…
… have a name match

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1568083 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Sergey Beryozkin committed Feb 13, 2014
1 parent 6cd1772 commit 25422135a679309f89004e7ef8192ff648ade2f5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
@@ -82,7 +82,7 @@ private void setParamMethods(Class<?> cls) {
}
for (Annotation a : m.getAnnotations()) {
if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) {
checkParamMethod(m, AnnotationUtils.getAnnotationValue(a));
addParamMethod(m);
break;
}
}
@@ -110,10 +110,4 @@ public List<Field> getParameterFields() {
return paramFields == null ? Collections.<Field>emptyList()
: Collections.unmodifiableList(paramFields);
}

private void checkParamMethod(Method m, String value) {
if (m.getName().equalsIgnoreCase("set" + value)) {
addParamMethod(m);
}
}
}
@@ -469,12 +469,14 @@ private Map<String, Object> getValuesFromBeanParam(Object bean, Class<? extends
Map<String, Object> values = new HashMap<String, Object>();

for (Method m : bean.getClass().getMethods()) {
if (m.getAnnotation(annClass) != null) {
Annotation annotation = m.getAnnotation(annClass);
if (annotation != null) {
try {
String propertyName = m.getName().substring(3);
Method getter = bean.getClass().getMethod("get" + propertyName, new Class[]{});
Object value = getter.invoke(bean, new Object[]{});
values.put(propertyName.toLowerCase(), value);
String annotationValue = AnnotationUtils.getAnnotationValue(annotation);
values.put(annotationValue, value);
} catch (Throwable t) {
// ignore
}
@@ -1580,7 +1580,7 @@ public long getId2() {
return id2;
}

@QueryParam("id2")
@QueryParam("id_2")
public void setId2(long id2) {
this.id2 = id2;
}
@@ -283,7 +283,7 @@ public void testUseParamBeanWebClient2() {
private void doTestUseParamBeanWebClient(String address) {
WebClient wc = WebClient.create(address);
wc.path("100");
wc.query("id2", "20");
wc.query("id_2", "20");
wc.query("id3", "3");
Book book = wc.get(Book.class);
assertEquals(123L, book.getId());

0 comments on commit 2542213

Please sign in to comment.