cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r786873 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Sat, 20 Jun 2009 18:08:07 GMT
Author: sergeyb
Date: Sat Jun 20 18:08:06 2009
New Revision: 786873

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

........
  r786850 | sergeyb | 2009-06-20 17:24:47 +0100 (Sat, 20 Jun 2009) | 1 line
  
  JAXRS: avoiding loading model resource class if it is already been loaded elsewhere (ex,
OSGI)
........

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/AbstractJAXRSFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jun 20 18:08:06 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786850

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Jun 20 18:08:06 2009
@@ -1 +1 @@
-/cxf/trunk:1-782619,782728-782730,783097,783294,783396,784059,784181-784184,784893-785866,785932,786142,786271-786272,786395,786512,786514,786582-786583,786638
+/cxf/trunk:1-782619,782728-782730,783097,783294,783396,784059,784181-784184,784893-785866,785932,786142,786271-786272,786395,786512,786514,786582-786583,786638,786850

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=786873&r1=786872&r2=786873&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Sat Jun 20 18:08:06 2009
@@ -247,6 +247,10 @@
         serviceFactory.setUserResources(resources);
     }
     
+    public void setModelBeansWithServiceClass(List<UserResource> resources, Class<?>
sClass) {
+        serviceFactory.setUserResourcesWithServiceClass(resources, sClass);
+    }
+    
     public void setModelRef(String modelRef) {
         List<UserResource> resources = ResourceUtils.getUserResources(modelRef);
         if (resources != null) {
@@ -254,4 +258,12 @@
         }
     }
     
+    public void setModelRefWithServiceClass(String modelRef, Class<?> sClass) {
+        List<UserResource> resources = ResourceUtils.getUserResources(modelRef);
+        if (resources != null) {
+            serviceFactory.setUserResourcesWithServiceClass(resources, sClass);
+        }
+    }
+    
+    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=786873&r1=786872&r2=786873&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
Sat Jun 20 18:08:06 2009
@@ -131,10 +131,7 @@
     }
     
     public void setUserResources(List<UserResource> resources) {
-        Map<String, UserResource> map = new HashMap<String, UserResource>();
-        for (UserResource ur : resources) {
-            map.put(ur.getName(), ur);
-        }
+        Map<String, UserResource> map = userResourcesAsMap(resources);
         for (UserResource ur : resources) {
             if (ur.getPath() != null) {
                 ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(map, ur, true);
@@ -145,6 +142,22 @@
         }
     }
     
+    public void setUserResourcesWithServiceClass(List<UserResource> resources, Class<?>
sClass) {
+        Map<String, UserResource> map = userResourcesAsMap(resources);
+        ClassResourceInfo cri = ResourceUtils.createServiceClassResourceInfo(map, sClass,
true);
+        if (cri != null) {
+            classResourceInfos.add(cri);
+        }
+    }
+    
+    private Map<String, UserResource> userResourcesAsMap(List<UserResource> resources)
{
+        Map<String, UserResource> map = new HashMap<String, UserResource>();
+        for (UserResource ur : resources) {
+            map.put(ur.getName(), ur);
+        }
+        return map;
+    }
+    
     protected ClassResourceInfo createResourceInfo(Class cls, boolean isRoot) {
         ClassResourceInfo classResourceInfo = 
             ResourceUtils.createClassResourceInfo(cls, cls, isRoot, enableStatic);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=786873&r1=786872&r2=786873&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Sat Jun 20 18:08:06 2009
@@ -119,6 +119,46 @@
 
     }
     
+    public static ClassResourceInfo createServiceClassResourceInfo(
+        Map<String, UserResource> resources, Class<?> sClass, boolean isRoot)
{
+        UserResource model = resources.get(sClass.getName());
+        if (model == null) {
+            throw new RuntimeException("Resource class " + sClass.getName() + " has no model
info");
+        }
+        ClassResourceInfo cri  = new ClassResourceInfo(sClass, sClass, isRoot, true, true);
+        URITemplate t = URITemplate.createTemplate(model.getPath());
+        cri.setURITemplate(t);
+        MethodDispatcher md = new MethodDispatcher();
+        Map<String, UserOperation> ops = model.getOperationsAsMap();
+        for (Method m : cri.getServiceClass().getMethods()) {
+            UserOperation op = ops.get(m.getName());
+            if (op == null || op.getName() == null) {
+                continue;
+            }
+            OperationResourceInfo ori = 
+                new OperationResourceInfo(m, cri, URITemplate.createTemplate(op.getPath()),
+                                          op.getVerb(), op.getConsumes(), op.getProduces(),
+                                          op.getParameters());
+            String rClassName = m.getReturnType().getName();
+            if (op.getVerb() == null) {
+                if (resources.containsKey(rClassName)) {
+                    ClassResourceInfo subCri = rClassName.equals(model.getName()) ? cri 
+                        : createServiceClassResourceInfo(resources, m.getReturnType(), false);
+                    if (subCri != null) {
+                        cri.addSubClassResourceInfo(subCri);
+                        md.bind(ori, m);
+                    }
+                }
+            } else {
+                md.bind(ori, m);
+            }
+        }
+        cri.setMethodDispatcher(md);
+        return checkMethodDispatcher(cri) ? cri : null;
+
+    }
+    
+    
     public static ClassResourceInfo createClassResourceInfo(
         final Class<?> rClass, final Class<?> sClass, boolean root, boolean enableStatic)
{
         ClassResourceInfo cri  = new ClassResourceInfo(rClass, sClass, root, enableStatic);

Modified: cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java?rev=786873&r1=786872&r2=786873&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
Sat Jun 20 18:08:06 2009
@@ -80,6 +80,9 @@
             
             sf.setModelBeans(ur, ur2);
             
+            String modelRef = "classpath:/org/apache/cxf/systest/jaxrs/resources/resources2.xml";
+            sf.setModelRefWithServiceClass(modelRef, BookStoreNoAnnotationsInterface.class);
+            sf.setServiceBeans(new BookStoreNoAnnotationsImpl());
             sf.create();
 
         }
@@ -110,6 +113,12 @@
     }
     
     @Test
+    public void testGetBookInterface123() throws Exception {
+        getAndCompare("http://localhost:9080/bookstore2/books/123",
+                      "application/xml", 200);
+    }
+    
+    @Test
     public void testGetChapter() throws Exception {
         
         getAndCompareChapter("http://localhost:9080/bookstoreNoAnnotations/books/123/chapter",



Mime
View raw message