Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 1512a124d -> d0e8cde61
Copying minor updates to CXFNonSpringJaxrsServlet 3.0.x made as part of bigger changes on the trunk Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d0e8cde6 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d0e8cde6 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d0e8cde6 Branch: refs/heads/3.0.x-fixes Commit: d0e8cde61fbace404e8872c08c48618b3dc4f0d0 Parents: 1512a12 Author: Sergey Beryozkin <sberyoz...@talend.com> Authored: Wed Dec 17 16:16:19 2014 +0000 Committer: Sergey Beryozkin <sberyoz...@talend.com> Committed: Wed Dec 17 16:16:19 2014 +0000 ---------------------------------------------------------------------- .../jaxrs/servlet/CXFNonSpringJaxrsServlet.java | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/d0e8cde6/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java index 9ac7616..ca9aea7 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java @@ -39,6 +39,7 @@ import org.apache.cxf.common.classloader.ClassLoaderUtils; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.PrimitiveUtils; import org.apache.cxf.common.util.StringUtils; +import org.apache.cxf.feature.Feature; import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.interceptor.Interceptor; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; @@ -66,6 +67,7 @@ public class CXFNonSpringJaxrsServlet extends CXFNonSpringServlet { private static final String IGNORE_APP_PATH_PARAM = "jaxrs.application.address.ignore"; private static final String SERVICE_CLASSES_PARAM = "jaxrs.serviceClasses"; private static final String PROVIDERS_PARAM = "jaxrs.providers"; + private static final String FEATURES_PARAM = "jaxrs.features"; private static final String OUT_INTERCEPTORS_PARAM = "jaxrs.outInterceptors"; private static final String OUT_FAULT_INTERCEPTORS_PARAM = "jaxrs.outFaultInterceptors"; private static final String IN_INTERCEPTORS_PARAM = "jaxrs.inInterceptors"; @@ -132,10 +134,32 @@ public class CXFNonSpringJaxrsServlet extends CXFNonSpringServlet { bean.setResourceProvider(entry.getKey(), entry.getValue()); } setExtensions(bean, servletConfig); - + List<? extends Feature> features = getFeatures(servletConfig, splitChar); + bean.setFeatures(features); bean.create(); } + protected List<? extends Feature> getFeatures(ServletConfig servletConfig, String splitChar) + throws ServletException { + + String featuresList = servletConfig.getInitParameter(FEATURES_PARAM); + if (featuresList == null) { + return Collections.< Feature >emptyList(); + } + String[] classNames = StringUtils.split(featuresList, splitChar); + List< Feature > features = new ArrayList< Feature >(); + for (String cName : classNames) { + Map<String, List<String>> props = new HashMap<String, List<String>>(); + String theName = getClassNameAndProperties(cName, props); + if (theName.length() != 0) { + Class<?> cls = loadClass(theName); + if (Feature.class.isAssignableFrom(cls)) { + features.add((Feature)createSingletonInstance(cls, props, servletConfig)); + } + } + } + return features; + } protected String getParameterSplitChar(ServletConfig servletConfig) { String param = servletConfig.getInitParameter(PARAMETER_SPLIT_CHAR); if (!StringUtils.isEmpty(param) && SPACE_PARAMETER_SPLIT_CHAR.equals(param.trim())) {