Commit 96e804f4 authored by Gwenael Cattez's avatar Gwenael Cattez

Adding jaxb binding file to frascati-interface-wsdl to generate serializable...

Adding jaxb binding file to frascati-interface-wsdl to generate serializable java class for XmlTypes, and convert wsdl:dateTime wsdl:date wsdl:time to java.util.Date
parent 813e5142
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
<version>1.5-SNAPSHOT</version> <version>1.5-SNAPSHOT</version>
</parent> </parent>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-interface-wsdl</artifactId> <artifactId>frascati-interface-wsdl</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>OW2 FraSCAti: SCA Interface WSDL Module</name> <name>OW2 FraSCAti: SCA Interface WSDL Module</name>
...@@ -132,24 +131,27 @@ ...@@ -132,24 +131,27 @@
</dependency> </dependency>
<!-- JAXB2 xjc plugin for generating toString() methods in XML to Java mapping classes. --> <!-- JAXB2 xjc plugin for generating toString() methods in XML to Java mapping classes. -->
<!-- TODO move back to 0.6.0 when EasyBPEL 1.4 will use this JAXB2 Basics Runtime. -->
<!--
<version>0.6.0</version>
-->
<dependency> <dependency>
<groupId>org.jvnet.jaxb2_commons</groupId> <groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId> <artifactId>jaxb2-basics</artifactId>
<!-- TODO move back to 0.6.0 when EasyBPEL 1.4 will use this JAXB2 Basics Runtime. --> <version>${jaxb2.version}</version>
<version>0.5.0</version>
<!--
<version>0.6.0</version>
-->
</dependency> </dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId> <!-- TODO move back to 0.6.0 when EasyBPEL 1.4 will use this JAXB2 Basics Runtime. -->
<!-- TODO move back to 0.6.0 when EasyBPEL 1.4 will use this JAXB2 Basics Runtime. -->
<!-- <!--
<artifactId>jaxb2-basics-runtime</artifactId> <artifactId>jaxb2-basics-runtime</artifactId>
<version>0.6.0</version> <version>0.6.0</version>
--> -->
<artifactId>runtime</artifactId> <dependency>
<version>0.4.1.5</version> <groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>${jaxb2.version}</version>
<!-- <artifactId>runtime</artifactId> -->
<!-- <version>0.4.1.5</version> -->
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -20,33 +20,30 @@ ...@@ -20,33 +20,30 @@
* *
* Author: Philippe Merle * Author: Philippe Merle
* *
* Contributor(s): * Contributor(s): Gwenael Cattez
* *
*/ */
package org.ow2.frascati.wsdl; package org.ow2.frascati.wsdl;
import com.sun.xml.bind.api.impl.NameConverter; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.wsdl.Definition; import javax.wsdl.Definition;
import javax.wsdl.WSDLException; import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory; import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader; import javax.wsdl.xml.WSDLReader;
import org.apache.cxf.tools.common.ToolContext; import org.apache.cxf.tools.common.ToolContext;
import org.apache.cxf.tools.wsdlto.WSDLToJava; import org.apache.cxf.tools.wsdlto.WSDLToJava;
import org.osoa.sca.annotations.Init; import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Property; import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
import org.ow2.frascati.assembly.factory.api.ProcessingContext; import org.ow2.frascati.assembly.factory.api.ProcessingContext;
import org.ow2.frascati.component.factory.api.MembraneGeneration; import org.ow2.frascati.component.factory.api.MembraneGeneration;
import org.ow2.frascati.util.AbstractLoggeable; import org.ow2.frascati.util.AbstractLoggeable;
import org.ow2.frascati.util.FrascatiException; import org.ow2.frascati.util.FrascatiException;
import com.sun.xml.bind.api.impl.NameConverter;
/** /**
* OW2 FraSCAti Assembly Factory WSDL compiler with Apache CXF. * OW2 FraSCAti Assembly Factory WSDL compiler with Apache CXF.
...@@ -81,6 +78,9 @@ public class WsdlCompilerCXF ...@@ -81,6 +78,9 @@ public class WsdlCompilerCXF
@Reference(name = "membrane-generation") @Reference(name = "membrane-generation")
private MembraneGeneration membraneGeneration; private MembraneGeneration membraneGeneration;
@Property(name = "binding-file-name")
private String bindingFileName = "jaxb-global-bindings.xml";
/** /**
* Reader of WSDL descriptions. * Reader of WSDL descriptions.
*/ */
...@@ -153,10 +153,13 @@ public class WsdlCompilerCXF ...@@ -153,10 +153,13 @@ public class WsdlCompilerCXF
// TODO: Could be optimized to avoid to read the WSDL file twice. // TODO: Could be optimized to avoid to read the WSDL file twice.
// Require to study the Apache CXF WSDL2Java class to find a more appropriate entry point. // Require to study the Apache CXF WSDL2Java class to find a more appropriate entry point.
String outputDirectory = this.membraneGeneration.getOutputDirectory() + '/' + targetDirectory; String outputDirectory = this.membraneGeneration.getOutputDirectory() + '/' + targetDirectory;
String[] params = new String[]{ this.wsdl2javaOptions, "-d", outputDirectory , wsdlUri };
log.info("Compiling WSDL '" + wsdlUri + "' into '" + outputDirectory + "'..."); URL bindingFileURL= Thread.currentThread().getContextClassLoader().getResource(bindingFileName);
String[] params = new String[]{this.wsdl2javaOptions , "-b" , bindingFileURL.toExternalForm() , "-d", outputDirectory , wsdlUri };
log.info("Compiling WSDL '" + wsdlUri + "' into '" + outputDirectory + "'...");
try { try {
// Compile the WSDL description with Apache CXF WSDL2Java Tool. // Compile the WSDL description with Apache CXF WSDL2Java Tool.
new WSDLToJava(params).run(new ToolContext(), System.out); new WSDLToJava(params).run(new ToolContext(), System.out);
...@@ -169,5 +172,4 @@ public class WsdlCompilerCXF ...@@ -169,5 +172,4 @@ public class WsdlCompilerCXF
// Add WSDL2Java output directory to the Juliac compiler at the first time needed. // Add WSDL2Java output directory to the Juliac compiler at the first time needed.
this.membraneGeneration.addJavaSource(outputDirectory); this.membraneGeneration.addJavaSource(outputDirectory);
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings>
<xjc:simple/>
<jaxb:javaType name="java.util.Date" xmlType="xs:dateTime"
parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
<jaxb:javaType name="java.util.Date" xmlType="xs:date"
parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
<jaxb:javaType name="java.util.Date" xmlType="xs:time"
parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
<jaxb:serializable/>
</jaxb:globalBindings>
</jaxb:bindings>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* *
* Author: Philippe Merle * Author: Philippe Merle
* *
* Contributor(s): * Contributor(s): Gwenael Cattez
* *
--> -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
...@@ -39,8 +39,9 @@ ...@@ -39,8 +39,9 @@
<component name="wsdl-compiler"> <component name="wsdl-compiler">
<implementation.java class="org.ow2.frascati.wsdl.WsdlCompilerCXF"/> <implementation.java class="org.ow2.frascati.wsdl.WsdlCompilerCXF"/>
<property name="wsdl2java-options">-xjc-XtoString</property> <property name="wsdl2java-options">-xjc-XtoString</property>
<property name="target-directory">generated-frascati-sources</property> <property name="target-directory">generated-frascati-sources</property>
<property name="binding-file-name">jaxb-global-bindings.xml</property>
<service name="wsdl-compiler"> <service name="wsdl-compiler">
<interface.java interface="org.ow2.frascati.wsdl.WsdlCompiler"/> <interface.java interface="org.ow2.frascati.wsdl.WsdlCompiler"/>
</service> </service>
......
...@@ -317,6 +317,7 @@ ...@@ -317,6 +317,7 @@
<xerces.version>2.9.1</xerces.version> <xerces.version>2.9.1</xerces.version>
<jaxb.version>2.1.13</jaxb.version> <jaxb.version>2.1.13</jaxb.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
<jaxb2.version>0.6.0</jaxb2.version>
</properties> </properties>
<!-- ======================= --> <!-- ======================= -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment