cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1551632 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Date Tue, 17 Dec 2013 17:08:30 GMT
Author: sergeyb
Date: Tue Dec 17 17:08:29 2013
New Revision: 1551632

URL: http://svn.apache.org/r1551632
Log:
Merged revisions 1551612 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1551612 | sergeyb | 2013-12-17 16:41:06 +0000 (Tue, 17 Dec 2013) | 1 line
  
  [CXF-5423] Setting correct bus and loader before the client invocation
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1551612

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1551632&r1=1551631&r2=1551632&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Tue Dec 17 17:08:29 2013
@@ -53,6 +53,10 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
@@ -605,46 +609,60 @@ public class ClientProxyImpl extends Abs
                                        int bodyIndex,
                                        Exchange exchange,
                                        Map<String, Object> invocationContext) throws
Throwable {
-        
-        Message outMessage = createMessage(body, ori.getHttpMethod(), headers, uri, 
-                                           exchange, invocationContext, true);
-        
-        outMessage.getExchange().setOneWay(ori.isOneway());
-        outMessage.setContent(OperationResourceInfo.class, ori);
-        setPlainOperationNameProperty(outMessage, ori.getMethodToInvoke().getName());
-        outMessage.getExchange().put(Method.class, ori.getMethodToInvoke());
-        
-        outMessage.put(Annotation.class.getName(), 
-                       getMethodAnnotations(ori.getAnnotatedMethod(), bodyIndex));
-        
-        if (body != null) {
-            outMessage.put("BODY_INDEX", bodyIndex);
-            outMessage.getInterceptorChain().add(new BodyWriter());
-        }
-
-        Map<String, Object> reqContext = getRequestContext(outMessage);
-        reqContext.put(OperationResourceInfo.class.getName(), ori);
-        reqContext.put("BODY_INDEX", bodyIndex);
-        
-        // execute chain    
-        doRunInterceptorChain(outMessage);
-        
-        Object[] results = preProcessResult(outMessage);
-        if (results != null && results.length == 1) {
-            return results[0];
-        }
-        
-        Object response = null;
+        Bus configuredBus = getConfiguration().getBus();
+        Bus origBus = BusFactory.getAndSetThreadDefaultBus(configuredBus);
+        ClassLoaderHolder origLoader = null;
         try {
-            response = handleResponse(outMessage, ori.getClassResourceInfo().getServiceClass());
-            return response;
-        } catch (Exception ex) {
-            response = ex;
-            throw ex;
+            ClassLoader loader = configuredBus.getExtension(ClassLoader.class);
+            if (loader != null) {
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
+            }
+            Message outMessage = createMessage(body, ori.getHttpMethod(), headers, uri, 
+                                               exchange, invocationContext, true);
+            
+            outMessage.getExchange().setOneWay(ori.isOneway());
+            outMessage.setContent(OperationResourceInfo.class, ori);
+            setPlainOperationNameProperty(outMessage, ori.getMethodToInvoke().getName());
+            outMessage.getExchange().put(Method.class, ori.getMethodToInvoke());
+            
+            outMessage.put(Annotation.class.getName(), 
+                           getMethodAnnotations(ori.getAnnotatedMethod(), bodyIndex));
+            
+            if (body != null) {
+                outMessage.put("BODY_INDEX", bodyIndex);
+                outMessage.getInterceptorChain().add(new BodyWriter());
+            }
+    
+            Map<String, Object> reqContext = getRequestContext(outMessage);
+            reqContext.put(OperationResourceInfo.class.getName(), ori);
+            reqContext.put("BODY_INDEX", bodyIndex);
+            
+            // execute chain    
+            doRunInterceptorChain(outMessage);
+            
+            Object[] results = preProcessResult(outMessage);
+            if (results != null && results.length == 1) {
+                return results[0];
+            }
+            
+            Object response = null;
+            try {
+                response = handleResponse(outMessage, ori.getClassResourceInfo().getServiceClass());
+                return response;
+            } catch (Exception ex) {
+                response = ex;
+                throw ex;
+            } finally {
+                completeExchange(response, outMessage.getExchange(), true);
+            }
         } finally {
-            completeExchange(response, outMessage.getExchange(), true);
+            if (origLoader != null) {
+                origLoader.reset();
+            }
+            if (origBus != configuredBus) {
+                BusFactory.setThreadDefaultBus(origBus);
+            }
         }
-        
     }
     
     @Override

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1551632&r1=1551631&r2=1551632&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Tue Dec 17 17:08:29 2013
@@ -50,7 +50,10 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -1042,10 +1045,26 @@ public class WebClient extends AbstractC
                                            Exchange exchange,
                                            Map<String, Object> invContext) {
     //CHECKSTYLE:ON    
-        Message m = finalizeMessage(httpMethod, headers, body, requestClass, inType, 
-                                    respClass, outType, exchange, invContext);
-        doRunInterceptorChain(m);
-        return doResponse(m, respClass, outType);
+        Bus configuredBus = getConfiguration().getBus();
+        Bus origBus = BusFactory.getAndSetThreadDefaultBus(configuredBus);
+        ClassLoaderHolder origLoader = null;
+        try {
+            ClassLoader loader = configuredBus.getExtension(ClassLoader.class);
+            if (loader != null) {
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
+            }
+            Message m = finalizeMessage(httpMethod, headers, body, requestClass, inType,

+                                        respClass, outType, exchange, invContext);
+            doRunInterceptorChain(m);
+            return doResponse(m, respClass, outType);
+        } finally {
+            if (origLoader != null) {
+                origLoader.reset();
+            }
+            if (origBus != configuredBus) {
+                BusFactory.setThreadDefaultBus(origBus);
+            }
+        }    
     }
     
     //CHECKSTYLE:OFF



Mime
View raw message