cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r642367 - in /incubator/cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 28 Mar 2008 20:27:52 GMT
Author: dkulp
Date: Fri Mar 28 13:27:50 2008
New Revision: 642367

URL: http://svn.apache.org/viewvc?rev=642367&view=rev
Log:
Fix some issues where the specified service beans were not being used after a sub resource
was hit

Modified:
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
Fri Mar 28 13:27:50 2008
@@ -48,13 +48,15 @@
     public JAXRSInvoker(List<Object> resourceObjects) {
         this.resourceObjects = resourceObjects;
     }
-    
     public Object invoke(Exchange exchange, Object request) {
+        return invoke(exchange, request, resourceObjects);
+    }    
+    public Object invoke(Exchange exchange, Object request, List<Object> resources)
{
         OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
 
         ClassResourceInfo cri = ori.getClassResourceInfo();
         Method m = cri.getMethodDispatcher().getMethod(ori);
-        Object resourceObject = getServiceObject(exchange);
+        Object resourceObject = getServiceObject(exchange, resources);
         
         if (cri.isRoot()) {
             JAXRSUtils.injectHttpContextValues(resourceObject, 
@@ -96,8 +98,8 @@
                     result = ((Object[])result)[0];
                 } 
             }
-            resourceObjects = new ArrayList<Object>();
-            resourceObjects.add(result);
+            List<Object> newResourceObjects = new ArrayList<Object>();
+            newResourceObjects.add(result);
         
             Message msg = exchange.getInMessage();
             MultivaluedMap<String, String> values = new MetadataMap<String, String>();
                
@@ -128,21 +130,24 @@
             List<Object> newParams = JAXRSUtils.processParameters(subOri, values, msg);
             msg.setContent(List.class, newParams);
             
-            return this.invoke(exchange, newParams);
+            return this.invoke(exchange, newParams, newResourceObjects);
         }
         
         return result;
     }    
     
     public Object getServiceObject(Exchange exchange) {
+        return getServiceObject(exchange, resourceObjects);
+    }
+    public Object getServiceObject(Exchange exchange, List<Object> resources) {
         Object serviceObject = null;
         
         OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
         ClassResourceInfo cri = ori.getClassResourceInfo();
         
-        if (resourceObjects != null) {
+        if (resources != null) {
             Class c  = cri.getResourceClass();
-            for (Object resourceObject : resourceObjects) {
+            for (Object resourceObject : resources) {
                 if (c.isInstance(resourceObject)) {
                     serviceObject = resourceObject;
                 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
Fri Mar 28 13:27:50 2008
@@ -137,12 +137,10 @@
         //TODO: Using information from annotation to determine which lifecycle provider to
use
         ResourceProvider rp = resourceProviders.get(c);
         if (rp != null) {
-            rp.setResourceClass(c);
             classResourceInfo.setResourceProvider(rp);
         } else {
             //default lifecycle is per-request
-            rp = new PerRequestResourceProvider();
-            rp.setResourceClass(c);
+            rp = new PerRequestResourceProvider(c);
             classResourceInfo.setResourceProvider(rp);  
         }
         

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
Fri Mar 28 13:27:50 2008
@@ -22,12 +22,10 @@
 public class PerRequestResourceProvider implements ResourceProvider {
     private Class<?> resourceClass;
    
-    public PerRequestResourceProvider() {
+    public PerRequestResourceProvider(Class<?> clazz) {
+        resourceClass = clazz;
     }
     
-    public void setResourceClass(Class<?> clazz) {
-        this.resourceClass = clazz;        
-    }
 
     public Object getInstance() {  
         Object resourceInstance = null;

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/ResourceProvider.java
Fri Mar 28 13:27:50 2008
@@ -22,5 +22,5 @@
 public interface ResourceProvider {
 
     Object getInstance();
-    void setResourceClass(Class<?> clazz);
+    //void setResourceClass(Class<?> clazz);
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/SingletonResourceProvider.java
Fri Mar 28 13:27:50 2008
@@ -20,28 +20,14 @@
 package org.apache.cxf.jaxrs.lifecycle;
 
 public class SingletonResourceProvider implements ResourceProvider {
-    private Class<?> resourceClass;
     private Object resourceInstance;
     
-    public SingletonResourceProvider() {
+    public SingletonResourceProvider(Object o) { 
+        resourceInstance = o;
     }
     
-    public void setResourceClass(Class<?> clazz) {
-        this.resourceClass = clazz;        
-    }
 
     public Object getInstance() {
-        if (resourceInstance != null) {
-            return resourceInstance;
-        }
-        
-        try {
-            resourceInstance = resourceClass.newInstance();
-        } catch (InstantiationException ex) {
-            //TODO
-        } catch (IllegalAccessException ex) {
-            //TODO
-        }        
         return resourceInstance;
     }
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
Fri Mar 28 13:27:50 2008
@@ -29,7 +29,8 @@
         JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
         sf.setResourceClasses(AtomBookStore.class);
         //default lifecycle is per-request, change it to singleton
-        sf.setResourceProvider(AtomBookStore.class, new SingletonResourceProvider());
+        sf.setResourceProvider(AtomBookStore.class, 
+                               new SingletonResourceProvider(new AtomBookStore()));
         sf.setAddress("http://localhost:9080/");
 
         sf.create();        

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java
Fri Mar 28 13:27:50 2008
@@ -46,7 +46,8 @@
     
     @BeforeClass
     public static void startServers() throws Exception {
-        assertTrue("server did not launch correctly", launchServer(AtomBookServer.class));
+        assertTrue("server did not launch correctly",
+                   launchServer(AtomBookServer.class));
     }
     
     @Test

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
Fri Mar 28 13:27:50 2008
@@ -29,7 +29,8 @@
         JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
         sf.setResourceClasses(BookStore.class);
         //default lifecycle is per-request, change it to singleton
-        sf.setResourceProvider(BookStore.class, new SingletonResourceProvider());
+        sf.setResourceProvider(BookStore.class,
+                               new SingletonResourceProvider(new BookStore()));
         sf.setAddress("http://localhost:9080/");
 
         sf.create();        

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Fri Mar 28 13:27:50 2008
@@ -40,7 +40,8 @@
 
     @BeforeClass
     public static void startServers() throws Exception {
-        assertTrue("server did not launch correctly", launchServer(BookServer.class));
+        assertTrue("server did not launch correctly",
+                   launchServer(BookServer.class));
     }
     
     @Test

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java?rev=642367&r1=642366&r2=642367&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
Fri Mar 28 13:27:50 2008
@@ -37,7 +37,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerResourceCreatedOutside.class, true));
+                   launchServer(BookServerResourceCreatedOutside.class));
     }
     
     @Test



Mime
View raw message