Repository: cxf Updated Branches: refs/heads/master a77774de4 -> 813321ea2
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/813321ea Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/813321ea Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/813321ea Branch: refs/heads/master Commit: 813321ea28d184188f1591e26629632a34ee4c22 Parents: a77774d Author: Sergey Beryozkin <[email protected]> Authored: Tue Dec 1 16:30:33 2015 +0000 Committer: Sergey Beryozkin <[email protected]> Committed: Tue Dec 1 16:30:33 2015 +0000 ---------------------------------------------------------------------- .../provider/RequestDispatcherProvider.java | 70 +++++++++++--------- 1 file changed, 39 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/813321ea/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; }
