tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuh...@apache.org
Subject svn commit: r573394 - in /incubator/tuscany/java/sdo: plugin/src/main/java/org/apache/tuscany/sdo/plugin/ tools/src/main/java/org/apache/tuscany/sdo/generate/ toolsTest/ toolsTest/src/main/resources/
Date Thu, 06 Sep 2007 22:06:46 GMT
Author: fuhwei
Date: Thu Sep  6 15:06:45 2007
New Revision: 573394

URL: http://svn.apache.org/viewvc?rev=573394&view=rev
Log:
Add schemaNamespace parameter support for SDO Mojo Plugin project

Added:
    incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly.wsdl
    incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly_1.xsd
Modified:
    incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/GeneratorMojo.java
    incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/SchemaFileOption.java
    incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/XSD2JavaGenerator.java
    incubator/tuscany/java/sdo/toolsTest/pom.xml

Modified: incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/GeneratorMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/GeneratorMojo.java?rev=573394&r1=573393&r2=573394&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/GeneratorMojo.java
(original)
+++ incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/GeneratorMojo.java
Thu Sep  6 15:06:45 2007
@@ -152,6 +152,14 @@
      * @parameter
      */
     private SchemaFileOption[] schemaFiles;
+    
+    /**
+     * The namespace to generate Java codes from.
+     * Setting to "all" will generate all namespaces.
+     * 
+     * @parameter
+     */
+    private String schemaNamespace;
 
     public void execute() throws MojoExecutionException {
 
@@ -167,6 +175,9 @@
                 if (null == sf.getJavaPackage()) {
                     sf.setJavaPackage(javaPackage);
                 }
+                if (null == sf.getSchemaNamespace()) {
+                	sf.setSchemaNamespace(schemaNamespace);
+                }
                 if (null == sf.isNoInterfaces()) {
                     sf.setNoInterfaces(noInterfaces);
                 }
@@ -218,6 +229,7 @@
                     schemaFiles[i].setNoUnsettable(noUnsettable);
                     schemaFiles[i].setPrefix(prefix);
                     schemaFiles[i].setTargetDirectory(targetDirectory);
+                    schemaFiles[i].setSchemaNamespace(schemaNamespace);
                 }
             } else {
                 schemaFiles = new SchemaFileOption[] {new SchemaFileOption()};
@@ -233,6 +245,7 @@
                 schemaFiles[0].setNoUnsettable(noUnsettable);
                 schemaFiles[0].setPrefix(prefix);
                 schemaFiles[0].setTargetDirectory(targetDirectory);
+                schemaFiles[0].setSchemaNamespace(schemaNamespace);
             }
         }
 
@@ -268,7 +281,7 @@
                 }
 
                 XSD2JavaGenerator.generateFromXMLSchema(file.toString(),
-                                                        null,
+                                                        schemaFiles[i].getSchemaNamespace(),
                                                         schemaFiles[i].getTargetDirectory(),
                                                         schemaFiles[i].getJavaPackage(),
                                                         schemaFiles[i].getPrefix(),

Modified: incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/SchemaFileOption.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/SchemaFileOption.java?rev=573394&r1=573393&r2=573394&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/SchemaFileOption.java
(original)
+++ incubator/tuscany/java/sdo/plugin/src/main/java/org/apache/tuscany/sdo/plugin/SchemaFileOption.java
Thu Sep  6 15:06:45 2007
@@ -100,6 +100,12 @@
      */
     private Boolean interfaceDataObject;
 
+    /**
+     * The namespace to generate Java codes from.
+     * Setting to "all" will generate all namespaces.
+     */
+    private String schemaNamespace;
+
     public SchemaFileOption() {
     }
 
@@ -189,6 +195,14 @@
 
 	public void setInterfaceDataObject(Boolean interfaceDataObject) {
 		this.interfaceDataObject = interfaceDataObject;
+	}
+	
+	public String getSchemaNamespace() {
+    	return schemaNamespace;
+    }
+	
+	public void setSchemaNamespace(String schemaNamespace) {
+		this.schemaNamespace = schemaNamespace;
 	}
 
 }

