You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/12/21 14:00:36 UTC
svn commit: r606185 - in /incubator/tuscany/java/sca/itest/databindings:
common/ common/src/main/java/org/apache/tuscany/sca/itest/generate/ sdogen/
sdogen/src/main/resources/generate/
Author: slaws
Date: Fri Dec 21 05:00:35 2007
New Revision: 606185
URL: http://svn.apache.org/viewvc?rev=606185&view=rev
Log:
TUSCANY-1934
Remove the need to auto-generate the sdogen pom file by driving the SDO generator API directly
Removed:
incubator/tuscany/java/sca/itest/databindings/sdogen/src/main/resources/generate/pom.xml.vm
Modified:
incubator/tuscany/java/sca/itest/databindings/common/pom.xml
incubator/tuscany/java/sca/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java
incubator/tuscany/java/sca/itest/databindings/sdogen/pom.xml
incubator/tuscany/java/sca/itest/databindings/sdogen/src/main/resources/generate/generate.xml
Modified: incubator/tuscany/java/sca/itest/databindings/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/databindings/common/pom.xml?rev=606185&r1=606184&r2=606185&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/databindings/common/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/databindings/common/pom.xml Fri Dec 21 05:00:35 2007
@@ -63,6 +63,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-tools</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.4</version>
Modified: incubator/tuscany/java/sca/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java?rev=606185&r1=606184&r2=606185&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java (original)
+++ incubator/tuscany/java/sca/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java Fri Dec 21 05:00:35 2007
@@ -25,7 +25,9 @@
import org.apache.tuscany.generate.GenerateFactory;
import org.apache.tuscany.generate.GenerateType;
+import org.apache.tuscany.generate.InputFileType;
import org.apache.tuscany.generate.TemplateType;
+import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
import org.apache.tuscany.sdo.util.SDOUtil;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
@@ -38,8 +40,8 @@
* and a set of velocity templates. The process is
*
* for each template
- * for each file
- * add a line to pom for code gen
+ * for each xsd file
+ * generate SDOs
* include the factory into the composite
* for each type
* add client iface method
@@ -70,14 +72,14 @@
fis = new FileInputStream(projectBuildDir + "/classes/generate/generate.xml");
// Load the stream into SDO
- // We are just using SDO as a conveniet way to parse the XML config file
+ // We are just using SDO as a convenient way to parse the XML config file
HelperContext scope = SDOUtil.createHelperContext();
GenerateFactory.INSTANCE.register(scope);
XMLDocument xmlDoc = scope.getXMLHelper().load(fis);
GenerateType generateType = (GenerateType)xmlDoc.getRootObject();
// Get the file list. This is the list of XSD that is passed into the
- // the velocity templates. Each confiured file holds a list of types
+ // the velocity templates. Each configured file holds a list of types
// that the velocity templates expand into appropriate methods and method calls
List fileList = generateType.getInputFile();
@@ -103,12 +105,60 @@
fw.close();
}
+
} catch (Exception e) {
System.out.println("Exception : " + e.toString());
e.printStackTrace();
return;
}
}
+
+ /**
+ * The SDO generator tool does all of the hard work
+ *
+ * @param projectBuildDir the path to the target dir of the project being generated.
+ */
+ public static void generateSDO(String projectBuildDir) {
+ System.out.println(">> Building SDOs from dir: " + projectBuildDir);
+ FileInputStream fis = null;
+
+ try {
+ // Load the config file into a stream
+ fis = new FileInputStream(projectBuildDir + "/classes/generate/generate.xml");
+
+ // Load the stream into SDO
+ // We are just using SDO as a convenient way to parse the XML config file
+ HelperContext scope = SDOUtil.createHelperContext();
+ GenerateFactory.INSTANCE.register(scope);
+ XMLDocument xmlDoc = scope.getXMLHelper().load(fis);
+ GenerateType generateType = (GenerateType)xmlDoc.getRootObject();
+
+ // Get the file list. This is the list of XSD that is passed into the
+ // the velocity templates. Each configured file holds a list of types
+ // that the velocity templates expand into appropriate methods and method calls
+ List fileList = generateType.getInputFile();
+
+ // for each XSD in the XSD file list generate an SDO.
+ XSD2JavaGenerator generator = new XSD2JavaGenerator();
+
+ for ( Object item : fileList){
+ InputFileType file = (InputFileType)item;
+
+ XSD2JavaGenerator.generateFromXMLSchema(projectBuildDir + "/classes/xsd/" + file.getFileName(),
+ file.getNamespace(),
+ projectBuildDir + "/sdo-source",
+ file.getJavaPackage(),
+ null, //file.getPrefix(),
+ XSD2JavaGenerator.OPTION_NO_CONTAINMENT | XSD2JavaGenerator.OPTION_NO_NOTIFICATION | XSD2JavaGenerator.OPTION_NO_UNSETTABLE);
+
+ }
+
+ } catch (Exception e) {
+ System.out.println("Exception : " + e.toString());
+ e.printStackTrace();
+ return;
+ }
+ }
/**
* The mainline
@@ -116,8 +166,12 @@
* @param args the target directory where project in which files are being generated
*/
public static void main(String[] args) {
- Generate gen = new Generate();
- gen.generate(args[0]);
+
+ Generate.generate(args[0]);
+
+ if (args.length > 1){
+ Generate.generateSDO(args[0]);
+ }
}
}
Modified: incubator/tuscany/java/sca/itest/databindings/sdogen/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/databindings/sdogen/pom.xml?rev=606185&r1=606184&r2=606185&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/databindings/sdogen/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/databindings/sdogen/pom.xml Fri Dec 21 05:00:35 2007
@@ -148,7 +148,7 @@
</configuration>
</execution>
</executions>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@@ -173,6 +173,26 @@
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
+ <id>generate-test-sdo-source</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.apache.tuscany.sca.itest.generate.Generate</mainClass>
+ <arguments>
+ <argument>${project.build.directory}</argument>
+ <argument>true</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
<id>generate-test-source</id>
<phase>process-resources</phase>
<goals>
@@ -184,6 +204,7 @@
<mainClass>org.apache.tuscany.sca.itest.generate.Generate</mainClass>
<arguments>
<argument>${project.build.directory}</argument>
+ <argument>true</argument>
</arguments>
</configuration>
</plugin>
@@ -201,15 +222,7 @@
<fileName>${project.build.directory}/classes/wsdl/Greeter.wsdl</fileName>
<javaPackage>org.apache.tuscany.sca.itest.databinding.services</javaPackage>
</configuration>
- <configuration>
- <fileName>${project.build.directory}/classes/xsd/Person.xsd</fileName>
- <javaPackage>org.apache.tuscany.sca.itest.databinding.types</javaPackage>
- </configuration>
- <configuration>
- <fileName>${project.build.directory}/classes/xsd/Interop.xsd</fileName>
- <javaPackage>org.apache.tuscany.interop</javaPackage>
- </configuration>
- </schemaFiles>
+ </schemaFiles>
<noNotification>true</noNotification>
<noContainment>true</noContainment>
<noUnsettable>true</noUnsettable>
Modified: incubator/tuscany/java/sca/itest/databindings/sdogen/src/main/resources/generate/generate.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/databindings/sdogen/src/main/resources/generate/generate.xml?rev=606185&r1=606184&r2=606185&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/databindings/sdogen/src/main/resources/generate/generate.xml (original)
+++ incubator/tuscany/java/sca/itest/databindings/sdogen/src/main/resources/generate/generate.xml Fri Dec 21 05:00:35 2007
@@ -20,10 +20,7 @@
<tns:Generate xmlns:tns="http://www.apache.org/tuscany/generate"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/generate generate.xsd ">
- <Template>
- <TemplateName>pom.xml.vm</TemplateName>
- <TemplateTargetDir>..</TemplateTargetDir>
- </Template>
+
<Template>
<TemplateName>greeter.composite.vm</TemplateName>
<TemplateTargetDir>classes</TemplateTargetDir>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org