Title: [948] trunk/servicemix-jsr181: Use jax-ws module from xfire

Diff

Modified: trunk/servicemix-jsr181/maven.xml (947 => 948)

--- trunk/servicemix-jsr181/maven.xml	2005-11-28 12:04:44 UTC (rev 947)
+++ trunk/servicemix-jsr181/maven.xml	2005-11-28 12:17:19 UTC (rev 948)
@@ -3,9 +3,9 @@
 <project default="default"
     xmlns:ant="jelly:ant">
 
-  <goal name="default" prereqs="jbi:install"/>
+  <goal name="default" prereqs="jar:install, jbi:install"/>
 
-  <goal name="nightly" prereqs="clean, jbi:install, jbi:deploy"/>
+  <goal name="nightly" prereqs="clean, jar:install, jbi:install, jar:deploy, jbi:deploy"/>
 
   <postGoal name="java:compile">
     <attainGoal name="xbean:generate" />

Modified: trunk/servicemix-jsr181/project.xml (947 => 948)

--- trunk/servicemix-jsr181/project.xml	2005-11-28 12:04:44 UTC (rev 947)
+++ trunk/servicemix-jsr181/project.xml	2005-11-28 12:17:19 UTC (rev 948)
@@ -74,6 +74,14 @@
         </properties>
       </dependency>
       <dependency>
+        <groupId>servicemix</groupId>
+        <artifactId>xfire-jaxws</artifactId>
+        <version>${xfire_version}</version>
+        <properties>
+          <jbi.bundle>true</jbi.bundle>
+        </properties>
+      </dependency>
+      <dependency>
         <groupId>stax</groupId>
         <artifactId>stax-api</artifactId>
         <version>${stax_api_version}</version>

Modified: trunk/servicemix-jsr181/src/main/java/org/servicemix/jsr181/Jsr181Endpoint.java (947 => 948)

--- trunk/servicemix-jsr181/src/main/java/org/servicemix/jsr181/Jsr181Endpoint.java	2005-11-28 12:04:44 UTC (rev 947)
+++ trunk/servicemix-jsr181/src/main/java/org/servicemix/jsr181/Jsr181Endpoint.java	2005-11-28 12:17:19 UTC (rev 948)
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -44,10 +45,10 @@
 import org.codehaus.xfire.annotations.backport175.Backport175WebAnnotations;
 import org.codehaus.xfire.annotations.commons.CommonsWebAttributes;
 import org.codehaus.xfire.service.Service;
-import org.codehaus.xfire.service.ServiceFactory;
 import org.codehaus.xfire.service.binding.BeanInvoker;
 import org.codehaus.xfire.service.binding.ObjectServiceFactory;
 import org.codehaus.xfire.transport.Transport;
+import org.codehaus.xfire.transport.TransportManager;
 import org.codehaus.xfire.xmlbeans.XmlBeansTypeRegistry;
 import org.servicemix.common.Endpoint;
 import org.servicemix.jsr181.xfire.JbiTransport;
@@ -165,7 +166,9 @@
         }
         // Determine annotations
         WebAnnotations wa = null;
