Author: alessio.soldano(a)jboss.com
Date: 2013-02-26 11:32:57 -0500 (Tue, 26 Feb 2013)
New Revision: 17346
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java
Log:
[JBWS-3603] Fix client configuration for Dispatch instances
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2013-02-25
14:16:05 UTC (rev 17345)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ProviderImpl.java 2013-02-26
16:32:57 UTC (rev 17346)
@@ -28,15 +28,18 @@
import java.util.Map;
import java.util.concurrent.Executor;
+import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
import javax.xml.ws.Endpoint;
import javax.xml.ws.EndpointContext;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.Service.Mode;
import javax.xml.ws.spi.Invoker;
import javax.xml.ws.spi.ServiceDelegate;
@@ -44,6 +47,7 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.jaxws.DispatchImpl;
import org.apache.cxf.jaxws.ServiceImpl;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.jboss.ws.api.configuration.AbstractClientFeature;
@@ -480,11 +484,28 @@
super(b, url, name, cls, f);
}
+ @Override
protected <T> T createPort(QName portName, EndpointReferenceType epr,
Class<T> serviceEndpointInterface,
WebServiceFeature... features) {
T port = super.createPort(portName, epr, serviceEndpointInterface, features);
- Binding binding = ((BindingProvider)port).getBinding();
- Client client = ClientProxy.getClient(port);
+ setupClient(port, features);
+ return port;
+ }
+
+ @Override
+ public <T> Dispatch<T> createDispatch(QName portName,
+ Class<T> type,
+ JAXBContext context,
+ Mode mode,
+ WebServiceFeature... features) {
+ Dispatch<T> dispatch = super.createDispatch(portName, type, context, mode,
features);
+ setupClient(dispatch, features);
+ return dispatch;
+ }
+
+ protected void setupClient(Object obj, WebServiceFeature... features) {
+ Binding binding = ((BindingProvider)obj).getBinding();
+ Client client = obj instanceof DispatchImpl<?> ?
((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj);
client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding));
if (jbossModulesEnv) { //optimization for avoiding checking for a server config
when we know for sure we're out-of-container
ServerConfig sc = getServerConfig();
@@ -501,13 +522,11 @@
if (features != null) {
for (WebServiceFeature f : features) {
if (f instanceof AbstractClientFeature) {
- ((AbstractClientFeature)f).initialize(port);
+ ((AbstractClientFeature)f).initialize(obj);
}
}
}
- return port;
}
-
}
//lazy get the server config (and try once per classloader only)
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 2013-02-25
14:16:05 UTC (rev 17345)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/CXFClientConfigurer.java 2013-02-26
16:32:57 UTC (rev 17346)
@@ -27,6 +27,7 @@
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.jaxws.DispatchImpl;
import org.jboss.ws.common.configuration.ConfigHelper;
import org.jboss.wsf.spi.metadata.config.ClientConfig;
@@ -42,15 +43,20 @@
private static final String JBOSSWS_CXF_CLIENT_CONF_PROPS =
"jbossws.cxf.client.conf.props";
@Override
- public void setConfigProperties(Object proxy, String configFile, String configName) {
+ public void setConfigProperties(Object client, String configFile, String configName)
{
ClientConfig config = readConfig(configFile, configName);
- Client client = ClientProxy.getClient(proxy);
- cleanupPreviousProps(client);
+ Client cxfClient;
+ if (client instanceof DispatchImpl<?>) {
+ cxfClient = ((DispatchImpl<?>)client).getClient();
+ } else {
+ cxfClient = ClientProxy.getClient(client);
+ }
+ cleanupPreviousProps(cxfClient);
Map<String, String> props = config.getProperties();
if (props != null && !props.isEmpty()) {
- savePropList(client, props);
+ savePropList(cxfClient, props);
}
- setConfigProperties(client, props);
+ setConfigProperties(cxfClient, props);
}
public void setConfigProperties(Client client, Map<String, String> properties)
{