Author: alessio.soldano(a)jboss.com
Date: 2009-11-20 07:30:36 -0500 (Fri, 20 Nov 2009)
New Revision: 11139
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
Log:
[JBWS-2822] Reading cxf spring configuration from jbossws-cxf.xml also when getting client
through webserviceref object factory
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2009-11-20
12:29:00 UTC (rev 11138)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2009-11-20
12:30:36 UTC (rev 11139)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, 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.
*
@@ -21,11 +21,14 @@
*/
package org.jboss.wsf.stack.cxf.client;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.configuration.Configurer;
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.Name;
@@ -35,22 +38,15 @@
import javax.naming.spi.ObjectFactory;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
-import javax.xml.ws.spi.ServiceDelegate;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Hashtable;
-
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
/**
* This ServiceObjectFactory reconstructs a javax.xml.ws.Service
@@ -98,10 +94,22 @@
// Unmarshall the UnifiedServiceRef
UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+
+ Bus bus;
+ URL cxfConfig = getCXFConfiguration(serviceRef.getVfsRoot());
+ if (cxfConfig != null)
+ {
+ SpringBusFactory busFactory = new SpringBusFactory();
+ bus = busFactory.createBus(cxfConfig);
+ BusFactory.setDefaultBus(bus);
+ }
+ else
+ {
+ //Reset bus before constructing Service
+ BusFactory.setThreadDefaultBus(null);
+ bus = BusFactory.getThreadDefaultBus();
+ }
- //Reset bus before constructing Service
- BusFactory.setThreadDefaultBus(null);
- Bus bus = BusFactory.getThreadDefaultBus();
//Add extension to configure stub properties using the UnifiedServiceRefMetaData
Configurer configurer = bus.getExtension(Configurer.class);
bus.setExtension(new ServiceRefStubPropertyConfigurer(serviceRef, configurer),
Configurer.class);
@@ -231,5 +239,25 @@
return sref;
}
+
+ public URL getCXFConfiguration(UnifiedVirtualFile vfsRoot)
+ {
+ URL url = null;
+ try
+ {
+ url = vfsRoot.findChild("WEB-INF/jbossws-cxf.xml").toURL();
+ }
+ catch (Exception e) {}
+
+ if (url == null)
+ {
+ try
+ {
+ url = vfsRoot.findChild("META-INF/jbossws-cxf.xml").toURL();
+ }
+ catch (Exception e) {}
+ }
+ return url;
+ }
}
Show replies by date