cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1537551 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
Date Thu, 31 Oct 2013 16:52:45 GMT
Author: sergeyb
Date: Thu Oct 31 16:52:45 2013
New Revision: 1537551

URL: http://svn.apache.org/r1537551
Log:
RequestDispatcherProvider should add prefix and extensions to the context paths when possible

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java?rev=1537551&r1=1537550&r2=1537551&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
Thu Oct 31 16:52:45 2013
@@ -88,6 +88,8 @@ public class RequestDispatcherProvider e
     private boolean saveParametersAsAttributes;
     private boolean logRedirects;
     private boolean strictPathCheck;
+    private String locationPrefix;
+    private String resourceExtension;
     
     private MessageContext mc; 
 
@@ -115,7 +117,9 @@ public class RequestDispatcherProvider e
         if (simpleName.length() > 1) {
             sb.append(simpleName.substring(1));
         }
-        return DEFAULT_LOCATION_PREFIX + sb.toString() + DEFAULT_RESOURCE_EXTENSION;  
+        String thePrefix = locationPrefix == null ? DEFAULT_LOCATION_PREFIX : locationPrefix;
+        String theExtension = resourceExtension == null ? DEFAULT_RESOURCE_EXTENSION : resourceExtension;
+        return thePrefix + sb.toString() + theExtension;  
     }
     
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
@@ -232,11 +236,26 @@ public class RequestDispatcherProvider e
             }
         }
         
-        Object resourcePathProp = (String)mc.get(MESSAGE_RESOURCE_PATH_PROPERTY);
-        return resourcePathProp != null ? resourcePathProp.toString() : null;
+        return getPathFromMessageContext();
         
     }
     
+    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);
+            }
+            return sb.toString();
+        }
+        return null;
+    }
+    
     private String getRequestPath() {
         Message inMessage = PhaseInterceptorChain.getCurrentMessage().getExchange().getInMessage();
         return (String)inMessage.get(Message.REQUEST_URI);



Mime
View raw message