Author: asoldano
Date: 2015-03-10 12:11:57 -0400 (Tue, 10 Mar 2015)
New Revision: 19548
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/FeatureUtils.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
Log:
[JBWS-3875] Allow setting CXF features using properties on client/endpoint configs and in
jboss-webservices.xml
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2015-03-10
09:02:23 UTC (rev 19547)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2015-03-10
16:11:57 UTC (rev 19548)
@@ -236,4 +236,8 @@
@LogMessage(level = WARN)
@Message(id = 24105, value = "Could not create instance of specified
ClientBusSelector: %s")
void couldNotLoadClientBusSelector(String selector, @Cause Throwable cause);
+
+ @LogMessage(level = WARN)
+ @Message(id = 24106, value = "Could not remove previuosly set features on
client: %s")
+ void couldNoRemoveFeaturesOnClient(String feature);
}
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2015-03-10
09:02:23 UTC (rev 19547)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2015-03-10
16:11:57 UTC (rev 19548)
@@ -42,6 +42,7 @@
public static final String CXF_POLICY_ALTERNATIVE_SELECTOR_PROP =
"cxf.policy.alternativeSelector";
public static final String CXF_IN_INTERCEPTORS_PROP =
"cxf.interceptors.in";
public static final String CXF_OUT_INTERCEPTORS_PROP =
"cxf.interceptors.out";
+ public static final String CXF_FEATURES_PROP = "cxf.features";
public static final String CXF_MANAGEMENT_ENABLED =
"cxf.management.enabled";
public static final String CXF_MANAGEMENT_INSTALL_RESPONSE_TIME_INTERCEPTORS =
"cxf.management.installResponseTimeInterceptors";
public static final String CXF_WS_DISCOVERY_ENABLED =
"cxf.ws-discovery.enabled";
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java 2015-03-10
09:02:23 UTC (rev 19547)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java 2015-03-10
16:11:57 UTC (rev 19548)
@@ -86,6 +86,7 @@
public void setConfigProperties(Client client, Map<String, String> properties)
{
client.getEndpoint().putAll(properties);
InterceptorUtils.addInterceptors(client, properties);
+ FeatureUtils.addFeatures(client, client.getBus(), properties);
}
private void savePropList(Client client, Map<String, String> props) {
@@ -102,6 +103,8 @@
InterceptorUtils.removeInterceptors(client.getInInterceptors(),
(String)ep.get(p));
} else if (Constants.CXF_OUT_INTERCEPTORS_PROP.equals(p)) {
InterceptorUtils.removeInterceptors(client.getOutInterceptors(),
(String)ep.get(p));
+ } else if (Constants.CXF_FEATURES_PROP.equals(p)) {
+ Loggers.ROOT_LOGGER.couldNoRemoveFeaturesOnClient((String)ep.get(p));
}
ep.remove(p);
}
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/FeatureUtils.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/FeatureUtils.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/FeatureUtils.java 2015-03-10
16:11:57 UTC (rev 19548)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.interceptor.InterceptorProvider;
+import org.jboss.ws.common.utils.DelegateClassLoader;
+import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
+import org.jboss.wsf.stack.cxf.client.Constants;
+
+/**
+ * Utils methods for adding/removing CXF features
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 10-Mar-2015
+ *
+ */
+public class FeatureUtils
+{
+ public static void addFeatures(InterceptorProvider interceptorProvider, Bus bus,
Map<String, String> properties) {
+ final String features = properties.get(Constants.CXF_FEATURES_PROP);
+ if (features != null) {
+ for (Feature f : createFeatures(features)) {
+ f.initialize(interceptorProvider, bus);
+ }
+ }
+ }
+
+ private static List<Feature> createFeatures(String propValue) {
+ List<Feature> list = new ArrayList<Feature>();
+ StringTokenizer st = new StringTokenizer(propValue, ", ", false );
+ while (st.hasMoreTokens()) {
+ String itc = st.nextToken();
+ Feature feature = (Feature)newInstance(itc);
+ if (feature != null) {
+ list.add(feature);
+ }
+ }
+ return list;
+ }
+
+ private static Object newInstance(String className)
+ {
+ try
+ {
+ ClassLoader loader = new
DelegateClassLoader(ClassLoaderProvider.getDefaultProvider()
+ .getServerIntegrationClassLoader(),
SecurityActions.getContextClassLoader());
+ Class<?> clazz = SecurityActions.loadClass(loader, className);
+ return clazz.newInstance();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+}
Property changes on:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/FeatureUtils.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2015-03-10
09:02:23 UTC (rev 19547)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2015-03-10
16:11:57 UTC (rev 19548)
@@ -66,6 +66,7 @@
import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.client.Constants;
+import org.jboss.wsf.stack.cxf.client.configuration.FeatureUtils;
import org.jboss.wsf.stack.cxf.client.configuration.InterceptorUtils;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.extensions.policy.PolicySetsAnnotationListener;
@@ -159,6 +160,8 @@
policySetsListener = new PolicySetsAnnotationListener(dep.getClassLoader());
bus.getExtension(FactoryBeanListenerManager.class).addListener(policySetsListener);
}
+
+ FeatureUtils.addFeatures(bus, bus, props);
}
private static Map<String, String> getProperties(JBossWebservicesMetaData wsmd)
{
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2015-03-10
09:02:23 UTC (rev 19547)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2015-03-10
16:11:57 UTC (rev 19548)
@@ -44,6 +44,7 @@
import org.jboss.wsf.spi.metadata.config.SOAPAddressRewriteMetadata;
import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
+import org.jboss.wsf.stack.cxf.client.configuration.FeatureUtils;
import org.jboss.wsf.stack.cxf.client.configuration.InterceptorUtils;
@@ -108,6 +109,7 @@
propMap.putAll(epConfProps);
}
InterceptorUtils.addInterceptors(this, epConfProps);
+ FeatureUtils.addFeatures(this, getBus(), epConfProps);
}
//handlers config is done later, as when this methods is called getBinding()
can't
//be used without messing with the servlet destinations due to the endpoint
address