cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1491869 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/ rt/frontend/jax...
Date Tue, 11 Jun 2013 16:33:56 GMT
Author: sergeyb
Date: Tue Jun 11 16:33:55 2013
New Revision: 1491869

URL: http://svn.apache.org/r1491869
Log:
Merged revisions 1491803,1491831,1491866 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1491803 | sergeyb | 2013-06-11 15:11:42 +0100 (Tue, 11 Jun 2013) | 1 line
  
  [CXF-5073] Fixing the recursion issue with the static/early resource resolution
........
  r1491831 | sergeyb | 2013-06-11 16:12:21 +0100 (Tue, 11 Jun 2013) | 1 line
  
  [CXF-5073] Fixing checkstyle issues
........
  r1491866 | sergeyb | 2013-06-11 17:26:46 +0100 (Tue, 11 Jun 2013) | 1 line
  
  [CXF-5073] Some more fixes to avoid endless recursions
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1491803-1491866

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=1491869&r1=1491868&r2=1491869&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Tue Jun 11 16:33:55 2013
@@ -275,4 +275,8 @@ public class ClassResourceInfo extends B
     public void setParent(ClassResourceInfo parent) {
         this.parent = parent;
     }
+    
+    public ClassResourceInfo getParent() {
+        return parent;
+    }
 }

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1491869&r1=1491868&r2=1491869&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Tue Jun 11 16:33:55 2013
@@ -270,7 +270,8 @@ public final class ResourceUtils {
                     if (enableStatic) {
                         ClassResourceInfo subCri = cri.findResource(subClass, subClass);
                         if (subCri == null) {
-                            subCri = subClass == cri.getServiceClass() ? cri
+                            ClassResourceInfo ancestor = getAncestorWithSameServiceClass(cri,
subClass);
+                            subCri = ancestor != null ? ancestor
                                      : createClassResourceInfo(subClass, subClass, cri, false,
enableStatic,
                                                                cri.getBus());
                         }
@@ -285,6 +286,16 @@ public final class ResourceUtils {
         cri.setMethodDispatcher(md);
     }
     
+    private static ClassResourceInfo getAncestorWithSameServiceClass(ClassResourceInfo parent,
Class<?> subClass) {
+        if (parent == null) {
+            return null;
+        }
+        if (parent.getServiceClass() == subClass) {
+            return parent;
+        }
+        return getAncestorWithSameServiceClass(parent.getParent(), subClass);
+    }
+    
     public static Constructor<?> findResourceConstructor(Class<?> resourceClass,
boolean perRequest) {
         List<Constructor<?>> cs = new LinkedList<Constructor<?>>();
         for (Constructor<?> c : resourceClass.getConstructors()) {
@@ -552,12 +563,22 @@ public final class ResourceUtils {
         }
         
         for (ClassResourceInfo sub : resource.getSubResources()) {
-            if (sub != resource) {
+            if (!isRecursiveSubResource(resource, sub)) {
                 getAllTypesForResource(sub, types, jaxbOnly);
             }
         }
     }
     
+    private static boolean isRecursiveSubResource(ClassResourceInfo parent, ClassResourceInfo
sub) {
+        if (parent == null) {
+            return false;
+        }
+        if (parent == sub) {
+            return true;
+        }
+        return isRecursiveSubResource(parent.getParent(), sub);
+    }
+    
     private static void checkJaxbType(Class<?> type, 
                                       Type genericType, 
                                       ResourceTypes types,

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java?rev=1491869&r1=1491868&r2=1491869&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
Tue Jun 11 16:33:55 2013
@@ -23,6 +23,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.feature.Feature;
@@ -180,6 +183,16 @@ public class JAXRSClientFactoryBeanTest 
                      WebClient.client(store2).getCurrentURI().toString());
     }
     
+    @Test 
+    public void testComplexProxy() throws Exception {
+        IProductResource productResource = JAXRSClientFactory.create("http://localhost:9000",

+                                                                     IProductResource.class);
+        assertNotNull(productResource);
+        IPartsResource parts = productResource.getParts();
+        assertNotNull(parts);
+        IProductResource productResourceElement = parts.elementAt("1");
+        assertNotNull(productResourceElement);
+    }
     
     private class TestFeature extends AbstractFeature {
         private TestInterceptor testInterceptor;
@@ -217,5 +230,15 @@ public class JAXRSClientFactoryBeanTest 
     }
     
 
+    public interface IProductResource {
+        @Path("/parts")
+        IPartsResource getParts();
+    }
     
-}
\ No newline at end of file
+    public interface IPartsResource {
+        @Path("/{i}/")
+        IProductResource elementAt(@PathParam("i") String i);
+        String get();
+    }
+
+}

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java?rev=1491869&r1=1491868&r2=1491869&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
Tue Jun 11 16:33:55 2013
@@ -26,6 +26,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.jaxrs.Customer;
@@ -117,4 +120,40 @@ public class ResourceUtilsTest extends A
         assertTrue(types.containsKey(Book.class));
         assertTrue(types.containsKey(Chapter.class));
     }
+    @Test
+    public void testGetAllJaxbClasses2() {
+        ClassResourceInfo cri1 = 
+            ResourceUtils.createClassResourceInfo(IProductResource.class, IProductResource.class,
true, true);
+        Map<Class<?>, Type> types = 
+            ResourceUtils.getAllRequestResponseTypes(Collections.singletonList(cri1), true)
+                .getAllTypes();
+        assertEquals(2, types.size());
+        assertTrue(types.containsKey(Book.class));
+        assertTrue(types.containsKey(Chapter.class));
+    }
+    
+    public interface IProductResource {
+        @Path("/parts")
+        IPartsResource getParts();
+    }
+    
+    public interface IPartsResource {
+        @Path("/{i}/")
+        IPartsResource2 elementAt(@PathParam("i") String i);
+        @Path("/parts")
+        IPartsResource getParts();
+        @Path("/products")
+        IProductResource getProducts();
+        @Path("chapter")
+        Chapter get();
+    }
+    
+    public interface IPartsResource2 {
+        @Path("/{i}/")
+        IPartsResource elementAt(@PathParam("i") String i);
+        @Path("/products")
+        IProductResource getProducts();
+        @GET
+        Book get();
+    }
 }



Mime
View raw message