You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/05/05 06:37:30 UTC
svn commit: r399957 - in /webservices/axis2/trunk/java: ./ etc/
modules/codegen/src/org/apache/axis2/wsdl/codegen/
modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/
modules/codegen/src/org/apache/axis2/wsdl/template/general/ modules/jaxbri/
...
Author: dims
Date: Thu May 4 21:37:28 2006
New Revision: 399957
URL: http://svn.apache.org/viewcvs?rev=399957&view=rev
Log:
Fix for AXIS2-660
HACK ALERT!
- the java.net repo mentioned in Kohsuke's blog is not usable from maven1 as it is "https:"
- The ibiblio has the EA3 jars but the layout is again maven2 (http://ibiblio.org/maven2/com/sun/xml/)
So,
I hacked the groupId, artifactId and maven.repo.remote to carefully construct the url for the jars. See project.xml in jaxbri maven module and you will understand :)
Added:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JAXBRIExtension.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxbriAntBuildTemplate.xsl
webservices/axis2/trunk/java/modules/jaxbri/
webservices/axis2/trunk/java/modules/jaxbri/maven.xml
webservices/axis2/trunk/java/modules/jaxbri/project.properties
webservices/axis2/trunk/java/modules/jaxbri/project.xml
webservices/axis2/trunk/java/modules/jaxbri/src/
webservices/axis2/trunk/java/modules/jaxbri/src/org/
webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/
webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/
webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/
webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
Modified:
webservices/axis2/trunk/java/etc/project.properties
webservices/axis2/trunk/java/maven.xml
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=399957&r1=399956&r2=399957&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Thu May 4 21:37:28 2006
@@ -37,9 +37,13 @@
http://www.openejb.org/maven,\
http://dist.codehaus.org/,\
http://mirrors.sunsite.dk/maven/,\
+http://www.ibiblio.org/maven2/com/sun/xml/jaxb-impl/,\
+http://www.ibiblio.org/maven2/com/sun/xml/jaxb-xjc/,\
http://jibx.sourceforge.net/maven/
+
+
# -------------------------------------------------------------------
# Multiproject includes and excludes
# -------------------------------------------------------------------
@@ -62,6 +66,7 @@
modules/integration/project.xml,\
modules/saaj/project.xml,\
modules/jibx/project.xml,\
+modules/jaxbri/project.xml,\
${optional.includes}
#maven.multiproject.excludes=modules/tool/project.xml
@@ -98,6 +103,7 @@
geronimo.spec.javamail.version=1.3.1-rc5
geronimo.spec.jms.version=1.1-rc4
groovy.all.version=1.0-jsr-01
+jaxbri.version=2.0EA3
jaxen.version=1.1-beta-8
jaxme.version=0.5.1
jibx.version=1.1-beta3
Modified: webservices/axis2/trunk/java/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/maven.xml?rev=399957&r1=399956&r2=399957&view=diff
==============================================================================
--- webservices/axis2/trunk/java/maven.xml (original)
+++ webservices/axis2/trunk/java/maven.xml Thu May 4 21:37:28 2006
@@ -407,6 +407,11 @@
<ant:fileset file="modules/jibx/target/axis2-jibx-${pom.currentVersion}.jar"/>
</ant:copy>
+ <!-- Copy the jaxbri jar -->
+ <ant:copy toDir="target/temp/war/lib">
+ <ant:fileset file="modules/jaxbri/target/axis2-jaxbri-${pom.currentVersion}.jar"/>
+ </ant:copy>
+
<!-- Copy the soapmonitor jar - the servlet classes -->
<ant:copy toDir="target/temp/war/lib">
<ant:fileset
@@ -656,6 +661,7 @@
<ant:fileset file="modules/codegen/target/axis2-codegen-${pom.currentVersion}.jar"/>
<ant:fileset file="modules/xmlbeans/target/axis2-xmlbeans-${pom.currentVersion}.jar"/>
<ant:fileset file="modules/jibx/target/axis2-jibx-${pom.currentVersion}.jar"/>
+ <ant:fileset file="modules/jaxbri/target/axis2-jaxbri-${pom.currentVersion}.jar"/>
</ant:copy>
<!-- Copy addressing mar -->
@@ -719,6 +725,7 @@
<ant:include name="**/modules/webapp/**"/>
<ant:include name="**/modules/xmlbeans/**"/>
<ant:include name="**/modules/jibx/**"/>
+ <ant:include name="**/modules/jaxbri/**"/>
<ant:include name="**/modules/addressing/**"/>
<ant:include name="**/modules/samples/**"/>
<ant:exclude name="**/SameServiceAddingTest.java"/>
@@ -891,6 +898,7 @@
<ant:pathelement location="modules/core/src"/>
<ant:pathelement location="modules/jaxws/src"/>
<ant:pathelement location="modules/jibx/src"/>
+ <ant:pathelement location="modules/jaxbri/src"/>
<ant:pathelement location="modules/saaj/src"/>
<ant:pathelement location="modules/security/src"/>
<ant:pathelement location="modules/soapmonitor/src"/>
@@ -980,6 +988,7 @@
<ant:fileset file="modules/codegen/target/axis2-codegen-${pom.currentVersion}.jar"/>
<ant:fileset file="modules/xmlbeans/target/axis2-xmlbeans-${pom.currentVersion}.jar"/>
<ant:fileset file="modules/jibx/target/axis2-jibx-${pom.currentVersion}.jar"/>
+ <ant:fileset file="modules/jaxbri/target/axis2-jaxbri-${pom.currentVersion}.jar"/>
<ant:fileset file="modules/java2wsdl/target/axis2-java2wsdl-${pom.currentVersion}.jar"/>
</ant:copy>
</goal>
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=399957&r1=399956&r2=399957&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Thu May 4 21:37:28 2006
@@ -1,84 +1,85 @@
-#######################################################################################################################
-##################### code generator property file #################################################################
-#######################################################################################################################
-# Extensions - The extensions are comma separated
-# these are loaded in their lexical order
-# Note the last extension - It includes a check to figure out whether proper databinding has taken place
-# This extension should appear AFTER all the databinding extensions inorder to function properly
-codegen.extension=org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.JiBXExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
-#codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension
-# The third party schemas to be loaded. e.g. The Xmime extension
-# Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package.
-# so whatever the third party schema's that are listed here should be present there
-codegen.thirdparty.schema=xmime.xsd,soap-enc.xsd
-#
-#####################################################################################################################
-#####################################################################################################################
-# Codegen data binding frameworks and their related information
-# The names of the codegeneration frameworks in lexical order
-# these are the names that should be passed onto the tool as arguments as well
-codegen.databinding.frameworks=adb,xmlbeans,jaxme,jibx,none
-# the related extensions for the specified data binding frameworks above
-# Note - these are in the lexical order of the framework names. There is an implicit assumption
-# that a given databinding framework will be processed only by one extension
-codegen.databinding.extensions=org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.JiBXExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
-# the default data binding framework name
-codegen.databinding.frameworks.default=adb
-# the databinding template - this should include all the necessary xslt templates for
-# creating the databindsupporters
-codegen.databinding.supporter.template=/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
-
-codegen.databinding.testobject.template=/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
-#####################################################################################################################
-#####################################################################################################################
-# Language types - these are the language types that the code generator understands. Again this is the name of the
-# language that should be passed from the tool as well
-#
-codegen.languages=java,c-sharp
-# Emitter class is the major code generator class that should be changed according to the language.
-# The emiiters need to implement the org.apache.axis2.wsdl.codegen.emitter.Emitter interface
-# Note - The emitters should appear in the lexical order of the languages. So the language java in the above
-# list corresponds to the org.apache.axis2.wsdl.codegen.emitter.JavaEmitter
-codegen.emitters=org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter,org.apache.axis2.wsdl.codegen.emitter.CSharpEmitter
-# Default language, this is the default language that would be picked when no language is specified. it should be
-# one of the languages specified above
-codegen.languages.default=java
-#####################################################################################################################
-######################## Language specific section #################################################################
-#####################################################################################################################
-# The language specific section has a special custom style. The language name comes first and separated from the period
-# a unique name. These parameters will be included in a hashmap that is will be stored in another hash map with the
-# language as the key
-#####################################################################################################################
-# Java section - Templates.
-# The format of the templates is <writer-class-name>,<template-name>
-# Note this section is specific to the emitter logic. One can have anything here!
-java.interface.template=org.apache.axis2.wsdl.codegen.writer.InterfaceWriter,/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl
-java.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
-java.bean.template=org.apache.axis2.wsdl.codegen.writer.BeanWriter,/org/apache/axis2/wsdl/template/java/BeanTemplate.xsl
-java.callback.template=org.apache.axis2.wsdl.codegen.writer.CallbackHandlerWriter,/org/apache/axis2/wsdl/template/java/CallbackHandlerTemplate.xsl
-java.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
-java.skeleton.interface.template=org.apache.axis2.wsdl.codegen.writer.SkeletonInterfaceWriter,/org/apache/axis2/wsdl/template/java/SkeletonInterfaceTemplate.xsl
-java.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
-java.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
-java.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
-#
-java.antbuild.jaxme.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
-java.antbuild.xmlbeans.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
-java.antbuild.jibx.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/jibxAntBuildTemplate.xsl
-java.antbuild.adb.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl
-java.antbuild.none.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/defaultAntBuildTemplate.xsl
-# file extension for generated files from this language
-java.filename.extension=java
-#
-# ##################################################################################################################
-# C sharp section - Templates
-c-sharp.interface.template=org.apache.axis2.wsdl.codegen.writer.InterfaceWriter,/org/apache/axis2/wsdl/template/csharp/InterfaceTemplate.xsl
-c-sharp.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/csharp/InterfaceImplementationTemplate.xsl
-c-sharp.bean.template=org.apache.axis2.wsdl.codegen.writer.BeanWriter,/org/apache/axis2/wsdl/template/csharp/BeanTemplate.xsl
-c-sharp.callback.template=org.apache.axis2.wsdl.codegen.writer.CallbackHandlerWriter,/org/apache/axis2/wsdl/template/csharp/CallbackHandlerTemplate.xsl
-c-sharp.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/csharp/SkeletonTemplate.xsl
-c-sharp.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl
-c-sharp.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
-c-sharp.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/csharp/MessageReceiverTemplate.xsl
-c-sharp.filename.extension=cs
+#######################################################################################################################
+##################### code generator property file #################################################################
+#######################################################################################################################
+# Extensions - The extensions are comma separated
+# these are loaded in their lexical order
+# Note the last extension - It includes a check to figure out whether proper databinding has taken place
+# This extension should appear AFTER all the databinding extensions inorder to function properly
+codegen.extension=org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.JiBXExtension,org.apache.axis2.wsdl.codegen.extension.JAXBRIExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
+#codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension
+# The third party schemas to be loaded. e.g. The Xmime extension
+# Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package.
+# so whatever the third party schema's that are listed here should be present there
+codegen.thirdparty.schema=xmime.xsd,soap-enc.xsd
+#
+#####################################################################################################################
+#####################################################################################################################
+# Codegen data binding frameworks and their related information
+# The names of the codegeneration frameworks in lexical order
+# these are the names that should be passed onto the tool as arguments as well
+codegen.databinding.frameworks=adb,xmlbeans,jaxme,jibx,jaxbri,none
+# the related extensions for the specified data binding frameworks above
+# Note - these are in the lexical order of the framework names. There is an implicit assumption
+# that a given databinding framework will be processed only by one extension
+codegen.databinding.extensions=org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.JiBXExtension,org.apache.axis2.wsdl.codegen.extension.JAXBRIExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
+# the default data binding framework name
+codegen.databinding.frameworks.default=adb
+# the databinding template - this should include all the necessary xslt templates for
+# creating the databindsupporters
+codegen.databinding.supporter.template=/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
+
+codegen.databinding.testobject.template=/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
+#####################################################################################################################
+#####################################################################################################################
+# Language types - these are the language types that the code generator understands. Again this is the name of the
+# language that should be passed from the tool as well
+#
+codegen.languages=java,c-sharp
+# Emitter class is the major code generator class that should be changed according to the language.
+# The emiiters need to implement the org.apache.axis2.wsdl.codegen.emitter.Emitter interface
+# Note - The emitters should appear in the lexical order of the languages. So the language java in the above
+# list corresponds to the org.apache.axis2.wsdl.codegen.emitter.JavaEmitter
+codegen.emitters=org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter,org.apache.axis2.wsdl.codegen.emitter.CSharpEmitter
+# Default language, this is the default language that would be picked when no language is specified. it should be
+# one of the languages specified above
+codegen.languages.default=java
+#####################################################################################################################
+######################## Language specific section #################################################################
+#####################################################################################################################
+# The language specific section has a special custom style. The language name comes first and separated from the period
+# a unique name. These parameters will be included in a hashmap that is will be stored in another hash map with the
+# language as the key
+#####################################################################################################################
+# Java section - Templates.
+# The format of the templates is <writer-class-name>,<template-name>
+# Note this section is specific to the emitter logic. One can have anything here!
+java.interface.template=org.apache.axis2.wsdl.codegen.writer.InterfaceWriter,/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl
+java.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
+java.bean.template=org.apache.axis2.wsdl.codegen.writer.BeanWriter,/org/apache/axis2/wsdl/template/java/BeanTemplate.xsl
+java.callback.template=org.apache.axis2.wsdl.codegen.writer.CallbackHandlerWriter,/org/apache/axis2/wsdl/template/java/CallbackHandlerTemplate.xsl
+java.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
+java.skeleton.interface.template=org.apache.axis2.wsdl.codegen.writer.SkeletonInterfaceWriter,/org/apache/axis2/wsdl/template/java/SkeletonInterfaceTemplate.xsl
+java.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
+java.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
+java.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
+#
+java.antbuild.jaxme.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/jaxmeAntBuildTemplate.xsl
+java.antbuild.xmlbeans.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
+java.antbuild.jibx.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/jibxAntBuildTemplate.xsl
+java.antbuild.jaxbri.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/jaxbriAntBuildTemplate.xsl
+java.antbuild.adb.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/adbAntBuildTemplate.xsl
+java.antbuild.none.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/defaultAntBuildTemplate.xsl
+# file extension for generated files from this language
+java.filename.extension=java
+#
+# ##################################################################################################################
+# C sharp section - Templates
+c-sharp.interface.template=org.apache.axis2.wsdl.codegen.writer.InterfaceWriter,/org/apache/axis2/wsdl/template/csharp/InterfaceTemplate.xsl
+c-sharp.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/csharp/InterfaceImplementationTemplate.xsl
+c-sharp.bean.template=org.apache.axis2.wsdl.codegen.writer.BeanWriter,/org/apache/axis2/wsdl/template/csharp/BeanTemplate.xsl
+c-sharp.callback.template=org.apache.axis2.wsdl.codegen.writer.CallbackHandlerWriter,/org/apache/axis2/wsdl/template/csharp/CallbackHandlerTemplate.xsl
+c-sharp.skeleton.template=org.apache.axis2.wsdl.codegen.writer.SkeletonWriter,/org/apache/axis2/wsdl/template/csharp/SkeletonTemplate.xsl
+c-sharp.testclass.template=org.apache.axis2.wsdl.codegen.writer.TestClassWriter,/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl
+c-sharp.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
+c-sharp.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/csharp/MessageReceiverTemplate.xsl
+c-sharp.filename.extension=cs
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JAXBRIExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JAXBRIExtension.java?rev=399957&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JAXBRIExtension.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JAXBRIExtension.java Thu May 4 21:37:28 2006
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.wsdl.codegen.extension;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.i18n.CodegenMessages;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JAXBRIExtension extends AbstractDBProcessingExtension {
+
+ public static final String SCHEMA_FOLDER = "schemas";
+
+ public static String MAPPINGS = "mappings";
+ public static String MAPPING = "mapping";
+ public static String MESSAGE = "message";
+ public static String JAVA_NAME = "javaclass";
+
+ public static final String MAPPING_FOLDER = "Mapping";
+ public static final String MAPPER_FILE_NAME = "mapper";
+ public static final String SCHEMA_PATH = "/org/apache/axis2/wsdl/codegen/schema/";
+
+ public static final String JAXB_RI_API_CLASS = "javax.xml.bind.JAXBContext";
+ public static final String JAXB_RI_IMPL_CLASS = "com.sun.xml.bind.Util";
+ public static final String JAXB_RI_XJC_CLASS = "com.sun.tools.xjc.api.XJC";
+
+ public static final String JAXB_RI_UTILITY_CLASS = "org.apache.axis2.jaxbri.CodeGenerationUtility";
+
+ public static final String JAXB_RI_PROCESS_METHOD = "processSchemas";
+
+
+ public void engage() {
+
+ //test the databinding type. If not just fall through
+ if (testFallThrough(configuration.getDatabindingType())) {
+ return;
+ }
+
+ try {
+
+ // try dummy load of framework classes first to check missing jars
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ cl.loadClass(JAXB_RI_API_CLASS);
+ cl.loadClass(JAXB_RI_IMPL_CLASS);
+ cl.loadClass(JAXB_RI_XJC_CLASS);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("JAX-B RI JARs not on classpath");
+ }
+
+ // load the actual utility class
+ Class clazz = null;
+ try {
+ clazz = JAXBRIExtension.class.getClassLoader().loadClass(JAXB_RI_UTILITY_CLASS);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("JAX-B RI binding extension not in classpath");
+ }
+
+ // invoke utility class method for actual processing
+ Method method = clazz.getMethod(JAXB_RI_PROCESS_METHOD,
+ new Class[] { List.class, Element[].class, CodeGenConfiguration.class });
+ ArrayList schemas = configuration.getAxisService().getSchema();
+ Element[] additionalSchemas = loadAdditionalSchemas();
+ TypeMapper mapper = (TypeMapper)method.invoke(null,
+ new Object[] { schemas, additionalSchemas, configuration });
+
+ // set the type mapper to the config
+ configuration.setTypeMapper(mapper);
+
+ } catch (Exception e) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ } else {
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+
+
+ /**
+ * Loading the external schemas.
+ *
+ * @return element array consisting of the the DOM element objects that represent schemas
+ */
+ private Element[] loadAdditionalSchemas() {
+ //load additional schemas
+ String[] schemaNames = ConfigPropertyFileLoader.getThirdPartySchemaNames();
+ Element[] schemaElements;
+
+ try {
+ ArrayList additionalSchemaElements = new ArrayList();
+ DocumentBuilder documentBuilder = getNamespaceAwareDocumentBuilder();
+ for (int i = 0; i < schemaNames.length; i++) {
+ //the location for the third party schema;s is hardcoded
+ if (!"".equals(schemaNames[i].trim())) {
+ InputStream schemaStream = this.getClass().getResourceAsStream(SCHEMA_PATH + schemaNames[i]);
+ Document doc = documentBuilder.parse(schemaStream);
+ additionalSchemaElements.add(doc.getDocumentElement());
+ }
+ }
+
+ //Create the Schema element array
+ schemaElements = new Element[additionalSchemaElements.size()];
+ for (int i = 0; i < additionalSchemaElements.size(); i++) {
+ schemaElements[i] = (Element) additionalSchemaElements.get(i);
+
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(CodegenMessages.getMessage("extension.additionalSchemaFailure"), e);
+ }
+
+ return schemaElements;
+ }
+
+ private DocumentBuilder getNamespaceAwareDocumentBuilder() throws ParserConfigurationException {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ return documentBuilderFactory.newDocumentBuilder();
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxbriAntBuildTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxbriAntBuildTemplate.xsl?rev=399957&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxbriAntBuildTemplate.xsl (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/jaxbriAntBuildTemplate.xsl Thu May 4 21:37:28 2006
@@ -0,0 +1,277 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
+ <xsl:template match="/ant">
+ <xsl:variable name="package"><xsl:value-of select="@package"/></xsl:variable>
+
+ <project basedir="." default="jar.all">
+ <xsl:comment>Auto generated ant build file</xsl:comment>
+ <property environment="env"/>
+ <property name="axis2.home">
+ <xsl:attribute name="value">${env.AXIS2_HOME}</xsl:attribute>
+ </property>
+ <property name="project.base.dir">
+ <xsl:attribute name="value">.</xsl:attribute>
+ </property>
+ <property name="maven.class.path">
+ <xsl:attribute name="value"></xsl:attribute>
+ </property>
+ <property name="name">
+ <xsl:attribute name="value"><xsl:value-of select="@servicename"/></xsl:attribute>
+ </property>
+ <property name="src">
+ <xsl:attribute name="value">${project.base.dir}/src</xsl:attribute>
+ </property>
+ <property name="test">
+ <xsl:attribute name="value">${project.base.dir}/test</xsl:attribute>
+ </property>
+ <property name="build">
+ <xsl:attribute name="value">${project.base.dir}/build</xsl:attribute>
+ </property>
+ <property name="classes">
+ <xsl:attribute name="value">${build}/classes</xsl:attribute>
+ </property>
+ <property name="lib">
+ <xsl:attribute name="value">${build}/lib</xsl:attribute>
+ </property>
+ <property name="resources">
+ <xsl:attribute name="value">${project.base.dir}/resources</xsl:attribute>
+ </property>
+
+ <property name="xbeans.packaged.jar.name" value="XBeans-packaged.jar"></property>
+
+ <property name="jars.ok" value=""></property>
+
+ <path id="axis2.class.path">
+ <pathelement>
+ <xsl:attribute name="path">${java.class.path}</xsl:attribute>
+ </pathelement>
+ <pathelement>
+ <xsl:attribute name="path">${maven.class.path}</xsl:attribute>
+ </pathelement>
+ <fileset>
+ <xsl:attribute name="dir">${axis2.home}</xsl:attribute>
+ <include>
+ <xsl:attribute name="name">lib/*.jar</xsl:attribute>
+ </include>
+ </fileset>
+ </path>
+
+ <target name="init">
+ <mkdir>
+ <xsl:attribute name="dir">${build}</xsl:attribute>
+ </mkdir>
+ <mkdir>
+ <xsl:attribute name="dir">${classes}</xsl:attribute>
+ </mkdir>
+ <mkdir>
+ <xsl:attribute name="dir">${lib}</xsl:attribute>
+ </mkdir>
+ <xsl:if test="not(@testOmit)">
+ <mkdir>
+ <xsl:attribute name="dir">${test}</xsl:attribute>
+ </mkdir>
+ </xsl:if>
+
+ </target>
+
+ <target name="jar.xbeans">
+ <!-- jar the XMLbeans stuff to the lib folder-->
+ <jar>
+ <xsl:attribute name="basedir">${resources}</xsl:attribute>
+ <xsl:attribute name="destfile">${lib}/${xbeans.packaged.jar.name}</xsl:attribute>
+ <xsl:attribute name="excludes">**/services.xml</xsl:attribute>
+ </jar>
+ </target>
+
+ <target name="pre.compile.test" depends="init, jar.xbeans">
+ <xsl:comment>Test the classpath for the availability of necesary classes</xsl:comment>
+ <available classname="com.sun.tools.xjc.api.XJC" property="jaxbri.available" classpathref="axis2.class.path"/>
+ <available classname="javax.xml.stream.XMLStreamReader" property="stax.available" classpathref="axis2.class.path"/>
+ <available classname="org.apache.axis2.engine.AxisEngine" property="axis2.available" classpathref="axis2.class.path"/>
+ <condition property="jars.ok" >
+ <and>
+ <isset property="jaxbri.available"/>
+ <isset property="stax.available"/>
+ <isset property="axis2.available"/>
+ </and>
+ </condition>
+
+ <xsl:comment>Print out the availabilities</xsl:comment>
+ <echo>
+ <xsl:attribute name="message">JAX-B RI Availability = ${jaxbri.available}</xsl:attribute>
+ </echo>
+ <echo>
+ <xsl:attribute name="message">Stax Availability= ${stax.available}</xsl:attribute>
+ </echo>
+ <echo>
+ <xsl:attribute name="message">Axis2 Availability= ${axis2.available}</xsl:attribute>
+ </echo>
+
+ </target>
+
+ <target name="compile.src" depends="pre.compile.test" >
+ <xsl:attribute name="if">jars.ok</xsl:attribute>
+ <javac debug="on">
+ <xsl:attribute name="destdir">${classes}</xsl:attribute>
+ <xsl:attribute name="srcdir">${src}</xsl:attribute>
+ <classpath>
+ <xsl:attribute name="location">${lib}/${xbeans.packaged.jar.name}</xsl:attribute>
+ </classpath>
+ <classpath>
+ <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+ </classpath>
+ </javac>
+ </target>
+
+
+ <target name="compile.test" depends="compile.src">
+ <xsl:attribute name="if">jars.ok</xsl:attribute>
+ <javac debug="on">
+ <xsl:attribute name="destdir">${classes}</xsl:attribute>
+
+ <src>
+ <xsl:attribute name="path">${test}</xsl:attribute>
+ </src>
+
+ <classpath>
+ <xsl:attribute name="location">${lib}/${xbeans.packaged.jar.name}</xsl:attribute>
+ </classpath>
+ <classpath>
+ <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+ </classpath>
+
+ <!-- todo -->
+
+ </javac>
+ </target>
+
+ <target name="echo.classpath.problem" depends="pre.compile.test">
+ <xsl:attribute name="unless">jars.ok</xsl:attribute>
+ <echo message="The class path is not set right!
+ Please make sure the following classes are in the classpath
+ 1. XmlBeans
+ 2. Stax
+ 3. Axis2
+ "></echo>
+ </target>
+ <target name="jar.all" depends="jar.server, jar.client">
+ </target>
+ <target name="jar.server" depends="compile.src,echo.classpath.problem">
+ <xsl:attribute name="if">jars.ok</xsl:attribute>
+ <copy>
+ <xsl:attribute name="toDir">${classes}/META-INF</xsl:attribute>
+ <fileset>
+ <xsl:attribute name="dir">${resources}</xsl:attribute>
+ <include><xsl:attribute name="name">*.xml</xsl:attribute></include>
+ <include><xsl:attribute name="name">*.wsdl</xsl:attribute></include>
+ <exclude><xsl:attribute name="name">**/schemaorg_apache_xmlbean/**</xsl:attribute></exclude>
+ </fileset>
+ </copy>
+ <copy>
+ <xsl:attribute name="file">${lib}/${xbeans.packaged.jar.name}</xsl:attribute>
+ <xsl:attribute name="toDir">${classes}/lib</xsl:attribute>
+ </copy>
+ <jar>
+ <xsl:attribute name="destfile">${lib}/${name}.aar</xsl:attribute>
+ <fileset>
+ <xsl:attribute name="excludes">**/Test.class</xsl:attribute>
+ <xsl:attribute name="dir">${classes}</xsl:attribute>
+ </fileset>
+ </jar>
+ </target>
+
+
+
+ <target name="jar.client" if="jars.ok">
+ <!--set the correct depends target-->
+ <xsl:choose>
+ <xsl:when test="@testOmit">
+ <xsl:attribute name="depends">compile.src</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="depends">compile.test</xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+
+
+ <jar>
+ <xsl:attribute name="destfile">${lib}/${name}-test-client.jar</xsl:attribute>
+ <fileset>
+ <xsl:attribute name="dir">${classes}</xsl:attribute>
+ <exclude><xsl:attribute name="name">**/META-INF/*.*</xsl:attribute></exclude>
+ <exclude><xsl:attribute name="name">**/lib/*.*</xsl:attribute></exclude>
+ <exclude><xsl:attribute name="name">**/*MessageReceiver.class</xsl:attribute></exclude>
+ <exclude><xsl:attribute name="name">**/*Skeleton.class</xsl:attribute></exclude>
+
+ </fileset>
+ <fileset>
+ <xsl:attribute name="dir">${resources}</xsl:attribute>
+ <exclude><xsl:attribute name="name">**/*.wsdl</xsl:attribute></exclude>
+ <exclude><xsl:attribute name="name">**/*.xml</xsl:attribute></exclude>
+ </fileset>
+ </jar>
+ </target>
+
+
+
+
+
+
+ <target depends="jar.server" name="make.repo" if="jars.ok">
+ <mkdir>
+ <xsl:attribute name="dir">${build}/repo/</xsl:attribute>
+ </mkdir>
+ <mkdir>
+ <xsl:attribute name="dir">${build}/repo/services</xsl:attribute>
+ </mkdir>
+ <copy>
+ <xsl:attribute name="file">${build}/lib/${name}.aar</xsl:attribute>
+ <xsl:attribute name="toDir">${build}/repo/services/</xsl:attribute>
+ </copy>
+ </target>
+ <target depends="make.repo" name="start.server" if="jars.ok">
+ <java classname="org.apache.axis2.transport.http.SimpleHTTPServer" fork="true">
+ <arg>
+ <xsl:attribute name="value">${build}/repo</xsl:attribute>
+ </arg>
+ <classpath>
+ <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+ </classpath>
+ </java>
+ </target>
+ <target if="jars.ok" name="run.test" depends="jar.client">
+ <path id="test.class.path">
+ <pathelement>
+ <xsl:attribute name="location">${lib}/${name}-test-client.jar</xsl:attribute>
+ </pathelement>
+ <path>
+ <xsl:attribute name="refid">axis2.class.path</xsl:attribute>
+ </path>
+ </path>
+ <mkdir>
+ <xsl:attribute name="dir">${build}/test-reports/</xsl:attribute>
+ </mkdir>
+ <junit printsummary="yes" haltonfailure="yes">
+ <classpath>
+ <xsl:attribute name="refid">test.class.path</xsl:attribute>
+ </classpath>
+ <formatter type="plain"/>
+ <batchtest fork="yes">
+ <xsl:attribute name="toDir">${build}/test-reports/</xsl:attribute>
+ <fileset>
+ <xsl:attribute name="dir">${test}</xsl:attribute>
+ <include>
+ <xsl:attribute name="name">**/*Test*.java</xsl:attribute>
+ </include>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+ <target name="clean">
+ <delete>
+ <xsl:attribute name="dir">${build}</xsl:attribute>
+ </delete>
+ </target>
+ </project>
+ </xsl:template>
+</xsl:stylesheet>
Added: webservices/axis2/trunk/java/modules/jaxbri/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jaxbri/maven.xml?rev=399957&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/maven.xml (added)
+++ webservices/axis2/trunk/java/modules/jaxbri/maven.xml Thu May 4 21:37:28 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Revision: 1.21 $ $Date: 2004-10-27 20:54:09 +0600 (Wed, 27 Oct 2004) $ -->
+
+<project default="jar"
+ xmlns:j="jelly:core"
+ xmlns:u="jelly:util"
+ xmlns:maven="jelly:maven"
+ xmlns:deploy="deploy"
+ xmlns:ant="jelly:ant">
+ <preGoal name="itest:compile">
+ <u:file var="file" name="${maven.itest.src}"/>
+ <j:if test="${!file.exists()}">
+ <j:expr value="${context.setVariable('maven.itest.skip', 'true')}"/>
+ </j:if>
+ </preGoal>
+</project>
Added: webservices/axis2/trunk/java/modules/jaxbri/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jaxbri/project.properties?rev=399957&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/project.properties (added)
+++ webservices/axis2/trunk/java/modules/jaxbri/project.properties Thu May 4 21:37:28 2006
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2004 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jar
Added: webservices/axis2/trunk/java/modules/jaxbri/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jaxbri/project.xml?rev=399957&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/project.xml (added)
+++ webservices/axis2/trunk/java/modules/jaxbri/project.xml Thu May 4 21:37:28 2006
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<project>
+ <pomVersion>3</pomVersion>
+ <extend>../../etc/project.xml</extend>
+
+ <name>Apache Axis 2.0 - JAXB-RI Data Binding</name>
+ <id>axis2-jaxbri</id>
+ <groupId>axis2</groupId>
+ <description>JAXB-RI data binding support for Axis 2.0</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-common</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-codegen</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-core</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>${XmlSchema.version}</version>
+ </dependency>
+
+ <!-- external JARs -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons.logging.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://dist.codehaus.org/stax/jars/</url>
+ </dependency>
+ <dependency>
+ <groupId>${stax.impl.groupid}</groupId>
+ <artifactId>${stax.impl.artifactid}</artifactId>
+ <version>${stax.impl.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>${stax.api.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>2.0EA3</groupId>
+ <artifactId>../jaxb-impl</artifactId>
+ <version>${jaxbri.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>2.0EA3</groupId>
+ <artifactId>../jaxb-xjc</artifactId>
+ <version>${jaxbri.version}</version>
+ </dependency>
+ </dependencies>
+ <build/>
+ <reports/>
+</project>
Added: webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java?rev=399957&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java (added)
+++ webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/CodeGenerationUtility.java Thu May 4 21:37:28 2006
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.jaxbri;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.StringReader;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+
+import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
+import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+
+import org.apache.ws.commons.schema.XmlSchema;
+
+import org.w3c.dom.Element;
+
+import org.xml.sax.InputSource;
+
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.writer.FileCodeWriter;
+import com.sun.tools.xjc.api.Mapping;
+import com.sun.tools.xjc.api.S2JJAXBModel;
+import com.sun.tools.xjc.api.SchemaCompiler;
+import com.sun.tools.xjc.api.XJC;
+
+public class CodeGenerationUtility {
+
+ /**
+ *
+ * @param additionalSchemas
+ * @throws RuntimeException
+ */
+ public static TypeMapper processSchemas(List schemas,
+ Element[] additionalSchemas,
+ CodeGenConfiguration cgconfig)
+ throws RuntimeException
+ {
+ try {
+
+ //check for the imported types. Any imported types are supposed to be here also
+ if (schemas == null || schemas.isEmpty()) {
+ //there are no types to be code generated
+ //However if the type mapper is left empty it will be a problem for the other
+ //processes. Hence the default type mapper is set to the configuration
+ return new DefaultTypeMapper();
+ }
+
+ Vector xmlObjectsVector = new Vector();
+
+ //create the type mapper
+ JavaTypeMapper mapper = new JavaTypeMapper();
+
+ String baseURI = cgconfig.getBaseURI();
+
+ for (int i = 0; i < schemas.size(); i++) {
+ XmlSchema schema = (XmlSchema) schemas.get(i);
+ InputSource inputSource = new InputSource(new StringReader(getSchemaAsString(schema)));
+ inputSource.setSystemId(baseURI);
+ xmlObjectsVector.add(inputSource);
+ }
+
+ File outputDir = new File(cgconfig.getOutputLocation(), "src");
+ outputDir.mkdir();
+
+ for (int i = 0; i < xmlObjectsVector.size(); i++) {
+
+ SchemaCompiler sc = XJC.createSchemaCompiler();
+
+ // TODO: pull default pkg and entity resolver from configuration
+ // sc.setDefaultPackageName();
+ // sc.setEntityResolver();
+
+ sc.parseSchema((InputSource) xmlObjectsVector.elementAt(i));
+
+ // Bind the XML
+ S2JJAXBModel jaxbModel = sc.bind();
+
+ // Emit the code artifacts
+ JCodeModel codeModel = jaxbModel.generateCode(null, null);
+ FileCodeWriter writer = new FileCodeWriter(outputDir);
+ codeModel.build( writer );
+
+ Collection mappings = jaxbModel.getMappings();
+
+ Iterator iter = mappings.iterator();
+
+ while ( iter.hasNext() )
+ {
+ Mapping mapping = (Mapping)iter.next();
+ QName qn = mapping.getElement();
+ String typeName = mapping.getType().getTypeClass().fullName();
+
+ mapper.addTypeMappingName( qn, typeName );
+ }
+ }
+
+ // Return the type mapper
+ return mapper;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static String getSchemaAsString(XmlSchema schema) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ schema.write(baos);
+ return baos.toString();
+ }
+}
\ No newline at end of file