cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1491803 - in /cxf/trunk/rt: frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rs/client/src/test/java/org/apache/cxf/jaxrs/client/
Date Tue, 11 Jun 2013 14:11:42 GMT
Author: sergeyb
Date: Tue Jun 11 14:11:42 2013
New Revision: 1491803

URL: http://svn.apache.org/r1491803
Log:
[CXF-5073] Fixing the recursion issue with the static/early resource resolution

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=1491803&r1=1491802&r2=1491803&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Tue Jun 11 14:11:42 2013
@@ -286,4 +286,8 @@ public class ClassResourceInfo extends B
     public void setParent(ClassResourceInfo parent) {
         this.parent = parent;
     }
+    
+    public ClassResourceInfo getParent() {
+        return parent;
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1491803&r1=1491802&r2=1491803&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Tue Jun 11 14:11:42 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,7 +563,7 @@ public final class ResourceUtils {
         }
         
         for (ClassResourceInfo sub : resource.getSubResources()) {
-            if (sub != resource) {
+            if (resource != sub) {
                 getAllTypesForResource(sub, types, jaxbOnly);
             }
         }

Modified: cxf/trunk/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java?rev=1491803&r1=1491802&r2=1491803&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
(original)
+++ cxf/trunk/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
Tue Jun 11 14:11:42 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;
@@ -218,4 +231,15 @@ public class JAXRSClientFactoryBeanTest 
     
 
     
+    public interface IProductResource {
+        @Path("/parts")
+        public IPartsResource getParts();
+    }
+    
+    public interface IPartsResource {
+    @Path("/{i}/")
+    public IProductResource elementAt(@PathParam("i") String i);
+        String get();
+    }
+    
 }
\ No newline at end of file



Mime
View raw message