Modified: incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/XSD2JavaGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/XSD2JavaGenerator.java?rev=573394&r1=573393&r2=573394&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/XSD2JavaGenerator.java
(original)
+++ incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/XSD2JavaGenerator.java
Thu Sep  6 15:06:45 2007
@@ -147,13 +147,32 @@
     generateFromXMLSchema(xsdFileName, packageRegistry, extendedMetaData, targetDirectory,
packageInfoTable, genOptions, generateBuiltIn, allNamespaces);
   }
 
+  /**
+   * This method was invoked by the SDO Mojo plugin
+   * 
+   * @param xsdFileName
+   * @param namespace
+   * @param targetDirectory
+   * @param javaPackage
+   * @param prefix
+   * @param genOptions
+   */
   public static void generateFromXMLSchema(String xsdFileName, String namespace, String targetDirectory,
String javaPackage, String prefix, int genOptions)
   {
+	  boolean allNamespaces = false;
+	  
+	  // Need to process the passed-in schemaNamespace value from Mojo plugin the same as the
command line
+	  if( "all".equalsIgnoreCase(namespace))
+      {
+        namespace = null;
+        allNamespaces = true;
+      }
+	  
     EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
     ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry);
     String packageURI = getSchemaNamespace(xsdFileName);
     Hashtable packageInfoTable = createPackageInfoTable(packageURI, namespace, javaPackage,
prefix, null );
-    generateFromXMLSchema(xsdFileName, packageRegistry, extendedMetaData, targetDirectory,
packageInfoTable, genOptions, null, false );
+    generateFromXMLSchema(xsdFileName, packageRegistry, extendedMetaData, targetDirectory,
packageInfoTable, genOptions, null, allNamespaces);
   }
 
   

Modified: incubator/tuscany/java/sdo/toolsTest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/pom.xml?rev=573394&r1=573393&r2=573394&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/pom.xml (original)
+++ incubator/tuscany/java/sdo/toolsTest/pom.xml Thu Sep  6 15:06:45 2007
@@ -146,6 +146,16 @@
                             <goal>generate</goal>
                         </goals>
                     </execution>
+                    <execution>
+                        <id>XSDImportOnly</id>
+                        <configuration>
+                            <schemaFile>${basedir}/src/main/resources/xsdImportOnly.wsdl</schemaFile>
+                            <schemaNamespace>all</schemaNamespace>
+                        </configuration>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
                 </executions>
             </plugin>
         </plugins>

Added: incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly.wsdl?rev=573394&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly.wsdl (added)
+++ incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly.wsdl Thu Sep  6
15:06:45 2007
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://xsdImportOnly/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="EchoService"
targetNamespace="http://xsdImportOnly/">
+  <types>
+    <xsd:schema>
+      <xsd:import namespace="http://xsdImportOnly/" schemaLocation="xsdImportOnly_1.xsd"/>
+    </xsd:schema>
+  </types>
+  <message name="echo">
+    <part element="tns:echo" name="parameters"/>
+  </message>
+  <message name="echoResponse">
+    <part element="tns:echoResponse" name="parameters"/>
+  </message>
+  <portType name="Echo">
+    <operation name="echo">
+      <input message="tns:echo"/>
+      <output message="tns:echoResponse"/>
+    </operation>
+  </portType>
+  <binding name="EchoPortBinding" type="tns:Echo">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <operation name="echo">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
+  </binding>
+  <service name="EchoService">
+    <port binding="tns:EchoPortBinding" name="EchoPort">
+      <soap:address location="http://localhost:9080/w1/EchoService"/>
+    </port>
+  </service>
+</definitions> 
\ No newline at end of file

Added: incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly_1.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly_1.xsd?rev=573394&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly_1.xsd (added)
+++ incubator/tuscany/java/sdo/toolsTest/src/main/resources/xsdImportOnly_1.xsd Thu Sep  6
15:06:45 2007
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://xsdImportOnly/"
targetNamespace="http://xsdImportOnly/" version="1.0">
+
+  <xs:element name="echo" type="tns:echo"/>
+
+  <xs:element name="echoResponse" type="tns:echoResponse"/>
+
+  <xs:complexType name="echo">
+    <xs:sequence>
+      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="echoResponse">
+    <xs:sequence>
+      <xs:element minOccurs="0" name="return" type="xs:string"/>
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema> 
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message