Author: alessio.soldano(a)jboss.com
Date: 2010-05-13 14:32:02 -0400 (Thu, 13 May 2010)
New Revision: 12230
Modified:
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java
Log:
[JBPAPP-4309] Cleaning default Bus in ServiceObjectFactory and improving port match in
ServiceRefStubPropertyConfigurer
Modified:
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2010-05-13
18:31:54 UTC (rev 12229)
+++
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2010-05-13
18:32:02 UTC (rev 12230)
@@ -100,7 +100,7 @@
UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
//Reset bus before constructing Service
- BusFactory.setThreadDefaultBus(null);
+ BusFactory.setDefaultBus(null);
Bus bus = BusFactory.getThreadDefaultBus();
//Add extension to configure stub properties using the UnifiedServiceRefMetaData
Configurer configurer = bus.getExtension(Configurer.class);
Modified:
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java 2010-05-13
18:31:54 UTC (rev 12229)
+++
stack/cxf/branches/jbossws-cxf-3.1.2/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java 2010-05-13
18:32:02 UTC (rev 12230)
@@ -24,8 +24,11 @@
import java.util.HashMap;
import java.util.Map;
+import javax.xml.namespace.QName;
+
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.jboss.logging.Logger;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
@@ -49,10 +52,6 @@
public void configureBean(Object beanInstance)
{
- if (beanInstance instanceof JaxWsProxyFactoryBean)
- {
- configureJaxWsProxyFactoryBean((JaxWsProxyFactoryBean)beanInstance);
- }
if (delegate != null)
{
delegate.configureBean(beanInstance);
@@ -61,9 +60,19 @@
public void configureBean(String name, Object beanInstance)
{
- if (beanInstance instanceof JaxWsProxyFactoryBean)
+ if (name != null && beanInstance instanceof JaxWsProxyFactoryBean)
{
- configureJaxWsProxyFactoryBean((JaxWsProxyFactoryBean)beanInstance);
+ QName portQName = null;
+ try
+ {
+ String portName = name.substring(0,
name.indexOf(".jaxws-client.proxyFactory"));
+ portQName = QName.valueOf(portName);
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(this.getClass()).warn("Unable to retrieve port QName
from '" + name + "', trying matching port using endpoint interface name
only.");
+ }
+ configureJaxWsProxyFactoryBean(portQName, (JaxWsProxyFactoryBean)beanInstance);
}
if (delegate != null)
{
@@ -71,21 +80,28 @@
}
}
- private synchronized void configureJaxWsProxyFactoryBean(JaxWsProxyFactoryBean
proxyFactory)
+ private synchronized void configureJaxWsProxyFactoryBean(QName portQName,
JaxWsProxyFactoryBean proxyFactory)
{
- Map<String, Object> properties = new HashMap<String, Object>();
- for (UnifiedPortComponentRefMetaData pcRef : serviceRefMD.getPortComponentRefs())
+ Class<?> clazz = proxyFactory.getServiceClass();
+ UnifiedPortComponentRefMetaData upcmd = serviceRefMD.getPortComponentRef(clazz !=
null ? clazz.getName() : null, portQName);
+ if (upcmd != null)
{
- String sei = pcRef.getServiceEndpointInterface();
- if (sei != null &&
sei.equals(proxyFactory.getServiceClass().getName()))
- {
- for (UnifiedStubPropertyMetaData prop : pcRef.getStubProperties())
- {
- properties.put(prop.getPropName(), prop.getPropValue());
- }
- }
+ setProperties(proxyFactory, upcmd);
}
- proxyFactory.setProperties(properties);
}
+
+ private void setProperties(JaxWsProxyFactoryBean proxyFactory,
UnifiedPortComponentRefMetaData upcmd)
+ {
+ Map<String, Object> properties = proxyFactory.getProperties();
+ if (properties == null)
+ {
+ properties = new HashMap<String, Object>();
+ proxyFactory.setProperties(properties);
+ }
+ for (UnifiedStubPropertyMetaData prop : upcmd.getStubProperties())
+ {
+ properties.put(prop.getPropName(), prop.getPropValue());
+ }
+ }
}