Author: sergeyb
Date: Fri Sep 30 12:39:16 2011
New Revision: 1177632
URL: http://svn.apache.org/viewvc?rev=1177632&view=rev
Log:
Merged revisions 1177631 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1177631 | sergeyb | 2011-09-30 13:36:47 +0100 (Fri, 30 Sep 2011) | 1 line
[CXF-3797] Better support for optional or repeating query parametets, thanks
to Christos Fragoulides
........
Modified:
cxf/branches/2.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 30 12:39:16 2011
@@ -1 +1 @@
-/cxf/trunk:1177618
+/cxf/trunk:1177618,1177631
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1177632&r1=1177631&r2=1177632&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
(original)
+++
cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Fri Sep 30 12:39:16 2011
@@ -105,6 +105,7 @@ public class SourceGenerator {
private static final Map<String, Class<?>> HTTP_METHOD_ANNOTATIONS;
private static final Map<String, Class<?>> PARAM_ANNOTATIONS;
private static final Set<String> RESOURCE_LEVEL_PARAMS;
+ private static final Map<String, String> AUTOBOXED_PRIMITIVES_MAP;
static {
HTTP_METHOD_ANNOTATIONS = new HashMap<String, Class<?>>();
@@ -124,6 +125,15 @@ public class SourceGenerator {
RESOURCE_LEVEL_PARAMS = new HashSet<String>();
RESOURCE_LEVEL_PARAMS.add("template");
RESOURCE_LEVEL_PARAMS.add("matrix");
+
+ AUTOBOXED_PRIMITIVES_MAP = new HashMap<String, String>();
+ AUTOBOXED_PRIMITIVES_MAP.put(byte.class.getSimpleName(),
Byte.class.getSimpleName());
+ AUTOBOXED_PRIMITIVES_MAP.put(short.class.getSimpleName(),
Short.class.getSimpleName());
+ AUTOBOXED_PRIMITIVES_MAP.put(int.class.getSimpleName(),
Integer.class.getSimpleName());
+ AUTOBOXED_PRIMITIVES_MAP.put(long.class.getSimpleName(),
Long.class.getSimpleName());
+ AUTOBOXED_PRIMITIVES_MAP.put(float.class.getSimpleName(),
Float.class.getSimpleName());
+ AUTOBOXED_PRIMITIVES_MAP.put(double.class.getSimpleName(),
Double.class.getSimpleName());
+ AUTOBOXED_PRIMITIVES_MAP.put(boolean.class.getSimpleName(),
Boolean.class.getSimpleName());
}
private Comparator<String> importsComparator;
@@ -718,8 +728,14 @@ public class SourceGenerator {
writeAnnotation(sbCode, imports, paramAnn, name, false, false);
sbCode.append(" ");
}
+ boolean isRepeating =
Boolean.valueOf(paramEl.getAttribute("repeating"));
String type = getPrimitiveType(paramEl);
- if (Boolean.valueOf(paramEl.getAttribute("repeating"))) {
+ if (paramAnn == QueryParam.class
+ && (isRepeating ||
!Boolean.valueOf(paramEl.getAttribute("required")))
+ && AUTOBOXED_PRIMITIVES_MAP.containsKey(type)) {
+ type = AUTOBOXED_PRIMITIVES_MAP.get(type);
+ }
+ if (isRepeating) {
addImport(imports, List.class.getName());
type = "List<" + type + ">";
}
Modified:
cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1177632&r1=1177631&r2=1177632&view=diff
==============================================================================
---
cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
(original)
+++
cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
Fri Sep 30 12:39:16 2011
@@ -97,9 +97,9 @@
<param name="hid" style="header" type="xs:int">
<doc>header param</doc>
</param>
- <param name="provider.bar" style="query" type="xs:int"/>
+ <param name="provider.bar" style="query" required="true" type="xs:int"/>
<param name="a" style="query" repeating="true" type="xs:string"/>
-
+ <param name="b" style="query" repeating="true" type="xs:long"/>
<representation mediaType="application/xml" element="prefix1:theBook2">
<doc>InputBook</doc>
</representation>