cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1501230 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
Date Tue, 09 Jul 2013 12:55:26 GMT
Author: sergeyb
Date: Tue Jul  9 12:55:25 2013
New Revision: 1501230

URL: http://svn.apache.org/r1501230
Log:
Merged revisions 1501222 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

................
  r1501222 | sergeyb | 2013-07-09 13:33:24 +0100 (Tue, 09 Jul 2013) | 9 lines
  
  Merged revisions 1501213 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1501213 | sergeyb | 2013-07-09 13:13:39 +0100 (Tue, 09 Jul 2013) | 1 line
    
    [CXF-5104] Releasing contexts when CXF continuations are used, using PhaseInterceptorChain
when the call is resumed directly on a subresource instance
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1501222
  Merged /cxf/trunk:r1501213

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

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=1501230&r1=1501229&r2=1501230&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
Tue Jul  9 12:55:25 2013
@@ -95,19 +95,17 @@ public class JAXRSInvoker extends Abstra
             return handleFault(ex, exchange.getInMessage());
         } finally {
             boolean suspended = exchange.getInMessage().getInterceptorChain().getState()
== State.SUSPENDED;
+            if (exchange.isOneWay() || suspended) {
+                ProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
+            }
             if (!suspended) {
-                if (exchange.isOneWay()) {
-                    ProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
-                }
                 if (!isServiceObjectRequestScope(exchange.getInMessage())) {
                     provider.releaseInstance(exchange.getInMessage(), rootInstance);
-                } else {
-                    persistRoots(exchange, rootInstance, provider);
                 }
             } else {
-                persistRoots(exchange, rootInstance, provider);
                 exchange.put(REQUEST_WAS_SUSPENDED, true);
             }
+            persistRoots(exchange, rootInstance, provider);
         }
     }
 
@@ -126,25 +124,24 @@ public class JAXRSInvoker extends Abstra
         
         if (!wasSuspended) {
             pushOntoStack(ori, ClassHelper.getRealClass(resourceObject), exchange.getInMessage());
-                    
-            if (cri.isRoot()) {
-                Object realResourceObject = ClassHelper.getRealObject(resourceObject);
-                JAXRSUtils.injectParameters(ori, realResourceObject,
-                                         exchange.getInMessage());
-    
-                InjectionUtils.injectContexts(realResourceObject,
-                                              ori.getClassResourceInfo(),
-                                              exchange.getInMessage());
-                
-                ProviderInfo<?> appProvider = 
-                    (ProviderInfo<?>)exchange.getEndpoint().get(Application.class.getName());
-                if (appProvider != null) {
-                    InjectionUtils.injectContexts(appProvider.getProvider(),
-                                                  appProvider,
-                                                  exchange.getInMessage());
-                }
+        }            
+        if (cri.isRoot()) {
+            Object realResourceObject = ClassHelper.getRealObject(resourceObject);
+            JAXRSUtils.injectParameters(ori, realResourceObject,
+                                        exchange.getInMessage());
+    
+            InjectionUtils.injectContexts(realResourceObject,
+                                          ori.getClassResourceInfo(),
+                                          exchange.getInMessage());
                 
+            ProviderInfo<?> appProvider = 
+                (ProviderInfo<?>)exchange.getEndpoint().get(Application.class.getName());
+            if (appProvider != null) {
+                InjectionUtils.injectContexts(appProvider.getProvider(),
+                                              appProvider,
+                                              exchange.getInMessage());
             }
+                
         }
         
 

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java?rev=1501230&r1=1501229&r2=1501230&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookContinuationStore.java
Tue Jul  9 12:55:25 2013
@@ -19,7 +19,7 @@
 
 package org.apache.cxf.systest.jaxrs;
 
-
+import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -27,14 +27,19 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-import javax.annotation.Resource;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.continuations.Continuation;
 import org.apache.cxf.continuations.ContinuationProvider;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.impl.UriInfoImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptorChain;
 
 @Path("/bookstore")
 public class BookContinuationStore {
@@ -45,7 +50,7 @@ public class BookContinuationStore {
     private Executor executor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.SECONDS,
                                         new ArrayBlockingQueue<Runnable>(10));
     
-    @Resource
+    @Context
     private MessageContext context;
     
     public BookContinuationStore() {
@@ -55,7 +60,10 @@ public class BookContinuationStore {
     @GET
     @Path("/books/{id}")
     public String getBookDescription(@PathParam("id") String id) {
-        
+        URI uri = context.getUriInfo().getAbsolutePath();
+        if (!uri.toString().contains("/books/")) {
+            throw new WebApplicationException(500);
+        }
         return handleContinuationRequest(id);
         
     }
@@ -128,8 +136,21 @@ public class BookContinuationStore {
     }
     
     private Continuation getContinuation(String name) {
-        
-        //System.out.println("Getting continuation for " + name);
+        ContinuationProvider provider = 
+            (ContinuationProvider)context.get(ContinuationProvider.class.getName());
+        if (provider == null) {
+            Message m = PhaseInterceptorChain.getCurrentMessage();
+            UriInfo uriInfo = new UriInfoImpl(m);
+            if (uriInfo.getAbsolutePath().toString().contains("/books/subresources/")) {
+                // when we suspend a CXF continuation from a sub-resource, the invocation
will
+                // return directly to that object - and sub-resources do not have contexts
supported
+                // by default - so we just need to depend on PhaseInterceptorChain
+                provider = (ContinuationProvider)m.get(ContinuationProvider.class.getName());
+            } 
+        }
+        if (provider == null) {
+            throw new WebApplicationException(500);
+        }
         
         synchronized (suspended) {
             Continuation suspendedCont = suspended.remove(name);
@@ -138,8 +159,6 @@ public class BookContinuationStore {
             }
         }
         
-        ContinuationProvider provider = 
-            (ContinuationProvider)context.get(ContinuationProvider.class.getName());
         return provider.getContinuation();
     }
     



Mime
View raw message