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

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 @@
<version>1.5-SNAPSHOT</version>
</parent>
<groupId>org.ow2.frascati</groupId>
<artifactId>frascati-interface-wsdl</artifactId>
<packaging>jar</packaging>
<name>OW2 FraSCAti: SCA Interface WSDL Module</name>
......@@ -132,24 +131,27 @@
</dependency>
<!-- 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>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<!-- TODO move back to 0.6.0 when EasyBPEL 1.4 will use this JAXB2 Basics Runtime. -->
<version>0.5.0</version>
<!--
<version>0.6.0</version>
-->
<version>${jaxb2.version}</version>
</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>
<version>0.6.0</version>
-->
<artifactId>runtime</artifactId>
<version>0.4.1.5</version>
<dependency>
<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>
</dependencies>
......
......@@ -20,33 +20,30 @@
*
* Author: Philippe Merle
*
* Contributor(s):
* Contributor(s): Gwenael Cattez
*
*/
package org.ow2.frascati.wsdl;
import com.sun.xml.bind.api.impl.NameConverter;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import org.apache.cxf.tools.common.ToolContext;
import org.apache.cxf.tools.wsdlto.WSDLToJava;
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.Reference;
import org.osoa.sca.annotations.Scope;
import org.ow2.frascati.assembly.factory.api.ProcessingContext;
import org.ow2.frascati.component.factory.api.MembraneGeneration;
import org.ow2.frascati.util.AbstractLoggeable;
import org.ow2.frascati.util.FrascatiException;
import com.sun.xml.bind.api.impl.NameConverter;
/**
* OW2 FraSCAti Assembly Factory WSDL compiler with Apache CXF.
......@@ -81,6 +78,9 @@ public class WsdlCompilerCXF
@Reference(name = "membrane-generation")
private MembraneGeneration membraneGeneration;
@Property(name = "binding-file-name")
private String bindingFileName = "jaxb-global-bindings.xml";
/**
* Reader of WSDL descriptions.
*/
......@@ -153,10 +153,13 @@ public class WsdlCompilerCXF
// 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.
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 {
// Compile the WSDL description with Apache CXF WSDL2Java Tool.
new WSDLToJava(params).run(new ToolContext(), System.out);
......@@ -169,5 +172,4 @@ public class WsdlCompilerCXF
// Add WSDL2Java output directory to the Juliac compiler at the first time needed.
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 @@
*
* Author: Philippe Merle
*
* Contributor(s):
* Contributor(s): Gwenael Cattez
*
-->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
......@@ -39,8 +39,9 @@
<component name="wsdl-compiler">
<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="binding-file-name">jaxb-global-bindings.xml</property>
<service name="wsdl-compiler">
<interface.java interface="org.ow2.frascati.wsdl.WsdlCompiler"/>
</service>
......
......@@ -317,6 +317,7 @@
<xerces.version>2.9.1</xerces.version>
<jaxb.version>2.1.13</jaxb.version>
<velocity.version>1.7</velocity.version>
<jaxb2.version>0.6.0</jaxb2.version>
</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