+        String selectedAnnotations = null;
         if (annotations != null) {
+            selectedAnnotations = annotations;
             if (!annotations.equals("none")) {
                 wa = (WebAnnotations) knownAnnotations.get(annotations);
                 if (wa == null) {
@@ -173,9 +176,11 @@
                 }
             }
         } else {
-            for (Iterator it = knownAnnotations.values().iterator(); it.hasNext();) {
-                WebAnnotations w = (WebAnnotations) it.next();
+            for (Iterator it = knownAnnotations.entrySet().iterator(); it.hasNext();) {
+                Map.Entry entry = (Map.Entry) it.next();
+                WebAnnotations w = (WebAnnotations) entry.getValue();
                 if (w.hasWebServiceAnnotation(pojo.getClass())) {
+                    selectedAnnotations = (String) entry.getKey();
                     wa = w;
                     break;
                 }
@@ -183,24 +188,32 @@
         }
         // Determine TypeMappingRegistry
         TypeMappingRegistry tm = null;
+        String selectedTypeMapping = null;
         if (typeMapping == null) {
-            if (wa == null) {
-                tm = (TypeMappingRegistry) knownTypeMappings.get("default");
-            } else {
-                tm = (TypeMappingRegistry) knownTypeMappings.get("jaxb2");
-            }
+            selectedTypeMapping = (wa == null) ? "default" : "jaxb2";
         } else {
-            tm = (TypeMappingRegistry) knownTypeMappings.get(typeMapping);
-            if (tm == null) {
-                throw new Exception("Unrecognized typeMapping: " + typeMapping);
-            }
+            selectedTypeMapping = typeMapping;
         }
+        tm = (TypeMappingRegistry) knownTypeMappings.get(selectedTypeMapping);
+        if (tm == null) {
+            throw new Exception("Unrecognized typeMapping: " + typeMapping);
+        }
         // Create factory
         XFire xfire = getXFire();
-        ServiceFactory factory = null;
+        ObjectServiceFactory factory = null;
         if (wa == null) {
             factory = new ObjectServiceFactory(xfire.getTransportManager(),
                                                new AegisBindingProvider(tm));
+        } else if (selectedAnnotations.equals("java5") && selectedTypeMapping.equals("jaxb2")) {
+            try {
+                Class clazz = Class.forName("org.codehaus.xfire.jaxws.JAXWSServiceFactory");
+                Constructor ct = clazz.getDeclaredConstructor(new Class[] { TransportManager.class });
+                factory = (ObjectServiceFactory) ct.newInstance(new Object[] { xfire.getTransportManager() });
+            } catch (Exception e) {
+                factory = new AnnotationServiceFactory(wa, 
+                        xfire.getTransportManager(), 
+                        new AegisBindingProvider(tm));
+            }
         } else {
             factory = new AnnotationServiceFactory(wa, 
                                                    xfire.getTransportManager(), 
@@ -209,9 +222,9 @@
         xfireService = factory.create(getPojo().getClass());
         xfireService.setInvoker(new BeanInvoker(getPojo()));
         xfire.getServiceRegistry().register(xfireService);
-        xfire.getTransportManager().disableAll(xfireService.getName());
+        xfire.getTransportManager().disableAll(xfireService);
         Transport jbiT = xfire.getTransportManager().getTransport(JbiTransport.JBI_BINDING);
-        xfire.getTransportManager().enable(jbiT, xfireService.getName());
+        xfire.getTransportManager().enable(jbiT, xfireService);
         this.description = generateWsdl();
         
         // Check service name and endpoint name
@@ -247,6 +260,9 @@
     protected Document generateWsdl() throws SAXException, IOException, ParserConfigurationException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         getXFire().generateWSDL(xfireService.getName(), baos);
+        if (logger.isTraceEnabled()) {
+            logger.trace(baos.toString());
+        }
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setNamespaceAware(true);
         Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));

Modified: trunk/servicemix-jsr181/src/main/java/org/servicemix/jsr181/xfire/JbiTransport.java (947 => 948)

--- trunk/servicemix-jsr181/src/main/java/org/servicemix/jsr181/xfire/JbiTransport.java	2005-11-28 12:04:44 UTC (rev 947)
+++ trunk/servicemix-jsr181/src/main/java/org/servicemix/jsr181/xfire/JbiTransport.java	2005-11-28 12:17:19 UTC (rev 948)
@@ -22,7 +22,7 @@
 import org.codehaus.xfire.handler.LocateBindingHandler;
 import org.codehaus.xfire.service.Service;
 import org.codehaus.xfire.soap.SoapTransport;
-import org.codehaus.xfire.soap.handler.SoapBindingHandler;
+import org.codehaus.xfire.soap.handler.SoapBodyHandler;
 import org.codehaus.xfire.transport.AbstractTransport;
 import org.codehaus.xfire.transport.Channel;
 import org.codehaus.xfire.transport.DefaultEndpoint;
@@ -43,7 +43,7 @@
 
     public JbiTransport() {
         addInHandler(new LocateBindingHandler());
-        addInHandler(new SoapBindingHandler());
+        addInHandler(new SoapBodyHandler());
     }
     
     public String getName() {

Reply via email to