cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1448177 - in /cxf/trunk/rt/transports/http/src: main/java/org/apache/cxf/transport/servlet/ServletController.java test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java
Date Wed, 20 Feb 2013 14:17:47 GMT
Author: dkulp
Date: Wed Feb 20 14:17:47 2013
New Revision: 1448177

URL: http://svn.apache.org/r1448177
Log:
Make sure the context classloader is set for REST requests.  Simplify things a bit.

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=1448177&r1=1448176&r2=1448177&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
Wed Feb 20 14:17:47 2013
@@ -158,19 +158,21 @@ public class ServletController {
                             generateNotFound(request, res);
                         }
                         return false;
-                    }  else { // the request should be a restful service request
-                        updateDestination(request, d);
-                        invokeDestination(request, res, d);
                     }
                 }
-            } else {
-                EndpointInfo ei = d.getEndpointInfo();
+            }
+            if (d != null) {
                 Bus bus = d.getBus();
                 ClassLoaderHolder orig = null;
                 try {
-                    ResourceManager manager = bus.getExtension(ResourceManager.class);
-                    if (manager != null) {
-                        ClassLoader loader = manager.resolveResource("", ClassLoader.class);
+                    if (bus != null) {
+                        ClassLoader loader = bus.getExtension(ClassLoader.class);
+                        if (loader == null) {
+                            ResourceManager manager = bus.getExtension(ResourceManager.class);
+                            if (manager != null) {
+                                loader = manager.resolveResource("", ClassLoader.class);
+                            }
+                        }
                         if (loader != null) {
                             //need to set the context classloader to the loader of the bundle
                             orig = ClassLoaderUtils.setThreadContextClassloader(loader);
@@ -178,21 +180,24 @@ public class ServletController {
                     }
                     updateDestination(request, d);
                     
-                    QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
-                    if ("GET".equals(request.getMethod()) 
-                        && !StringUtils.isEmpty(request.getQueryString()) 
-                        && queryHandlerRegistry != null) {
-                        
-                        String ctxUri = request.getPathInfo();
-                        String baseUri = request.getRequestURL().toString()
-                            + "?" + request.getQueryString();
-
-                        QueryHandler selectedHandler = 
-                            findQueryHandler(queryHandlerRegistry, ei, ctxUri, baseUri);
-                        
-                        if (selectedHandler != null) {
-                            respondUsingQueryHandler(selectedHandler, res, ei, ctxUri, baseUri);
-                            return true;
+                    if (bus != null) {
+                        QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
+                        if ("GET".equals(request.getMethod()) 
+                            && !StringUtils.isEmpty(request.getQueryString()) 
+                            && queryHandlerRegistry != null) {
+                            
+                            EndpointInfo ei = d.getEndpointInfo();
+                            String ctxUri = request.getPathInfo();
+                            String baseUri = request.getRequestURL().toString()
+                                + "?" + request.getQueryString();
+    
+                            QueryHandler selectedHandler = 
+                                findQueryHandler(queryHandlerRegistry, ei, ctxUri, baseUri);
+                            
+                            if (selectedHandler != null) {
+                                respondUsingQueryHandler(selectedHandler, res, ei, ctxUri,
baseUri);
+                                return true;
+                            }
                         }
                     }
                     invokeDestination(request, res, d);

Modified: cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java?rev=1448177&r1=1448176&r2=1448177&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java
(original)
+++ cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/servlet/ServletControllerTest.java
Wed Feb 20 14:17:47 2013
@@ -135,6 +135,8 @@ public class ServletControllerTest exten
         AbstractHTTPDestination dest = EasyMock.createMock(AbstractHTTPDestination.class);
         registry.checkRestfulRequest("");
         EasyMock.expectLastCall().andReturn(dest).atLeastOnce();
+        dest.getBus();
+        EasyMock.expectLastCall().andReturn(null).anyTimes();
         dest.getMessageObserver();
         EasyMock.expectLastCall().andReturn(EasyMock.createMock(MessageObserver.class)).atLeastOnce();
         



Mime
View raw message