cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1174404 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
Date Thu, 22 Sep 2011 21:55:24 GMT
Author: sergeyb
Date: Thu Sep 22 21:55:24 2011
New Revision: 1174404

URL: http://svn.apache.org/viewvc?rev=1174404&view=rev
Log:
[CXF-3743] Configuration of extension and language mappings in a non spring servlet

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=1174404&r1=1174403&r2=1174404&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
Thu Sep 22 21:55:24 2011
@@ -56,6 +56,8 @@ public class CXFNonSpringJaxrsServlet ex
     private static final String OUT_INTERCEPTORS_PARAM = "jaxrs.outInterceptors";
     private static final String IN_INTERCEPTORS_PARAM = "jaxrs.inInterceptors";
     private static final String SERVICE_SCOPE_PARAM = "jaxrs.scope";
+    private static final String EXTENSIONS_PARAM = "jaxrs.extensions";
+    private static final String LANGUAGES_PARAM = "jaxrs.languages";
     private static final String SCHEMAS_PARAM = "jaxrs.schemaLocations";
     private static final String SERVICE_SCOPE_SINGLETON = "singleton";
     private static final String SERVICE_SCOPE_REQUEST = "prototype";
@@ -99,9 +101,37 @@ public class CXFNonSpringJaxrsServlet ex
         for (Map.Entry<Class, ResourceProvider> entry : resourceProviders.entrySet())
{
             bean.setResourceProvider(entry.getKey(), entry.getValue());
         }
+        setExtensions(bean, servletConfig);
+        
         bean.create();
     }
 
+    protected void setExtensions(JAXRSServerFactoryBean bean, ServletConfig servletConfig)
{
+        doSetExtensions(bean, servletConfig, EXTENSIONS_PARAM);
+        doSetExtensions(bean, servletConfig, LANGUAGES_PARAM);
+    }
+    
+    protected void doSetExtensions(JAXRSServerFactoryBean bean, ServletConfig servletConfig,

+            String extParamName) {
+        String extParam = servletConfig.getInitParameter(extParamName);
+        if (extParam != null) {
+            Map<Object, Object> extensions = new HashMap<Object, Object>();
+            String[] pairs = extParam.split(" ");
+            for (String pair : pairs) {
+                String[] value = pair.split(":");
+                if (value.length == 2) {
+                    extensions.put(value[0].trim(), value[1].trim());
+                }
+            }
+            if (EXTENSIONS_PARAM.equals(extParamName)) {
+                bean.setExtensionMappings(extensions);
+            } else {
+                bean.setLanguageMappings(extensions);
+            }
+        }
+        
+    }
+    
     protected void setAllInterceptors(JAXRSServerFactoryBean bean, ServletConfig servletConfig)
{
         setInterceptors(bean, servletConfig, OUT_INTERCEPTORS_PARAM);
         setInterceptors(bean, servletConfig, IN_INTERCEPTORS_PARAM);
@@ -266,6 +296,7 @@ public class CXFNonSpringJaxrsServlet ex
         String ignoreParam = servletConfig.getInitParameter(IGNORE_APP_PATH_PARAM);
         JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, MessageUtils.isTrue(ignoreParam));
         setAllInterceptors(bean, servletConfig);
+        setExtensions(bean, servletConfig);
         bean.setBus(getBus());
         bean.create();
     }



Mime
View raw message