cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Reordering the way request dispatcher provider checks resources to ensure the more dynamic settings are prefferred
Date Tue, 01 Dec 2015 16:31:57 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes c66b1a181 -> 088dcdf8c


Reordering the way request dispatcher provider checks resources to ensure the more dynamic
settings are prefferred


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/088dcdf8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/088dcdf8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/088dcdf8

Branch: refs/heads/3.1.x-fixes
Commit: 088dcdf8c7a3626adf650e80b98a9efd51d48653
Parents: c66b1a1
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Dec 1 16:30:33 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Dec 1 16:31:32 2015 +0000

----------------------------------------------------------------------
 .../provider/RequestDispatcherProvider.java     | 70 +++++++++++---------
 1 file changed, 39 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/088dcdf8/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
index 4422d81..a2d239f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
@@ -238,49 +238,57 @@ public class RequestDispatcherProvider extends AbstractConfigurableProvider
     }
     
     String getResourcePath(Class<?> cls, Object o) {
-        if (useClassNames) {
-            return getClassResourceName(cls);     
+        String currentResourcePath = getPathFromMessageContext();
+        if (currentResourcePath != null) {
+            return currentResourcePath;
         }
         
-        String name = cls.getName();
-        if (cls.isEnum()) {
-            String enumResource = enumResources.get(o);
-            if (enumResource != null) {
-                return enumResource;
+        if (!resourcePaths.isEmpty()) {
+            
+            String path = getRequestPath();
+            for (Map.Entry<String, String> entry : resourcePaths.entrySet()) {
+                if (path.endsWith(entry.getKey())) {
+                    return entry.getValue();
+                }
             }
-            name += "." + o.toString();     
-        }
-        
-        String clsResourcePath = classResources.get(name);
-        if (clsResourcePath != null) {
-            return clsResourcePath;
         }
-        if (resourcePath != null) {
-            return resourcePath;
-        }
-        String path = getRequestPath();
-        for (Map.Entry<String, String> entry : resourcePaths.entrySet()) {
-            if (path.endsWith(entry.getKey())) {
-                return entry.getValue();
+        if (!enumResources.isEmpty() || !classResources.isEmpty()) {
+            String name = cls.getName();
+            if (cls.isEnum()) {
+                String enumResource = enumResources.get(o);
+                if (enumResource != null) {
+                    return enumResource;
+                }
+                name += "." + o.toString();     
+            }
+            
+            String clsResourcePath = classResources.get(name);
+            if (clsResourcePath != null) {
+                return clsResourcePath;
             }
         }
         
-        return getPathFromMessageContext();
+        if (useClassNames) {
+            return getClassResourceName(cls);     
+        }
         
+        return resourcePath;
     }
     
     private String getPathFromMessageContext() {
-        Object resourcePathProp = (String)mc.get(MESSAGE_RESOURCE_PATH_PROPERTY);
-        if (resourcePathProp != null) {
-            StringBuilder sb = new StringBuilder();
-            if (locationPrefix != null) {
-                sb.append(locationPrefix);
-            }
-            sb.append(resourcePathProp.toString());
-            if (resourceExtension != null) {
-                sb.append(resourceExtension);
+        if (mc != null) {
+            Object resourcePathProp = (String)mc.get(MESSAGE_RESOURCE_PATH_PROPERTY);
+            if (resourcePathProp != null) {
+                StringBuilder sb = new StringBuilder();
+                if (locationPrefix != null) {
+                    sb.append(locationPrefix);
+                }
+                sb.append(resourcePathProp.toString());
+                if (resourceExtension != null) {
+                    sb.append(resourceExtension);
+                }
+                return sb.toString();
             }
-            return sb.toString();
         }
         return null;
     }


Mime
View raw message