You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/06/07 22:18:53 UTC
svn commit: r412520 - in /beehive/trunk: samples/controls-webservices-blank/
system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/
system-controls/src/webservice/control/org/apache/beehive/controls/system/webse...
Author: cschoett
Date: Wed Jun 7 13:18:52 2006
New Revision: 412520
URL: http://svn.apache.org/viewvc?rev=412520&view=rev
Log:
Some cleanup to the WSC generator Ant Task. Consoldated srcDir, srcFile and srcUrl into a single parameter: wsdlSrc.
Also fixed a minor wsdl processing bug in WsdlOpParameter for some implicit forms of an 'any' typed type.
Updated build files which were using the WSC generator ant task for parameter name change.
Modified:
beehive/trunk/samples/controls-webservices-blank/build-svn.xml
beehive/trunk/samples/controls-webservices-blank/build.xml
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java
beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlUtils.java
beehive/trunk/system-controls/test/webservice/build.xml
beehive/trunk/system-controls/test/webservice/junit/build.xml
Modified: beehive/trunk/samples/controls-webservices-blank/build-svn.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/samples/controls-webservices-blank/build-svn.xml?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/samples/controls-webservices-blank/build-svn.xml (original)
+++ beehive/trunk/samples/controls-webservices-blank/build-svn.xml Wed Jun 7 13:18:52 2006
@@ -120,7 +120,7 @@
classname="org.apache.beehive.controls.system.webservice.generator.WebServiceControlGeneratorTask"
classpathref="wscgen.dependencies"/>
- <webservice-control-gen srcdir="${schema.dir}" destdir="${gen.source.dir}" destPackageName="${my.service.control.package}"/>
+ <webservice-control-gen wsdlsrc="${schema.dir}" destdir="${gen.source.dir}" destPackageName="${my.service.control.package}"/>
<!-- have the wsdls, in the same dir as the jcx files -->
<copy todir="${gen.source.dir}/${my.service.control.package}">
Modified: beehive/trunk/samples/controls-webservices-blank/build.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/samples/controls-webservices-blank/build.xml?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/samples/controls-webservices-blank/build.xml (original)
+++ beehive/trunk/samples/controls-webservices-blank/build.xml Wed Jun 7 13:18:52 2006
@@ -105,7 +105,7 @@
classname="org.apache.beehive.controls.system.webservice.generator.WebServiceControlGeneratorTask"
classpathref="wscgen.dependencies"/>
- <webservice-control-gen srcdir="${schema.dir}" destdir="${gen.source.dir}" destPackageName="${my.service.control.package}"/>
+ <webservice-control-gen wsdlsrc="${schema.dir}" destdir="${gen.source.dir}" destPackageName="${my.service.control.package}"/>
<!-- have the wsdls, in the same dir as the jcx files -->
<copy todir="${gen.source.dir}/${my.service.control.package}">
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java Wed Jun 7 13:18:52 2006
@@ -36,9 +36,8 @@
* <li>serviceName, optional, If not set the first service in the WSDL will be used to generate the control.</li>
* <li>serviceNamespace, optional, Used in conjunction with the serviceName parameter to specify a service in the WSDL.</li>
* <li>servicePort, optional, If not set the first port in the service will be used for control generation.</li>
- * <li>srcDir, optional, If specfied all WSDL files in the directory will be processed. Either srcDir or srcFile must be set.</li>
- * <li>srcFile, optional, If specified the WSDL file will be used to generate the control.</li>
* <li>wsdlRuntimePath, optional, Specifies the location of the WSDL for the control at runtime.</li>
+ * <li>wsdlSrc, optional, Specifies the location of the WSDL(s) for control generation, must be either a URL, file or directory.</li>
* </ul>
*
* <xmp>
@@ -47,25 +46,24 @@
* classpathref="wscgen.dependency.path"/>
* <p/>
* <p/>
- * <webservice-control-gen srcDir="${build.wsdls}" destDir="${build.jcxgen}" destPackageName="${pkg.name}"/>
+ * <webservice-control-gen wsdlSrc="${build.wsdls}" destDir="${build.jcxgen}" destPackageName="${pkg.name}"/>
* </xmp>
*/
public final class WebServiceControlGeneratorTask
extends Task {
- private File _srcfile;
- private File _srcdir;
private File _destdir;
- private URL _srcURL;
-
+ private String _wsdlSrc;
private String _destPackageName;
private String _wsdlRuntimePath;
private String _serviceName;
private String _serviceNamespace;
private String _servicePortName;
-
private boolean _copyWsdl = false;
+ private File _wsdlSrcFile;
+ private URL _wsdlSrcURL;
+
//@todo: add option to compile generated service control
/**
@@ -103,7 +101,7 @@
* @param destPackageName Java package name. Package names may be of arbitrary depth, ex. xxx.yyy.zzz
*/
public void setDestPackageName(String destPackageName) {
- _destPackageName = destPackageName;
+ _destPackageName = ("".equals(destPackageName)) ? null : destPackageName;
}
/**
@@ -115,7 +113,7 @@
* @param serviceName Name of service to generate web service control from.
*/
public void setServiceName(String serviceName) {
- _serviceName = serviceName;
+ _serviceName = ("".equals(serviceName)) ? null : serviceName;
}
/**
@@ -126,7 +124,7 @@
* @param serviceNamespace Namespace of the service.
*/
public void setServiceNamespace(String serviceNamespace) {
- _serviceNamespace = serviceNamespace;
+ _serviceNamespace = ("".equals(serviceNamespace)) ? null : serviceNamespace;
}
/**
@@ -136,39 +134,42 @@
* @param servicePortName Name of the service port to use in control generation.
*/
public void setServicePort(String servicePortName) {
- _servicePortName = servicePortName;
- }
-
- /**
- * Set the source directory to generate service control(s) from. All WSDL files
- * in the directory will be processed, each one producing a service control.
- *
- * @param srcdir The directory to process WSDLs in.
- */
- public void setSrcdir(File srcdir) {
- _srcdir = srcdir;
+ _servicePortName = ("".equals(servicePortName)) ? null : servicePortName;
}
/**
- * Set the source file (wsdl) to generate the service control from.
- *
- * @param srcfile WSDL used to generate a service control.
+ * Set the wsdlSrc attribute value. Value may be in a form of a URL, file or diectory.
+ * @param src wsdlSrc attribute value.
*/
- public void setSrcfile(File srcfile) {
- _srcfile = srcfile;
+ public void setWsdlSrc(String src) {
+ _wsdlSrc = src;
+ if (!isUrl(src) && !isFile(src)) {
+ throw new BuildException("Invalid src attribute value, src must be a URL, file or directory.");
+ }
}
/**
- * Set the source url to get the WSDL file from.
- * @param urlStr
+ * Is the parameter a URL string?
+ * @param src Parameter to check.
+ * @return true if valid url.
*/
- public void setSrcUrl(String urlStr) {
+ private boolean isUrl(String src) {
try {
- _srcURL = new URL(urlStr);
+ _wsdlSrcURL = new URL(src);
}
catch (MalformedURLException e) {
- throw new BuildException("Invalid srcUrl parameter!", e);
}
+ return (_wsdlSrcURL == null) ? false : true;
+ }
+
+ /**
+ * Is the parameter a file or directory?
+ * @param src Parameter to check.
+ * @return true if file or directory.
+ */
+ private boolean isFile(String src) {
+ _wsdlSrcFile = new File(src);
+ return (_wsdlSrcFile.isFile() || _wsdlSrcFile.isDirectory());
}
/**
@@ -179,7 +180,7 @@
* @param wsdlRuntimePath The value for the WSDL path annotation.
*/
public void setWsdlRuntimePath(String wsdlRuntimePath) {
- _wsdlRuntimePath = wsdlRuntimePath;
+ _wsdlRuntimePath = ("".equals(wsdlRuntimePath)) ? null : wsdlRuntimePath;
}
/**
@@ -203,19 +204,17 @@
}
try {
- if (_srcURL != null) {
- WebServiceControlGenerator.generateWSC(_srcURL, _destdir, _destPackageName,
- _wsdlRuntimePath, _copyWsdl, serviceQName,
- _servicePortName);
+ if (_wsdlSrcURL != null) {
+ WebServiceControlGenerator.generateWSC(_wsdlSrcURL, _destdir, _destPackageName, _wsdlRuntimePath,
+ _copyWsdl, serviceQName, _servicePortName);
}
- else if (_srcfile != null) {
- WebServiceControlGenerator.generateJCX(_srcfile, _destdir, _destPackageName,
- _wsdlRuntimePath, _copyWsdl, serviceQName,
- _servicePortName);
+ else if (_wsdlSrcFile.isFile()) {
+ WebServiceControlGenerator.generateJCX(_wsdlSrcFile, _destdir, _destPackageName, _wsdlRuntimePath,
+ _copyWsdl, serviceQName, _servicePortName);
}
else {
- WebServiceControlGenerator.generateJCXs(_srcdir, _destdir, _destPackageName,
- _wsdlRuntimePath, _copyWsdl);
+ WebServiceControlGenerator.generateJCXs(_wsdlSrcFile, _destdir, _destPackageName, _wsdlRuntimePath,
+ _copyWsdl);
}
}
catch (Exception e) {
@@ -233,26 +232,15 @@
*/
private void validateAttributeSettings() {
- if (_srcfile == null && _srcdir == null && _srcURL == null) {
+ if (_wsdlSrc == null) {
throw new BuildException("The srcFile, srcDir or srcUrl attribute must be set");
}
- if (_srcfile != null && _srcdir != null) {
- throw new BuildException("The srcFile and srcDir attributes are both set");
- }
-
- if (_srcfile != null && !_srcfile.isFile()) {
- throw new BuildException("The srcFile must be a file");
- }
-
- if (_srcfile == null && _srcURL == null && _serviceName != null) {
+ if ((_wsdlSrcFile != null && _wsdlSrcFile.isDirectory())
+ && (_serviceName != null && !"".equals(_serviceName))) {
throw new BuildException("The serviceName attribute can only be used with the srcFile or srcUrl attributes");
}
- if (_srcdir != null && !_srcdir.isDirectory()) {
- throw new BuildException("The srcDir must be a directory");
- }
-
if (_destdir == null) {
throw new BuildException("The destDir attribute must be set");
}
@@ -261,7 +249,7 @@
throw new BuildException("destDir must be a directory");
}
- if (_wsdlRuntimePath != null && _copyWsdl) {
+ if ((_wsdlRuntimePath != null && !"".equals(_wsdlRuntimePath)) && _copyWsdl) {
log("Warning: 'wsdlRuntimePath' and 'copyWsdl' attributes have both been set. The generated web service control will use the value of 'wsdlRuntimePath' to locate the WSDL file at runtime.");
}
}
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java Wed Jun 7 13:18:52 2006
@@ -200,6 +200,16 @@
</complexType>
</element>
+ or
+
+ <element name="foo">
+ <complexType>
+ <sequence>
+ <any/>
+ </sequence>
+ </complexType>
+ </element>
+
This code is extremely brittle, this is a construct used
by dot net when DataTypes are employed. The code will need to be enhanced
if other samples of this construct arise.
@@ -207,17 +217,25 @@
Element child;
if ((child = DomUtils.getChildElementByName(element, WsdlUtils.COMPLEX_TYPE_NAME)) != null) {
if ((child = DomUtils.getChildElementByName(child, WsdlUtils.SEQUENCE_TAG_NAME)) != null) {
- if ((child = DomUtils.getChildElementByName(child, WsdlUtils.ELEMENT_NAME)) != null) {
+ Element childElement = DomUtils.getChildElementByName(child, WsdlUtils.ELEMENT_NAME);
+ if (childElement != null) {
if (child.hasAttribute(WsdlUtils.ELEMENT_REF_ATTR)) {
return wsdlTypes.getTypeQName(child.getAttribute(WsdlUtils.ELEMENT_REF_ATTR));
}
else if (child.hasAttribute(WsdlUtils.ELEMENT_TYPE_ATTR)) {
- return wsdlTypes.getTypeQName(child.getAttribute(WsdlUtils.ELEMENT_REF_ATTR));
+ return wsdlTypes.getTypeQName(child.getAttribute(WsdlUtils.ELEMENT_TYPE_ATTR));
}
}
+ else if ((childElement = DomUtils.getChildElementByName(child, WsdlUtils.ANY_TAG_NAME)) != null) {
+ return new QName(childElement.getNamespaceURI(), childElement.getLocalName());
+ }
}
}
- throw new RuntimeException("Cannot determine type of element: " + element.getNodeName());
+ else {
+ // no children / no type map to 'any'
+ return new QName("", "any");
+ }
+ throw new RuntimeException("Cannot determine type of element: " + getName());
}
/**
Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlUtils.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlUtils.java?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlUtils.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlUtils.java Wed Jun 7 13:18:52 2006
@@ -33,6 +33,7 @@
// schema names
protected static final String ELEMENT_FORM_DEFAULT_ATTR = "elementFormDefault";
+ protected static final String ANY_TAG_NAME = "any";
protected static final String TARGET_NAMESPACE_ATTR = "targetNamespace";
protected static final String ELEMENT_FORM_QUALIFIED = "qualified";
protected static final String ELEMENT_NAME = "element";
Modified: beehive/trunk/system-controls/test/webservice/build.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/webservice/build.xml?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/system-controls/test/webservice/build.xml (original)
+++ beehive/trunk/system-controls/test/webservice/build.xml Wed Jun 7 13:18:52 2006
@@ -253,7 +253,7 @@
classname="org.apache.beehive.controls.system.webservice.generator.WebServiceControlGeneratorTask"
classpathref="client.classpath"/>
- <webservice-control-gen srcdir="${schematypes.wsdls.dir}" destdir="${client.wscgensrc}"
+ <webservice-control-gen wsdlsrc="${schematypes.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="yes" destPackageName="schematypestest"/>
<!-- now gen the wsc's which require type support from xmlbeans and axis -->
@@ -281,7 +281,7 @@
</fileset>
</xmlbeanbuild>
- <webservice-control-gen srcdir="${xmlbeangen.wsdls.dir}" destdir="${client.wscgensrc}"
+ <webservice-control-gen wsdlsrc="${xmlbeangen.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="yes" destPackageName="xmlbeangentest"/>
</target>
@@ -295,14 +295,14 @@
<axisbeanbuild wsdldir="${axisgen.wsdls.dir}" outputdir="${client.axisgen}"/>
<javac srcdir="${client.axisgen}" destdir="${client.classes}" classpathref="client.classpath" debug="true"/>
- <webservice-control-gen srcdir="${axisgen.wsdls.dir}" destdir="${client.wscgensrc}"
+ <webservice-control-gen wsdlsrc="${axisgen.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="true" destPackageName="axisgentest"/>
</target>
<target name="gen.pojo.wscs" description="Build wsc's which use pre-existing java classes generation.">
<javac srcdir="${types-source.dir}" destdir="${client.classes}" classpathref="client.classpath" debug="true"/>
- <webservice-control-gen srcdir="${pojotypes.wsdls.dir}" destdir="${client.wscgensrc}"
+ <webservice-control-gen wsdlsrc="${pojotypes.wsdls.dir}" destdir="${client.wscgensrc}"
copyWsdl="yes" destPackageName="pojotypetest"/>
</target>
Modified: beehive/trunk/system-controls/test/webservice/junit/build.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/webservice/junit/build.xml?rev=412520&r1=412519&r2=412520&view=diff
==============================================================================
--- beehive/trunk/system-controls/test/webservice/junit/build.xml (original)
+++ beehive/trunk/system-controls/test/webservice/junit/build.xml Wed Jun 7 13:18:52 2006
@@ -101,37 +101,37 @@
classpathref="wscgen.classpath"/>
<!-- general task tests -->
- <webservice-control-gen srcdir="${wsdls.dir}"
+ <webservice-control-gen wsdlsrc="${wsdls.dir}"
destdir="${wscgen.gensrc}"/>
<!-- *** task parameter / settings tests *** -->
<!-- wsdl runtime path not set -->
- <webservice-control-gen srcfile="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
+ <webservice-control-gen wsdlsrc="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
destdir="${wscgen.gensrc}"
destPackageName="test1"/>
<!-- wsdl runtime path set to location of generated control-->
- <webservice-control-gen srcfile="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
+ <webservice-control-gen wsdlsrc="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
destdir="${wscgen.gensrc}"
copyWsdl="yes"
destPackageName="test2"/>
<!-- wsdl runtime path explicitly set -->
- <webservice-control-gen srcfile="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
+ <webservice-control-gen wsdlsrc="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
destdir="${wscgen.gensrc}"
wsdlRuntimePath="/tmp"
destPackageName="test3"/>
<!-- wsdl runtime path explicitly set, so is copyWsdl -->
- <webservice-control-gen srcfile="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
+ <webservice-control-gen wsdlsrc="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
destdir="${wscgen.gensrc}"
wsdlRuntimePath="/tmp/"
copyWsdl="yes"
destPackageName="test4"/>
<!-- explictly set the service name and port name we are looking for -->
- <webservice-control-gen srcfile="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
+ <webservice-control-gen wsdlsrc="${wsdls.settings.dir}/TaskGeneratorTest.wsdl"
destdir="${wscgen.gensrc}"
copyWsdl="yes"
serviceName="TestService1"