cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r889753 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/
Date Fri, 11 Dec 2009 18:33:07 GMT
Author: sergeyb
Date: Fri Dec 11 18:33:04 2009
New Revision: 889753

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

........
  r889740 | sergeyb | 2009-12-11 18:18:03 +0000 (Fri, 11 Dec 2009) | 1 line
  
  JAXRS : better nested beans support in WADLGenerator
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 11 18:33:04 2009
@@ -1 +1 @@
-/cxf/trunk:889426,889595,889601
+/cxf/trunk:889426,889595,889601,889740

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=889753&r1=889752&r2=889753&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Fri Dec 11 18:33:04 2009
@@ -309,18 +309,30 @@
     private void writeParam(StringBuilder sb, Parameter pm, OperationResourceInfo ori) {
         Class<?> type = ori.getMethodToInvoke().getParameterTypes()[pm.getIndex()];
         if (!"".equals(pm.getName())) {
-            doWriteParam(sb, pm, type);
+            doWriteParam(sb, pm, type, pm.getName());
         } else {
-            Map<Parameter, Class<?>> pms = InjectionUtils.getParametersFromBeanClass(type,
pm.getType());
-            for (Map.Entry<Parameter, Class<?>> entry : pms.entrySet()) {   
-                doWriteParam(sb, entry.getKey(), entry.getValue());
+            doWriteBeanParam(sb, type, pm, null);
+        }
+    }
+    
+    private void doWriteBeanParam(StringBuilder sb, Class<?> type, Parameter pm, String
parentName) {
+        Map<Parameter, Class<?>> pms = InjectionUtils.getParametersFromBeanClass(type,
pm.getType());
+        for (Map.Entry<Parameter, Class<?>> entry : pms.entrySet()) {
+            String name = entry.getKey().getName();
+            if (parentName != null) {
+                name = parentName + "." + name;
+            }
+            if (InjectionUtils.isPrimitive(entry.getValue())) {
+                doWriteParam(sb, entry.getKey(), entry.getValue(), name);
+            } else {
+                doWriteBeanParam(sb, entry.getValue(), entry.getKey(), name);
             }
         }
     }
     
-    private void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type) {
+    private void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type, String
paramName) {
         
-        sb.append("<param name=\"").append(pm.getName()).append("\" ");
+        sb.append("<param name=\"").append(paramName).append("\" ");
         String style = ParameterType.PATH == pm.getType() ? "template" 
                        : ParameterType.FORM == pm.getType() ? "query"
                        : pm.getType().toString().toLowerCase();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=889753&r1=889752&r2=889753&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
Fri Dec 11 18:33:04 2009
@@ -50,16 +50,18 @@
     
     @POST
     @Path("books/{bookid}")
+    //CHECKSTYLE:OFF
     public Book addBook(@PathParam("id") int id,
                         @PathParam("bookid") int bookId,
                         @MatrixParam("mid") int matrixId,
                         @HeaderParam("hid") int headerId,
                         @CookieParam("cid") int cookieId,
+                        @QueryParam("provider.bar") int queryParam,
                         @Context HttpHeaders headers,
                         Book b) {
         return new Book(1);
     }
-    
+    //CHECKSTYLE:ON
     @Path("booksubresource")
     public Book getBook() {
         return new Book(1);
@@ -85,6 +87,50 @@
     public static class QueryBean {
         private int a;
         private int b;
+        private QueryBean2 bean;
+        
+        public int getA() {
+            return a;
+        }
+        
+        public int getB() {
+            return b;
+        }
+        
+        public QueryBean2 getC() {
+            return bean;
+        }
+        
+        public void setC(QueryBean2 c) {
+            bean = c;
+        }
+    }
+    
+    public static class QueryBean2 {
+        private int a;
+        private int b;
+        private QueryBean3 bean;
+        
+        public int getA() {
+            return a;
+        }
+        
+        public int getB() {
+            return b;
+        }
+        
+        public QueryBean3 getD() {
+            return bean;
+        }
+        
+        public void setD(QueryBean3 d) {
+            bean = d;
+        }
+    }
+    
+    public static class QueryBean3 {
+        private int a;
+        private int b;
         
         public int getA() {
             return a;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=889753&r1=889752&r2=889753&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Fri Dec 11 18:33:04 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.jaxrs.model.wadl;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
@@ -82,14 +84,14 @@
         assertNotNull(r);
         assertEquals(WadlGenerator.WADL_TYPE.toString(),
                      r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
-//        File f = new File("test.xml");
-//        f.delete();
-//        f.createNewFile();
-//        System.out.println(f.getAbsolutePath());
-//        FileOutputStream fos = new FileOutputStream(f);
-//        fos.write(r.getEntity().toString().getBytes());
-//        fos.flush();
-//        fos.close();
+        File f = new File("test.xml");
+        f.delete();
+        f.createNewFile();
+        System.out.println(f.getAbsolutePath());
+        FileOutputStream fos = new FileOutputStream(f);
+        fos.write(r.getEntity().toString().getBytes());
+        fos.flush();
+        fos.close();
     }
     
     @Test
@@ -165,9 +167,13 @@
         
         paramsEls = DOMUtils.getChildrenWithName(requestEls.get(0), 
                                                  WadlGenerator.WADL_NS, "param");
-        assertEquals(2, paramsEls.size());
+        assertEquals(6, paramsEls.size());
         checkParameter(paramsEls.get(0), "a", "query");
         checkParameter(paramsEls.get(1), "b", "query");
+        checkParameter(paramsEls.get(2), "c.a", "query");
+        checkParameter(paramsEls.get(3), "c.b", "query");
+        checkParameter(paramsEls.get(4), "c.d.a", "query");
+        checkParameter(paramsEls.get(5), "c.d.b", "query");
         
         paramsEls = DOMUtils.getChildrenWithName(resourceEls.get(2), 
                                                                WadlGenerator.WADL_NS, "param");



Mime
View raw message