cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1492132 - in /cxf/branches/2.5.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 Wed, 12 Jun 2013 10:15:45 GMT
Author: sergeyb
Date: Wed Jun 12 10:15:45 2013
New Revision: 1492132

URL: http://svn.apache.org/r1492132
Log:
Merged revisions 1491923 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1491923 | sergeyb | 2013-06-11 20:43:47 +0100 (Tue, 11 Jun 2013) | 24 lines
  
  Merged revisions 1491869 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
  
  ................
    r1491869 | sergeyb | 2013-06-11 17:33:55 +0100 (Tue, 11 Jun 2013) | 17 lines
    
    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.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
    cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1491869
  Merged /cxf/trunk:r1491803-1491866
  Merged /cxf/branches/2.6.x-fixes:r1491923

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

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=1492132&r1=1492131&r2=1492132&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Wed Jun 12 10:15:45 2013
@@ -128,14 +128,11 @@ public class ClassResourceInfo extends A
         SubresourceKey key = new SubresourceKey(typedClass, instanceClass);
         ClassResourceInfo cri = subResources.get(key);
         if (cri == null && !enableStatic) {
-            cri = ResourceUtils.createClassResourceInfo(typedClass, instanceClass, false,
enableStatic);
+            cri = ResourceUtils.createClassResourceInfo(typedClass, instanceClass, this,
false, enableStatic);
             if (cri != null) {
                 ClassResourceInfo tmpCri = subResources.putIfAbsent(key, cri);
                 if (tmpCri != null) {
                     cri = tmpCri;
-                    if (cri != this) {
-                        cri.setParent(this);
-                    }
                 }
             }
         }
@@ -146,9 +143,6 @@ public class ClassResourceInfo extends A
         subResources.putIfAbsent(new SubresourceKey(cri.getResourceClass(), 
                                             cri.getServiceClass()),
                                  cri);
-        if (cri != this) {
-            cri.setParent(this);
-        }
     }
     
     public Collection<ClassResourceInfo> getSubResources() {
@@ -294,7 +288,11 @@ public class ClassResourceInfo extends A
         return resourceProvider != null && resourceProvider.isSingleton();
     }
 
-    void setParent(ClassResourceInfo parent) {
+    public void setParent(ClassResourceInfo parent) {
         this.parent = parent;
     }
+    
+    public ClassResourceInfo getParent() {
+        return parent;
+    }
 }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1492132&r1=1492131&r2=1492132&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Wed Jun 12 10:15:45 2013
@@ -195,11 +195,18 @@ public final class ResourceUtils {
 
     }
     
-    
     public static ClassResourceInfo createClassResourceInfo(
         final Class<?> rClass, final Class<?> sClass, boolean root, boolean enableStatic)
{
+        return createClassResourceInfo(rClass, sClass, null, root, enableStatic);
+    }
+    
+    public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass,

+                                                            final Class<?> sClass,
+                                                            ClassResourceInfo parent,
+                                                            boolean root, 
+                                                            boolean enableStatic) {
         ClassResourceInfo cri  = new ClassResourceInfo(rClass, sClass, root, enableStatic);
-
+        cri.setParent(parent);
         if (root) {
             URITemplate t = URITemplate.createTemplate(cri.getPath());
             cri.setURITemplate(t);
@@ -226,8 +233,9 @@ public final class ResourceUtils {
                     if (enableStatic) {
                         ClassResourceInfo subCri = cri.findResource(subClass, subClass);
                         if (subCri == null) {
-                            subCri = subClass == cri.getServiceClass() ? cri
-                                     : createClassResourceInfo(subClass, subClass, false,
enableStatic);
+                            ClassResourceInfo ancestor = getAncestorWithSameServiceClass(cri,
subClass);
+                            subCri = ancestor != null ? ancestor
+                                     : createClassResourceInfo(subClass, subClass, cri, false,
enableStatic);
                         }
                         
                         if (subCri != null) {
@@ -240,6 +248,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()) {
@@ -511,12 +529,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.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java?rev=1492132&r1=1492131&r2=1492132&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
Wed Jun 12 10:15:45 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.interceptor.Fault;
@@ -179,6 +182,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;
@@ -216,5 +229,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.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java?rev=1492132&r1=1492131&r2=1492132&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
Wed Jun 12 10:15:45 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();
+    }
 }

Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java?rev=1492132&r1=1492131&r2=1492132&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
Wed Jun 12 10:15:45 2013
@@ -66,6 +66,7 @@ public interface BookSubresource {
     
     @POST
     @Path("/subresource3")
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     Book getTheBook3(@FormParam("id") String id,
                      @FormParam("name") List<String> nameParts) throws BookNotFoundFault;
     



Mime
View raw message