You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by ry...@apache.org on 2006/04/26 19:10:46 UTC
svn commit: r397240 - in /incubator/woden/java: ant-test/ ant-test/build.xml
src/org/apache/woden/ant/ValidateWSDL20.java
Author: ryman
Date: Wed Apr 26 10:10:46 2006
New Revision: 397240
URL: http://svn.apache.org/viewcvs?rev=397240&view=rev
Log:
[WODEN-9} Added WSDL 2.0 Component Model Interchange Format output to Ant task.
Modified:
incubator/woden/java/ant-test/ (props changed)
incubator/woden/java/ant-test/build.xml
incubator/woden/java/src/org/apache/woden/ant/ValidateWSDL20.java
Propchange: incubator/woden/java/ant-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Apr 26 10:10:46 2006
@@ -0,0 +1,2 @@
+
+interchange
Modified: incubator/woden/java/ant-test/build.xml
URL: http://svn.apache.org/viewcvs/incubator/woden/java/ant-test/build.xml?rev=397240&r1=397239&r2=397240&view=diff
==============================================================================
--- incubator/woden/java/ant-test/build.xml (original)
+++ incubator/woden/java/ant-test/build.xml Wed Apr 26 10:10:46 2006
@@ -2,14 +2,14 @@
<project default="main" basedir=".">
<property file="../build.properties" />
- <property name="libdir" location="../build"/>
- <property name="downloadslibdir" location="../downloads/lib"/>
+ <property name="libdir" location="../build" />
+ <property name="downloadslibdir" location="../downloads/lib" />
- <target name="main">
- <taskdef name="validatewsdl20" classname="org.apache.woden.ant.ValidateWSDL20" classpath="${libdir}/woden.jar;${downloadslibdir}/${XmlSchemaFile}" />
- <validatewsdl20 dir="." includes="**/*.wsdl" verbose="yes">
- </validatewsdl20>
- </target>
-
+ <target name="main">
+ <taskdef name="validatewsdl20" classname="org.apache.woden.ant.ValidateWSDL20" classpath="${libdir}/woden.jar;${downloadslibdir}/${XmlSchemaFile};${downloadslibdir}/${XercesJar1};${downloadslibdir}/${XercesJar2}" />
+ <validatewsdl20 dir="." includes="**/*.wsdl" verbose="no" cm="yes" cmdir="interchange">
+ </validatewsdl20>
+ </target>
+
</project>
Modified: incubator/woden/java/src/org/apache/woden/ant/ValidateWSDL20.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/ant/ValidateWSDL20.java?rev=397240&r1=397239&r2=397240&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/ant/ValidateWSDL20.java (original)
+++ incubator/woden/java/src/org/apache/woden/ant/ValidateWSDL20.java Wed Apr 26 10:10:46 2006
@@ -1,6 +1,10 @@
package org.apache.woden.ant;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
import javax.xml.namespace.QName;
@@ -32,6 +36,18 @@
* The <code>verbose</code> attribute is a boolean flag that enables verbose
* output.
*
+ * The <code>cm</code> attribute is a boolean flag that enables Component
+ * Model interchange format output</code>. The default is false.
+ *
+ * The <code>cmdir</code> attribute is a file directory for the Component
+ * Model interchange format output files. This is ignored if <code>cm</code>
+ * is false. The default is to use the input directory as specified by the
+ * <code>dir</code> attribute.
+ *
+ * The <code>cmext</code> attribute is the file extension to use for the
+ * Component Model interchange format output files. This is ignored if <code>cm</code>
+ * is false. The default is <code>.wsdlcm</code>.
+ *
* @author Arthur Ryman, ryman@ca.ibm.com
*
*/
@@ -47,6 +63,18 @@
// flag to enable verbose output
private boolean verbose = false;
+ // flag to enable Component Model interchange format output
+ private boolean cm = false;
+
+ // directory for Component Model interchange format output
+ private File cmdir;
+
+ // extension for Component Model interchange format output
+ private String cmext;
+
+ // default extension for Component Model interchange format output
+ private static final String CMEXT_DEFAULT = ".wsdlcm";
+
public File getDir() {
return this.dir;
}
@@ -71,7 +99,58 @@
return verbose;
}
-public void execute() throws BuildException {
+ public void setCm(boolean cm) {
+ this.cm = cm;
+ }
+
+ public boolean isCm() {
+ return cm;
+ }
+
+ public void setCmdir(File cmdir) {
+ this.cmdir = cmdir;
+ }
+
+ public File getCmdir() {
+ return cmdir;
+ }
+
+ public void setCmext(String cmext) {
+ this.cmext = cmext;
+ }
+
+ public String getCmext() {
+ return cmext;
+ }
+
+ public void execute() throws BuildException {
+
+ // check the cm input attributes and set defaults if necessary
+ if (isCm()) {
+ File cmdir = getCmdir();
+ if (cmdir == null) {
+
+ // default cmdir to dir
+ cmdir = getDir();
+ setCmdir(cmdir);
+ }
+
+ if (!cmdir.isDirectory()) {
+
+ // cmdir MUST be a directory
+ System.out.println("Invalid cm output directory: " + cmdir.toString());
+
+ // disable cm output
+ setCm(false);
+ }
+
+ String cmext = getCmext();
+ if (cmext == null) {
+
+ //default cmext
+ setCmext(CMEXT_DEFAULT);
+ }
+ }
WSDLReader reader = null;
@@ -130,6 +209,11 @@
// <-- the Description component
Description descComp = desc.toComponent();
+
+ if (isCm()) {
+ // write the Component Model interchange format output file
+ writeCm(descComp, files[i]);
+ }
if (isVerbose()) {
@@ -150,13 +234,15 @@
TypeDefinition typeDefinitions[] = descComp
.getTypeDefinitions();
- System.out.println("There are " + typeDefinitions.length + " TypeDefinition components.");
-
+ System.out.println("There are " + typeDefinitions.length
+ + " TypeDefinition components.");
+
for (int j = 0; j < typeDefinitions.length; j++) {
TypeDefinition typeDefinition = typeDefinitions[j];
-
- QName name= typeDefinition.getName();
- System.out.println("TypeDefinition[" + j + "] : name = " + name);
+
+ QName name = typeDefinition.getName();
+ System.out.println("TypeDefinition[" + j
+ + "] : name = " + name);
}
Interface interfaces[] = descComp.getInterfaces();
@@ -193,6 +279,29 @@
} catch (WSDLException e) {
throw new BuildException(e);
+ } catch (IOException ioe) {
+
+ throw new BuildException(ioe);
}
+
}
- }}
+ }
+
+ private void writeCm(Description descComp, String file) throws IOException {
+
+ // replace the file extension
+
+ int dot = file.lastIndexOf('.');
+ String base = dot == -1 ? file : file.substring(0, dot);
+ String ext = getCmext();
+ String cmfilename = base + ext;
+ File cmfile = new File(cmdir, cmfilename);
+
+ FileOutputStream fos = new FileOutputStream(cmfile);
+ PrintWriter out = new PrintWriter(fos);
+ WsdlCm wsdlCm = new WsdlCm(out);
+ wsdlCm.write(descComp);
+ out.close();
+ fos.close();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org