parse cxf.jaxrs.extensions like it done in CXFNonSpringJaxrsServlet, but
with "," separator
package org.apache.cxf.jaxrs.spring;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
@@ -39,6 +41,8 @@ public abstract class AbstractSpringConfigurationFactory
protected ApplicationContext applicationContext;
@Value("${cxf.jaxrs.server.address:}")
private String jaxrsServerAddress;
+ @Value("${cxf.jaxrs.extensions:}")
+ private String jaxrsExtensions;
protected Server createJaxRsServer() {
@@ -53,6 +57,9 @@ public abstract class AbstractSpringConfigurationFactory
factory.setOutInterceptors(getOutInterceptors());
factory.setOutFaultInterceptors(getOutFaultInterceptors());
factory.setFeatures(getFeatures());
+ if (!StringUtils.isEmpty(jaxrsExtensions)) {
+ factory.setExtensionMappings((Map)parseMapSequence(jaxrsExtensions));
+ }
finalizeFactorySetup(factory);
return factory.create();
}
@@ -90,4 +97,25 @@ public abstract class AbstractSpringConfigurationFactory
protected void finalizeFactorySetup(JAXRSServerFactoryBean factory) {
// complete
}
+ protected static Map<String, String> parseMapSequence(String sequence) {
+ if (sequence != null) {
+ sequence = sequence.trim();
+ Map<String, String> map = new HashMap<>();
+ String[] pairs = sequence.split(",");
+ for (String pair : pairs) {
+ String thePair = pair.trim();
+ if (thePair.length() == 0) {
+ continue;
+ }
+ String[] value = thePair.split("=");
+ if (value.length == 2) {
+ map.put(value[0].trim(), value[1].trim());
+ } else {
+ map.put(thePair, "");
+ }
+ }
+ return map;
+ }
+ return Collections.emptyMap();
+ }
}
