You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by br...@apache.org on 2006/06/05 14:38:49 UTC
svn commit: r411803 - in /incubator/yoko/trunk: ./ tools/
tools/src/main/java/org/apache/yoko/tools/common/
tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/
tools/src/main/java/org/apache/yoko/tools/processors/idl/
tools/src/test/ja...
Author: bravi
Date: Mon Jun 5 07:38:48 2006
New Revision: 411803
URL: http://svn.apache.org/viewvc?rev=411803&view=rev
Log:
Adding the idltowsdl tool.
Added:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java (with props)
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/idl.g
incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java (with props)
incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java (with props)
incubator/yoko/trunk/tools/src/test/resources/idl/
incubator/yoko/trunk/tools/src/test/resources/idl/HelloWorld.idl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl (with props)
incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml (with props)
Modified:
incubator/yoko/trunk/pom.xml
incubator/yoko/trunk/tools/pom.xml
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/CORBAConstants.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
Modified: incubator/yoko/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/pom.xml?rev=411803&r1=411802&r2=411803&view=diff
==============================================================================
--- incubator/yoko/trunk/pom.xml (original)
+++ incubator/yoko/trunk/pom.xml Mon Jun 5 07:38:48 2006
@@ -136,10 +136,35 @@
</plugin> -->
</plugins>
<defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.1.3</version>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*$*</exclude>
+ </excludes>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile>
+ <forkMode>once</forkMode>
+ <childDelegation>false</childDelegation>
+ <argLine>-ea</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
</build>
<reporting>
- <plugins>
+ <plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
Modified: incubator/yoko/trunk/tools/pom.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/pom.xml?rev=411803&r1=411802&r2=411803&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/pom.xml (original)
+++ incubator/yoko/trunk/tools/pom.xml Mon Jun 5 07:38:48 2006
@@ -40,9 +40,42 @@
<artifactId>yoko-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
-
+ <dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>2.7.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.0.2</version>
+ </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antlr-plugin</artifactId>
+ <version>2.0-beta-1</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <outputDirectory>${basedir}/src/main/java</outputDirectory>
+ <grammars>idl.g</grammars>
+ <sourceDirectory>${basedir}/src/main/java/org/apache/yoko/tools/processors/idl</sourceDirectory>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+ </plugins>
+ </build>
<profiles>
<profile>
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/CORBAConstants.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/CORBAConstants.java?rev=411803&r1=411802&r2=411803&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/CORBAConstants.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/CORBAConstants.java Mon Jun 5 07:38:48 2006
@@ -6,6 +6,10 @@
String NP_WSDL_CORBA = "corba";
String NU_WSDL_CORBA = "http://schemas.apache.org/yoko/bindings/corba";
+ String NP_TM_CORBA = "corbatm";
+ String NU_TM_CORBA = "http://schemas.apache.org/yoko/typemap/corba/";
+ String SCHEMA_NS_URI = "http://schemas.apache.org/yoko/idltypes/";
+ String WSDL_NS_URI = "http://schemas.apache.org/yoko/idl/";
// CORBA Binding Extensibility Elements
QName NE_CORBA_ADDRESS = new QName(NU_WSDL_CORBA, "address", NP_WSDL_CORBA);
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java?rev=411803&r1=411802&r2=411803&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java Mon Jun 5 07:38:48 2006
@@ -7,4 +7,9 @@
public static final String CFG_IDL = "idl";
public static final String CFG_WSDLOUTPUT = "wsdlOutput";
public static final String CFG_IDLOUTPUT = "idlOutput";
-}
\ No newline at end of file
+
+ public static final String CFG_IDLFILE = "idl";
+ public static final String CFG_TNS = "tns";
+ public static final String CFG_SCHEMA = "schema";
+ public static final String CFG_IMPORTSCHEMA = "importschema";
+}
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml Mon Jun 5 07:38:48 2006
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- The xhtml namespace is for usage documentation -->
+<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
+ xsi:schemaLocation="http://www.xsume.com/Xutil/ToolSpecification http://www.xsume.com/schema/xutil/tool-specification.xsd"
+ xmlns="http://www.xsume.com/Xutil/ToolSpecification"
+ xmlns:ts="http://www.xsume.com/Xutil/ToolSpecification">
+
+ <annotation> Examples :
+ idltowsdl HelloWorld.idl
+ idltowsdl -o HelloWorld HelloWorld.idl
+ idltowsdl -w http://www.mycompany.com/schemas HelloWorld.idl
+ idltowsdl -f HelloWorld.ior -interface HelloWorld HellowWorld.idl
+ </annotation>
+
+ <usage>
+
+ <optionGroup id="options">
+
+ <option id="includedir" maxOccurs="unbounded">
+ <annotation>Specify a directory to be included in the search path for the IDL preprocessor.</annotation>
+ <switch>I</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>idl-include-directory</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="outputdir" maxOccurs="1">
+ <annotation>The wsdl output directory.</annotation>
+ <switch>o</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>output-directory</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="address" maxOccurs="1">
+ <annotation>Specify the value to be used for the corba:address location attribute.</annotation>
+ <switch>a</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>corba-address</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="boundedstrings" maxOccurs="1">
+ <annotation>Treat bounded strings as unbounded.</annotation>
+ <switch>b</switch>
+ </option>
+
+ <option id="addressfile" maxOccurs="1">
+ <annotation>Use the contents of file as the value for the corba:address locationattribute.</annotation>
+ <switch>f</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>corba-address-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="importschema" maxOccurs="1">
+ <annotation>Do not generate schema types, but instead import them from file.</annotation>
+ <switch>n</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>schema-import-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="sequencetype" maxOccurs="1">
+ <annotation>Specify the XML Schema type used for the IDL sequence octet type.
+ Valid option values for type are base64Binary and hexBinary. The default is base64Binary.</annotation>
+ <switch>s</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>idl-sequence-type</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="tns" maxOccurs="1">
+ <annotation>Specify the target namespace to use in the wsdl.</annotation>
+ <switch>w</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>target-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="schemans" maxOccurs="1">
+ <annotation>Specify the schema namespace to use in the wsdl.</annotation>
+ <switch>x</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>schema-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="corbatypemapns" maxOccurs="1">
+ <annotation>Specify the corba type map target namespace to use in the wsdl.</annotation>
+ <switch>t</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>corba-type-map target-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+
+ <option id="referenceimport" maxOccurs="1">
+ <annotation>Specify the pathname of the schema file imported to define the Reference type.</annotation>
+ <switch>r</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>reference-schema-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="logical" maxOccurs="1">
+ <annotation>Split the generated WSDL into two files.
+ The logical portion of the WSDL is generated into the specified file.
+ The physical portion is generated into the default output file, unless -P is also used.</annotation>
+ <switch>L</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>logical-wsdl-filename</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="physical" maxOccurs="1">
+ <annotation>Split the generated WSDL into two files.
+ The physical portion of the WSDL is generated into specified file.
+ The logical portion is generated into the default output file, unless -L is also used.</annotation>
+ <switch>P</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>physical-wsdl-filename</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="schema" maxOccurs="1">
+ <annotation>Generate schema types into the specified file.
+ The file is then imported back into the logical portion of the generated WSDL.
+ This option cannot be used with -n.</annotation>
+ <switch>T</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>schema-file-name</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="interface" maxOccurs="1">
+ <annotation>Specify the interface name within idl to use during fast track process.</annotation>
+ <switch>interface</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>interface-name</annotation>
+ </associatedArgument>
+ </option>
+
+
+ <option id="qualified" maxOccurs="1">
+ <annotation>Generate qualified wsdl contract</annotation>
+ <switch>qualified</switch>
+ </option>
+
+ <option id="inline" maxOccurs="1">
+ <annotation>In-line imported schema</annotation>
+ <switch>inline</switch>
+ </option>
+
+ <option id="encoding" maxOccurs="1">
+ <annotation>Use specified encoding as the value of the generated WSDL xml encoding attribute.
+ Defaults to UTF-8.</annotation>
+ <switch>e</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>xml-encoding-type</annotation>
+ </associatedArgument>
+ </option>
+
+ </optionGroup>
+
+ <optionGroup id="common_options">
+ <option id="help" maxOccurs="1">
+ <annotation>Display detailed information for options.</annotation>
+ <switch>h</switch>
+ <switch>?</switch>
+ <switch>help</switch>
+ </option>
+
+ <option id="version">
+ <annotation>Display the version of the tool.</annotation>
+ <switch>v</switch>
+ </option>
+
+ <option id="verbose">
+ <annotation>Verbose mode</annotation>
+ <switch>verbose</switch>
+ <switch>V</switch>
+ </option>
+
+ <option id="quiet">
+ <annotation>Quiet mode</annotation>
+ <switch>quiet</switch>
+ <switch>q</switch>
+ </option>
+
+
+ </optionGroup>
+
+ <argument id="idl" minOccurs="1" maxOccurs="1">
+ <annotation>idl-file-name</annotation>
+ </argument>
+ </usage>
+
+
+
+</toolspec>
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/idl2wsdl.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,89 @@
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.ASTVisitor;
+import antlr.DumpASTVisitor;
+import antlr.collections.AST;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.StringTokenizer;
+
+import javax.wsdl.Definition;
+
+import org.objectweb.celtix.tools.common.Processor;
+import org.objectweb.celtix.tools.common.ProcessorEnvironment;
+import org.objectweb.celtix.tools.common.ToolException;
+
+import org.apache.yoko.tools.common.CORBAConstants;
+import org.apache.yoko.tools.common.ToolCorbaConstants;
+import org.apache.yoko.tools.common.W3CConstants;
+
+public class IDLToWSDLProcessor implements Processor {
+
+ private String idl;
+ private ProcessorEnvironment env;
+ private OutputStream outStream;
+
+ public void process() throws ToolException {
+ Definition def = null;
+ idl = getBaseFilename(env.get(ToolCorbaConstants.CFG_IDLFILE).toString());
+ try {
+ parseIDL();
+ } catch (Exception e) {
+ throw new ToolException(e);
+ }
+ }
+
+ public void setOutputStream(OutputStream out) {
+ outStream = out;
+ }
+
+ public void parseIDL() throws Exception {
+ InputStream stream = new FileInputStream(env.get(ToolCorbaConstants.CFG_IDLFILE).toString());
+ IDLParser parser = new IDLParser(new IDLLexer(stream));
+ parser.specification();
+ AST idlTree = parser.getAST();
+
+ String tns = (String) env.get(ToolCorbaConstants.CFG_TNS);
+ if (tns == null) {
+ tns = CORBAConstants.WSDL_NS_URI + idl;
+ }
+
+ try {
+ WSDLASTVisitor visitor = new WSDLASTVisitor(tns);
+ visitor.visit(idlTree);
+ if (outStream == null) {
+ java.io.File file = new java.io.File(idl + ".wsdl");
+ outStream = new java.io.FileOutputStream(file);
+ }
+ visitor.writeDefinition(outStream);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new ToolException(ex.getMessage(), ex);
+ }
+ }
+
+ public void setEnvironment(ProcessorEnvironment penv) {
+ env = penv;
+ }
+
+ public ProcessorEnvironment getEnvironment() {
+ return env;
+ }
+
+ public String getBaseFilename(String ifile) {
+ String fileName = ifile;
+ StringTokenizer token = new StringTokenizer(ifile, "\\/");
+
+ while (token.hasMoreTokens()) {
+ fileName = token.nextToken();
+ }
+ if (fileName.endsWith(".idl")) {
+ fileName = new String(fileName.substring(0, fileName.length() - 4));
+ }
+ return fileName;
+ }
+
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,104 @@
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+
+import javax.xml.namespace.QName;
+
+public class MessagePartVisitor implements ASTVisitor {
+
+ Definition definition;
+ WSDLFactory wsdlFactory;
+ Message inputMsg;
+ Message outputMsg;
+
+ TypesVisitor typesVisitor;
+
+ public MessagePartVisitor(WSDLASTVisitor visitor) {
+ definition = visitor.getDefinition();
+ typesVisitor = visitor.getTypesVisitor();
+ }
+
+ public void setInputMessage(Message msg) {
+ inputMsg = msg;
+ }
+
+ public void setOutputMessage(Message msg) {
+ outputMsg = msg;
+ }
+
+ public Message getInputMessage() {
+ return inputMsg;
+ }
+
+ public Message getOutputMessage() {
+ return outputMsg;
+ }
+
+ //Assumption for now is to generate wrapped doc-literal wsdl.
+
+ public void visit(AST node) {
+ switch (node.getType()) {
+ case IDLTokenTypes.LITERAL_in: {
+ AST typeNode = node.getFirstChild();
+ AST partName = typeNode.getNextSibling();
+ createInputPart(partName.toString(), typeNode);
+ break;
+ }
+ case IDLTokenTypes.LITERAL_inout: {
+ AST typeNode = node.getFirstChild();
+ AST partName = typeNode.getNextSibling();
+ createInputPart(partName.toString(), typeNode);
+ createOutputPart(partName.toString(), typeNode);
+ break;
+ }
+ case IDLTokenTypes.LITERAL_out: {
+ AST typeNode = node.getFirstChild();
+ AST partName = typeNode.getNextSibling();
+ createOutputPart(partName.toString(), typeNode);
+ break;
+ }
+ default: {
+ createOutputPart("return", node);
+ }
+ }
+ }
+
+ private void createInputPart(String partName, AST typeNode) {
+ Part part;
+ QName element = inputMsg.getQName();
+ if (inputMsg.getParts().size() == 0) {
+ part = definition.createPart();
+ part.setName("parameters");
+ part.setElementName(element);
+ typesVisitor.addElement(element);
+ inputMsg.addPart(part);
+ } else {
+ part = (Part) inputMsg.getParts().get(0);
+ }
+ typesVisitor.setCurrentPart(element, partName);
+ typesVisitor.visit(typeNode);
+ }
+
+ private void createOutputPart(String partName, AST typeNode) {
+ Part part;
+ QName element = outputMsg.getQName();
+ if (outputMsg.getParts().size() == 0) {
+ part = definition.createPart();
+ part.setName("parameters");
+ part.setElementName(element);
+ typesVisitor.addElement(element);
+ outputMsg.addPart(part);
+ } else {
+ part = (Part) outputMsg.getParts().get(0);
+ }
+ typesVisitor.setCurrentPart(element, partName);
+ typesVisitor.visit(typeNode);
+ }
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,91 @@
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+
+import javax.xml.namespace.QName;
+
+public class MessageVisitor implements ASTVisitor {
+
+ Definition definition;
+
+ Operation operation;
+ MessagePartVisitor partVisitor;
+
+ public MessageVisitor(WSDLASTVisitor visitor) {
+ definition = visitor.getDefinition();
+ partVisitor = new MessagePartVisitor(visitor);
+ }
+
+ public void setOperation(Operation op) {
+ operation = op;
+ }
+
+ public void visit(AST node) {
+ AST node2 = node.getFirstChild();
+ while (node2 != null) {
+ switch (node2.getType()) {
+ case IDLTokenTypes.LITERAL_in: {
+ if (partVisitor.getInputMessage() == null) {
+ partVisitor.setInputMessage(createInputMessage());
+ }
+ break;
+ }
+ case IDLTokenTypes.LITERAL_inout: {
+ if (partVisitor.getInputMessage() == null) {
+ partVisitor.setInputMessage(createInputMessage());
+ }
+ if (partVisitor.getOutputMessage() == null) {
+ partVisitor.setOutputMessage(createOutputMessage());
+ }
+ break;
+ }
+ case IDLTokenTypes.LITERAL_out: {
+ if (partVisitor.getOutputMessage() == null) {
+ partVisitor.setOutputMessage(createOutputMessage());
+ }
+ break;
+ }
+ default: {
+ if (partVisitor.getOutputMessage() == null) {
+ partVisitor.setOutputMessage(createOutputMessage());
+ }
+ }
+ }
+ partVisitor.visit(node2);
+ node2 = node2.getNextSibling();
+ }
+ }
+
+ private Message createInputMessage() {
+ Input input = definition.createInput();
+ Message msg = definition.createMessage();
+ msg.setQName(new QName(definition.getTargetNamespace(), operation.getName()));
+ input.setMessage(msg);
+ input.setName(operation.getName() + "Request");
+ msg.setUndefined(false);
+ operation.setInput(input);
+ definition.addMessage(msg);
+ return msg;
+ }
+
+ private Message createOutputMessage() {
+ Output output = definition.createOutput();
+ Message msg = definition.createMessage();
+ msg.setQName(new QName(definition.getTargetNamespace(), operation.getName() + "Response"));
+ output.setMessage(msg);
+ output.setName(operation.getName() + "Response");
+ msg.setUndefined(false);
+ operation.setOutput(output);
+ definition.addMessage(msg);
+ return msg;
+ }
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,43 @@
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+
+import javax.xml.namespace.QName;
+
+public class PortTypeVisitor implements ASTVisitor {
+
+ Definition definition;
+ PortType portType;
+
+ MessageVisitor msgVisitor;
+
+ public PortTypeVisitor(WSDLASTVisitor visitor) {
+ definition = visitor.getDefinition();
+ msgVisitor = new MessageVisitor(visitor);
+ }
+
+ public void visit(AST node) {
+ portType = definition.createPortType();
+ AST node2 = node.getFirstChild();
+ portType.setQName(new QName(definition.getTargetNamespace(), node2.toString()));
+ node2 = node2.getNextSibling();
+ visitOperation(node2);
+ portType.setUndefined(false);
+ definition.addPortType(portType);
+ }
+
+ public void visitOperation(AST node) {
+ Operation op = definition.createOperation();
+ op.setName(node.toString());
+ msgVisitor.setOperation(op);
+ msgVisitor.visit(node);
+ op.setUndefined(false);
+ portType.addOperation(op);
+ }
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,44 @@
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.constants.Constants;
+
+public class PrimitiveTypesVisitor implements ASTVisitor {
+
+ XmlSchema schema;
+ XmlSchemaCollection schemas;
+ XmlSchemaType schemaType;
+
+ public PrimitiveTypesVisitor(XmlSchemaCollection xmlSchemas, XmlSchema xmlSchema) {
+ schemas = xmlSchemas;
+ schema = xmlSchema;
+ }
+
+ public XmlSchemaType getSchemaType() {
+ return schemaType;
+ }
+
+
+ public void visit(AST node) {
+ switch (node.getType()) {
+ case IDLTokenTypes.LITERAL_string: {
+ schemaType = schemas.getTypeByQName(Constants.XSD_STRING);
+ break;
+ }
+ }
+ }
+
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PrimitiveTypesVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,85 @@
+package org.apache.yoko.tools.processors.idl;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.factory.WSDLFactory;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSerializer;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+public class TypesVisitor implements ASTVisitor {
+
+ Definition definition;
+ WSDLFactory wsdlFactory;
+
+ XmlSchema schema;
+ XmlSchemaCollection schemas;
+ XmlSchemaObject currentType;
+ List<String> parts = new ArrayList<String>();
+
+ public TypesVisitor(WSDLASTVisitor visitor) {
+ definition = visitor.getDefinition();
+ schemas = new XmlSchemaCollection();
+ schema = new XmlSchema(definition.getTargetNamespace(), schemas);
+ }
+
+ public void attachSchema() throws Exception {
+ Types types = definition.createTypes();
+ Schema wsdlSchema = (Schema) definition.getExtensionRegistry().createExtension(Types.class,
+ new QName("http://www.w3.org/2001/XMLSchema",
+ "schema"));
+ XmlSchemaObjectTable table = schema.getElements();
+ org.w3c.dom.Element el = XmlSchemaSerializer.serializeSchema(schema, true)[0].getDocumentElement();
+ org.w3c.dom.NodeList list = el.getChildNodes();
+ wsdlSchema.setElement(el);
+ types.addExtensibilityElement(wsdlSchema);
+ definition.setTypes(types);
+ }
+
+
+ public void addElement(QName el) {
+ XmlSchemaElement element = new XmlSchemaElement();
+ element.setQName(el);
+ element.setName(el.getLocalPart());
+ schema.getElements().add(el, element);
+ schema.getItems().add(element);
+ }
+
+ public void setCurrentPart(QName el, String name) {
+ //get the element & check if a type has been set
+ XmlSchemaElement element = (XmlSchemaElement) schema.getElements().getItem(el);
+ if (element.getSchemaType() == null) {
+ currentType = element;
+ parts.add(name);
+ }
+ }
+
+ public void visit(AST node) {
+ //only handling primitive types
+ PrimitiveTypesVisitor visitor = new PrimitiveTypesVisitor(schemas, schema);
+ visitor.visit(node);
+ if (currentType instanceof XmlSchemaElement) {
+ ((XmlSchemaElement) currentType).setSchemaTypeName(visitor.getSchemaType().getQName());
+ }
+ }
+
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,67 @@
+package org.apache.yoko.tools.processors.idl;
+
+import java.io.OutputStream;
+
+import antlr.ASTVisitor;
+import antlr.collections.AST;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+
+import org.objectweb.celtix.tools.common.WSDLConstants;
+
+public class WSDLASTVisitor implements ASTVisitor {
+
+ Definition definition;
+ WSDLFactory wsdlFactory;
+ PortTypeVisitor portTypeVisitor;
+ TypesVisitor typesVisitor;
+
+ public WSDLASTVisitor(String tns) throws WSDLException {
+ wsdlFactory = WSDLFactory.newInstance();
+ definition = wsdlFactory.newDefinition();
+ definition.setTargetNamespace(tns);
+ definition.addNamespace(WSDLConstants.WSDL_PREFIX, WSDLConstants.NS_WSDL);
+ definition.addNamespace(WSDLConstants.XSD_PREFIX, WSDLConstants.XSD_NAMESPACE);
+ definition.addNamespace(WSDLConstants.SOAP_PREFIX, WSDLConstants.SOAP11_NAMESPACE);
+ definition.addNamespace(WSDLConstants.TNS_PREFIX, tns);
+ initVisitors();
+ }
+
+ public void visit(AST node) {
+ switch (node.getType()) {
+ case IDLTokenTypes.LITERAL_interface: {
+ portTypeVisitor.visit(node);
+ }
+ break;
+ default: System.out.println("Visit for node: " + node.getType() + ":" + node);
+ }
+ }
+
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ public WSDLFactory getFactory() {
+ return wsdlFactory;
+ }
+
+ public TypesVisitor getTypesVisitor() {
+ return typesVisitor;
+ }
+
+ private void initVisitors() {
+ typesVisitor = new TypesVisitor(this);
+ portTypeVisitor = new PortTypeVisitor(this);
+ }
+
+ public boolean writeDefinition(OutputStream outstream) throws Exception {
+ typesVisitor.attachSchema();
+ WSDLWriter writer = wsdlFactory.newWSDLWriter();
+ writer.writeWSDL(definition, outstream);
+ return true;
+ }
+
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/idl.g
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/idl.g?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/idl.g (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/idl.g Mon Jun 5 07:38:48 2006
@@ -0,0 +1,1389 @@
+header {
+ package org.apache.yoko.tools.processors.idl;
+
+ import java.io.*;
+ import java.util.Vector;
+ import java.util.Hashtable;
+ }
+
+/**
+ * This is a complete parser for the IDL language as defined
+ * by the CORBA 3.0.2 specification. It will allow those who
+ * need an IDL parser to get up-and-running very quickly.
+ * Though IDL's syntax is very similar to C++, it is also
+ * much simpler, due in large part to the fact that it is
+ * a declarative-only language.
+ *
+ * Some things that are not included are: Symbol table construction
+ * (it is not necessary for parsing, btw) and preprocessing (for
+ * IDL compiler #pragma directives). You can use just about any
+ * C or C++ preprocessor, but there is an interesting semantic
+ * issue if you are going to generate code: In C, #include is
+ * a literal include, in IDL, #include is more like Java's import:
+ * It adds definitions to the scope of the parse, but included
+ * definitions are not generated.
+ *
+ * Jim Coker, jcoker@magelang.com
+ * Gary Duzan, gduzan@bbn.com
+ */
+class IDLParser extends Parser;
+options {
+ exportVocab=IDL;
+ buildAST=true;
+ k=4;
+}
+
+specification
+ : (import_dcl)* (definition)+
+ ;
+
+
+definition
+ : ( type_dcl SEMI!
+ | const_dcl SEMI!
+ | except_dcl SEMI!
+ | (("abstract" | "local")? "interface") => interf SEMI!
+ | module SEMI!
+ | (("abstract" | "custom")? "valuetype") => value SEMI!
+ | type_id_dcl SEMI!
+ | type_prefix_dcl SEMI!
+ | (("abstract" | "custom")? "eventtype") => event SEMI!
+ | component SEMI!
+ | home_dcl SEMI!
+ )
+ ;
+
+module
+ : "module"^
+ identifier
+ LCURLY! d:definition_list RCURLY!
+ ;
+
+definition_list
+ : (definition)+
+ ;
+
+interf
+ : ( "abstract" | "local" )?
+ "interface"^
+ identifier
+ // interface_name_dcl
+ ( interface_dcl
+ | // forward_dcl
+ )
+ ;
+
+interface_dcl
+ : interface_header
+ LCURLY! interface_body RCURLY!
+ ;
+
+// forward_dcl
+// : // interface_name_dcl
+// ;
+
+// interface_name_dcl
+// : ( "abstract" | "local" )?
+// "interface"^
+// identifier
+// ;
+
+interface_header
+ : // interface_name_dcl
+ ( interface_inheritance_spec )?
+ ;
+
+interface_body
+ : ( export )*
+ ;
+
+export
+ : ( type_dcl SEMI!
+ | const_dcl SEMI!
+ | except_dcl SEMI!
+ | attr_dcl SEMI!
+ | op_dcl SEMI!
+ | type_id_dcl SEMI!
+ | type_prefix_dcl SEMI!
+ )
+ ;
+
+
+interface_inheritance_spec
+ : COLON^ scoped_name_list
+ ;
+
+interface_name
+ : scoped_name
+ ;
+
+scoped_name_list
+ : scoped_name (COMMA! scoped_name)*
+ ;
+
+
+scoped_name
+ : ( SCOPEOP^ )? IDENT^ /* identifier */ (SCOPEOP! identifier)*
+ ;
+
+value
+ : ( value_dcl
+ | value_abs_dcl
+ | value_box_dcl
+ | value_custom_dcl
+ | value_forward_dcl
+ )
+ ;
+
+value_forward_dcl
+ : "valuetype"^
+ identifier
+ ;
+
+value_box_dcl
+ : "valuetype"^
+ identifier
+ type_spec
+ ;
+
+value_abs_dcl
+ : "abstract"
+ "valuetype"^
+ identifier
+ ( value_abs_full_dcl
+ | // value_abs_forward_dcl
+ )
+ ;
+
+value_abs_full_dcl
+ : value_inheritance_spec
+ LCURLY! ( export )* RCURLY!
+ ;
+
+// value_abs_forward_dcl
+// :
+// ;
+
+value_dcl
+ : value_header
+ LCURLY! ( value_element )* RCURLY!
+ ;
+
+value_custom_dcl
+ : "custom"^
+ value_dcl
+ ;
+
+value_header
+ : "valuetype"^
+ identifier
+ value_inheritance_spec
+ ;
+
+value_inheritance_spec
+/*
+ : ( COLON ( "truncatable" )?
+ value_name ( COMMA! value_name )*
+ )?
+ ( "supports" interface_name ( COMMA! interface_name )* )?
+ ;
+*/
+ : ( value_value_inheritance_spec )?
+ ( value_interface_inheritance_spec )?
+ ;
+
+value_value_inheritance_spec
+ : COLON^ ( "truncatable" )?
+ value_name ( COMMA! value_name )*
+ ;
+
+value_interface_inheritance_spec
+ : "supports"^ interface_name ( COMMA! interface_name )*
+ ;
+
+value_name
+ : scoped_name
+ ;
+
+value_element
+ : ( export
+ | state_member
+ | init_dcl
+ )
+ ;
+
+state_member
+ : ( "public" | "private" )
+ type_spec declarators SEMI!
+ ;
+
+init_dcl
+ : "factory"^ identifier
+ LPAREN! (init_param_decls)? RPAREN!
+ (raises_expr)?
+ SEMI!
+ ;
+
+init_param_decls
+ : init_param_decl ( COMMA! init_param_decl )*
+ ;
+
+init_param_decl
+ : init_param_attribute
+ param_type_spec
+ simple_declarator
+ ;
+
+init_param_attribute
+ : "in"
+ ;
+
+const_dcl
+ : "const"^ const_type identifier ASSIGN! const_exp
+ ;
+
+const_type
+ : (integer_type) => integer_type
+ | char_type
+ | wide_char_type
+ | boolean_type
+ | floating_pt_type
+ | string_type
+ | wide_string_type
+ | fixed_pt_const_type
+ | scoped_name
+ | octet_type
+ ;
+
+
+/* EXPRESSIONS */
+
+const_exp
+ : or_expr
+ ;
+
+or_expr
+ : xor_expr
+ ( OR^ // or_op
+ xor_expr
+ )*
+ ;
+
+// or_op
+// : OR
+// ;
+
+
+xor_expr
+ : and_expr
+ ( XOR^ // xor_op
+ and_expr
+ )*
+ ;
+
+// xor_op
+// : XOR
+// ;
+
+and_expr
+ : shift_expr
+ ( AND^ // and_op
+ shift_expr
+ )*
+ ;
+
+// and_op
+// : AND
+// ;
+
+
+shift_expr
+ : add_expr
+ ( ( LSHIFT^
+ | RSHIFT^
+ ) // shift_op
+ add_expr
+ )*
+ ;
+
+// shift_op
+// : LSHIFT
+// | RSHIFT
+// ;
+
+
+add_expr
+ : mult_expr
+ ( ( PLUS^
+ | MINUS^
+ ) // add_op
+ mult_expr
+ )*
+ ;
+
+// add_op
+// : PLUS
+// | MINUS
+// ;
+
+mult_expr
+ : unary_expr
+ ( ( STAR^
+ | DIV^
+ | MOD^
+ ) // mult_op
+ unary_expr
+ )*
+ ;
+
+// mult_op
+// : STAR
+// | DIV
+// | MOD
+// ;
+
+unary_expr
+ : ( MINUS^
+ | PLUS^
+ | TILDE^
+ ) // unary_operator
+ primary_expr
+ | primary_expr
+ ;
+
+// unary_operator
+// : MINUS
+// | PLUS
+// | TILDE
+// ;
+
+// Node of type TPrimaryExp serves to avoid inf. recursion on tree parse
+primary_expr
+ : scoped_name
+ | literal
+ | LPAREN^ const_exp RPAREN
+ ;
+
+literal
+ : integer_literal
+ | string_literal
+ | wide_string_literal
+ | character_literal
+ | wide_character_literal
+ | fixed_pt_literal
+ | floating_pt_literal
+ | boolean_literal
+ ;
+
+boolean_literal
+ : "TRUE"
+ | "FALSE"
+ ;
+
+positive_int_const
+ : const_exp
+ ;
+
+
+type_dcl
+ : "typedef"^ type_declarator
+ | (struct_type) => struct_type
+ | (union_type) => union_type
+ | enum_type
+ | "native"^ simple_declarator
+ | constr_forward_decl
+ ;
+
+type_declarator
+ : type_spec declarators
+ ;
+
+type_spec
+ : simple_type_spec
+ | constr_type_spec
+ ;
+
+simple_type_spec
+ : base_type_spec
+ | template_type_spec
+ | scoped_name
+ ;
+
+base_type_spec
+ : (floating_pt_type) => floating_pt_type
+ | integer_type
+ | char_type
+ | wide_char_type
+ | boolean_type
+ | octet_type
+ | any_type
+ | object_type
+ | value_base_type
+ ;
+
+template_type_spec
+ : sequence_type
+ | string_type
+ | wide_string_type
+ | fixed_pt_type
+ ;
+
+constr_type_spec
+ : struct_type
+ | union_type
+ | enum_type
+ ;
+
+declarators
+ : declarator (COMMA! declarator)*
+ ;
+
+declarator
+ : simple_declarator
+ | complex_declarator
+ ;
+
+simple_declarator
+ : identifier
+ ;
+
+complex_declarator
+ : array_declarator
+ ;
+
+floating_pt_type
+ : "float"
+ | "double"
+ | "long"^ "double"
+ ;
+
+integer_type
+ : signed_int
+ | unsigned_int
+ ;
+
+signed_int
+ : signed_short_int
+ | signed_long_int
+ | signed_longlong_int
+ ;
+
+signed_short_int
+ : "short"
+ ;
+
+signed_long_int
+ : "long"
+ ;
+
+signed_longlong_int
+ : "long" "long"
+ ;
+
+unsigned_int
+ : unsigned_short_int
+ | unsigned_long_int
+ | unsigned_longlong_int
+ ;
+
+unsigned_short_int
+ : "unsigned" "short"
+ ;
+
+unsigned_long_int
+ : "unsigned" "long"
+ ;
+
+unsigned_longlong_int
+ : "unsigned" "long" "long"
+ ;
+
+char_type
+ : "char"
+ ;
+
+wide_char_type
+ : "wchar"
+ ;
+
+boolean_type
+ : "boolean"
+ ;
+
+octet_type
+ : "octet"
+ ;
+
+any_type
+ : "any"
+ ;
+
+object_type
+ : "Object"
+ ;
+
+struct_type
+ : "struct"^
+ identifier
+ LCURLY! member_list RCURLY!
+ ;
+
+member_list
+ : (member)+
+ ;
+
+member
+ : type_spec declarators SEMI!
+ ;
+
+union_type
+ : "union"^
+ identifier
+ "switch"! LPAREN! switch_type_spec RPAREN!
+ LCURLY! switch_body RCURLY!
+ ;
+
+switch_type_spec
+ : integer_type
+ | char_type
+ | boolean_type
+ | enum_type
+ | scoped_name
+ ;
+
+switch_body
+ : case_stmt_list
+ ;
+
+case_stmt_list
+ : (case_stmt)+
+ ;
+
+case_stmt
+ : // case_label_list
+ ( "case"^ const_exp COLON!
+ | "default"^ COLON!
+ )+
+ element_spec SEMI!
+ ;
+
+// case_label_list
+// : (case_label)+
+// ;
+
+
+// case_label
+// : "case"^ const_exp COLON!
+// | "default"^ COLON!
+// ;
+
+element_spec
+ : type_spec declarator
+ ;
+
+enum_type
+ : "enum"^ identifier LCURLY! enumerator_list RCURLY!
+ ;
+
+enumerator_list
+ : enumerator (COMMA! enumerator)*
+ ;
+
+enumerator
+ : identifier
+ ;
+
+sequence_type
+ : "sequence"^
+ LT! simple_type_spec opt_pos_int GT!
+ ;
+
+opt_pos_int
+ : (COMMA! positive_int_const)?
+ ;
+
+string_type
+ : "string"^ (LT! positive_int_const GT!)?
+ ;
+
+wide_string_type
+ : "wstring"^ (LT! positive_int_const GT!)?
+ ;
+
+array_declarator
+ : IDENT^ // identifier
+ (fixed_array_size)+
+ ;
+
+fixed_array_size
+ : LBRACK! positive_int_const RBRACK!
+ ;
+
+attr_dcl
+ : readonly_attr_spec
+ | attr_spec
+ ;
+
+except_dcl
+ : "exception"^
+ identifier
+ LCURLY! opt_member_list RCURLY!
+ ;
+
+
+opt_member_list
+ : (member)*
+ ;
+
+op_dcl
+ : (op_attribute)?
+ op_type_spec
+ IDENT^ // identifier
+ parameter_dcls
+ (raises_expr)?
+ (context_expr)?
+ ;
+
+op_attribute
+ : "oneway"
+ ;
+
+op_type_spec
+ : param_type_spec
+ | "void"
+ ;
+
+parameter_dcls
+ : LPAREN! (param_dcl_list)? RPAREN!
+ ;
+
+param_dcl_list
+ : param_dcl (COMMA! param_dcl)*
+ ;
+
+param_dcl
+ : ("in"^ | "out"^ | "inout"^) // param_attribute
+ param_type_spec simple_declarator
+ ;
+
+// param_attribute
+// : "in"
+// | "out"
+// | "inout"
+// ;
+
+raises_expr
+ : "raises"^ LPAREN! scoped_name_list RPAREN!
+ ;
+
+context_expr
+ : "context"^ LPAREN! string_literal_list RPAREN!
+ ;
+
+string_literal_list
+ : string_literal (COMMA! string_literal)*
+ ;
+
+param_type_spec
+ : base_type_spec
+ | string_type
+ | wide_string_type
+ | scoped_name
+ ;
+
+fixed_pt_type
+ : "fixed"^ LT! positive_int_const COMMA! positive_int_const GT!
+ ;
+
+fixed_pt_const_type
+ : "fixed"
+ ;
+
+value_base_type
+ : "ValueBase"
+ ;
+
+constr_forward_decl
+ : "struct"^ identifier
+ | "union"^ identifier
+ ;
+
+import_dcl
+ : "import"^ imported_scope SEMI!
+ ;
+
+imported_scope
+ : scoped_name
+ | string_literal
+ ;
+
+type_id_dcl
+ : "typeid"^
+ scoped_name
+ string_literal
+ ;
+
+type_prefix_dcl
+ : "typeprefix"^
+ scoped_name
+ string_literal
+ ;
+
+readonly_attr_spec
+ : "readonly" "attribute"^
+ param_type_spec
+ readonly_attr_declarator
+ ;
+
+readonly_attr_declarator
+ : simple_declarator
+ ( raises_expr
+ | (COMMA! simple_declarator)*
+ )
+ ;
+
+attr_spec
+ : "attribute"^ param_type_spec attr_declarator
+ ;
+
+attr_declarator
+ : simple_declarator
+ ( ("getraises" | "setraises") => attr_raises_expr
+ | (COMMA! simple_declarator)*
+ )
+ ;
+
+attr_raises_expr
+ : (get_excep_expr)?
+ (set_excep_expr)?
+ ;
+
+get_excep_expr
+ : "getraises"^ exception_list
+ ;
+
+set_excep_expr
+ : "setraises"^ exception_list
+ ;
+
+exception_list
+ : LPAREN! scoped_name (COMMA! scoped_name)* RPAREN!
+ ;
+
+// Component Stuff
+
+component
+ : "component"^
+ identifier
+ (component_dcl)?
+ ;
+
+component_dcl
+ : (component_inheritance_spec)?
+ (supported_interface_spec)?
+ LCURLY! component_body RCURLY!
+ ;
+
+supported_interface_spec
+ : "supports"^ scoped_name ( COMMA! scoped_name )*
+ ;
+
+component_inheritance_spec
+ : COLON^ scoped_name
+ ;
+
+component_body
+ : (component_export)*
+ ;
+
+component_export
+ : ( provides_dcl SEMI!
+ | uses_dcl SEMI!
+ | emits_dcl SEMI!
+ | publishes_dcl SEMI!
+ | consumes_dcl SEMI!
+ | attr_dcl SEMI!
+ )
+ ;
+
+provides_dcl
+ : "provides"^ interface_type identifier
+ ;
+
+interface_type
+ : ( scoped_name
+ | "Object"
+ )
+ ;
+
+uses_dcl
+ : "uses"^ ("multiple")? interface_type identifier
+ ;
+
+emits_dcl
+ : "emits"^ scoped_name identifier
+ ;
+
+publishes_dcl
+ : "publishes"^ scoped_name identifier
+ ;
+
+consumes_dcl
+ : "consumes"^ scoped_name identifier
+ ;
+
+home_dcl
+ : home_header home_body
+ ;
+
+home_header
+ : "home"^ identifier
+ (home_inheritance_spec)?
+ (supported_interface_spec)?
+ "manages"! scoped_name
+ (primary_key_spec)?
+ ;
+
+home_inheritance_spec
+ : COLON^ scoped_name
+ ;
+
+primary_key_spec
+ : "primarykey"^ scoped_name
+ ;
+
+home_body
+ : LCURLY! (home_export)* RCURLY!
+ ;
+
+home_export
+ : ( export
+ | factory_dcl SEMI!
+ | finder_dcl SEMI!
+ )
+ ;
+
+factory_dcl
+ : "factory"^ identifier
+ LPAREN! init_param_decls RPAREN!
+ (raises_expr)?
+ ;
+
+finder_dcl
+ : "finder"^ identifier
+ LPAREN! init_param_decls RPAREN!
+ (raises_expr)?
+ ;
+
+event
+ : ( event_abs
+ | event_custom
+ | event_dcl
+ )
+ ;
+
+event_header
+ : "eventtype"^
+ identifier
+ ;
+
+event_abs
+ : "abstract"^
+ event_header
+ (event_abs_dcl)?
+ ;
+
+event_abs_dcl
+ : value_inheritance_spec
+ LCURLY! (export)* RCURLY!
+ ;
+
+event_custom
+ : "custom"^
+ event_header
+ event_elem_dcl
+ ;
+
+event_dcl
+ : event_header
+ ( event_elem_dcl
+ | // event_forward_dcl
+ )
+ ;
+
+event_elem_dcl
+ : value_inheritance_spec
+ LCURLY! (export)* RCURLY!
+ ;
+
+// event_forward_dcl
+// :
+// ;
+
+/* literals */
+integer_literal
+ : INT
+ | OCTAL
+ | HEX
+ ;
+
+string_literal
+ : (STRING_LITERAL)+
+ ;
+
+wide_string_literal
+ : (WIDE_STRING_LITERAL)+
+ ;
+
+character_literal
+ : CHAR_LITERAL
+ ;
+
+wide_character_literal
+ : WIDE_CHAR_LITERAL
+ ;
+
+fixed_pt_literal
+ : FIXED
+ ;
+
+floating_pt_literal
+ : f:FLOAT
+ ;
+
+identifier
+ : IDENT
+ ;
+
+/* IDL LEXICAL RULES */
+class IDLLexer extends Lexer;
+options {
+ exportVocab=IDL;
+ charVocabulary='\u0000'..'\uFFFE';
+ k=4;
+}
+
+SEMI
+options {
+ paraphrase = ";";
+}
+ : ';'
+ ;
+
+QUESTION
+options {
+ paraphrase = "?";
+}
+ : '?'
+ ;
+
+LPAREN
+options {
+ paraphrase = "(";
+}
+ : '('
+ ;
+
+RPAREN
+options {
+ paraphrase = ")";
+}
+ : ')'
+ ;
+
+LBRACK
+options {
+ paraphrase = "[";
+}
+ : '['
+ ;
+
+RBRACK
+options {
+ paraphrase = "]";
+}
+ : ']'
+ ;
+
+LCURLY
+options {
+ paraphrase = "{";
+}
+ : '{'
+ ;
+
+RCURLY
+options {
+ paraphrase = "}";
+}
+ : '}'
+ ;
+
+OR
+options {
+ paraphrase = "|";
+}
+ : '|'
+ ;
+
+XOR
+options {
+ paraphrase = "^";
+}
+ : '^'
+ ;
+
+AND
+options {
+ paraphrase = "&";
+}
+ : '&'
+ ;
+
+COLON
+options {
+ paraphrase = ":";
+}
+ : ':'
+ ;
+
+COMMA
+options {
+ paraphrase = ",";
+}
+ : ','
+ ;
+
+DOT
+options {
+ paraphrase = ".";
+}
+ : '.'
+ ;
+
+ASSIGN
+options {
+ paraphrase = "=";
+}
+ : '='
+ ;
+
+NOT
+options {
+ paraphrase = "!";
+}
+ : '!'
+ ;
+
+LT
+options {
+ paraphrase = "<";
+}
+ : '<'
+ ;
+
+LSHIFT
+options {
+ paraphrase = "<<";
+}
+ : "<<"
+ ;
+
+GT
+options {
+ paraphrase = ">";
+}
+ : '>'
+ ;
+
+RSHIFT
+options {
+ paraphrase = ">>";
+}
+ : ">>"
+ ;
+
+DIV
+options {
+ paraphrase = "/";
+}
+ : '/'
+ ;
+
+PLUS
+options {
+ paraphrase = "+";
+}
+ : '+'
+ ;
+
+MINUS
+options {
+ paraphrase = "-";
+}
+ : '-'
+ ;
+
+TILDE
+options {
+ paraphrase = "~";
+}
+ : '~'
+ ;
+
+STAR
+options {
+ paraphrase = "*";
+}
+ : '*'
+ ;
+
+MOD
+options {
+ paraphrase = "%";
+}
+ : '%'
+ ;
+
+
+SCOPEOP
+options {
+ paraphrase = "::";
+}
+ : "::"
+ ;
+
+WS
+options {
+ paraphrase = "white space";
+}
+ : (' '
+ | '\t'
+ | '\n' { newline(); }
+ | '\r')
+ { $setType(Token.SKIP); }
+ ;
+
+
+PREPROC_DIRECTIVE
+options {
+ paraphrase = "a preprocessor directive";
+}
+
+ :
+ '#'!
+ (~'\n')* '\n'!
+ { $setType(Token.SKIP); newline(); }
+ ;
+
+
+SL_COMMENT
+options {
+ paraphrase = "a comment";
+}
+
+ :
+ "//"!
+ (~'\n')* '\n'
+ { $setType(Token.SKIP); newline(); }
+ ;
+
+ML_COMMENT
+options {
+ paraphrase = "a comment";
+}
+ :
+ "/*"!
+ (
+ '\n' { newline(); }
+ | ('*')+
+ ( '\n' { newline(); }
+ | ~('*' | '/' | '\n')
+ )
+ | ~('*' | '\n')
+ )*
+ "*/"!
+ { $setType(Token.SKIP); }
+ ;
+
+CHAR_LITERAL
+options {
+ paraphrase = "a character literal";
+}
+ :
+ '\''!
+ ( ESC | ~'\'' )
+ '\''!
+ ;
+
+WIDE_CHAR_LITERAL
+options {
+ paraphrase = "a wide character literal";
+}
+ : 'L'! CHAR_LITERAL
+ ;
+
+STRING_LITERAL
+options {
+ paraphrase = "a string literal";
+}
+ :
+ '"'!
+ (ESC|~'"')*
+ '"'!
+ ;
+
+
+WIDE_STRING_LITERAL
+options {
+ paraphrase = "a wide string literal";
+}
+ :
+ 'L'! STRING_LITERAL
+ ;
+
+protected
+ESC
+options {
+ paraphrase = "an escape sequence";
+}
+ : '\\'!
+ ( 'n' {$setText("\n");}
+ | 't' {$setText("\t");}
+ | 'v' {$setText("\013");}
+ | 'b' {$setText("\b");}
+ | 'r' {$setText("\r");}
+ | 'f' {$setText("\r");}
+ | 'a' {$setText("\007");}
+ | '\\' {$setText("\\");}
+ | '?' {$setText("?");}
+ | '\'' {$setText("'");}
+ | '"' {$setText("\"");}
+ | OCTDIGIT
+ (options {greedy=true;}:OCTDIGIT
+ (options {greedy=true;}:OCTDIGIT)?
+ )?
+ {char realc = (char) Integer.valueOf($getText, 8).intValue(); $setText(realc);}
+ | 'x'! HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT)?
+ {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);}
+ | 'u'!
+ HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT
+ (options {greedy=true;}:HEXDIGIT)?
+ )?
+ )?
+ {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);}
+ )
+ ;
+
+protected
+VOCAB
+options {
+ paraphrase = "an escaped character value";
+}
+ : '\3'..'\377'
+ ;
+
+protected
+DIGIT
+options {
+ paraphrase = "a digit";
+}
+ : '0'..'9'
+ ;
+
+protected
+NONZERODIGIT
+options {
+ paraphrase = "a non-zero digit";
+}
+ : '1'..'9'
+ ;
+
+protected
+OCTDIGIT
+options {
+ paraphrase = "an octal digit";
+}
+ : '0'..'7'
+ ;
+
+protected
+HEXDIGIT
+options {
+ paraphrase = "a hexadecimal digit";
+}
+ : ('0'..'9' | 'a'..'f' | 'A'..'F')
+ ;
+
+HEX
+options {
+ paraphrase = "a hexadecimal value value";
+}
+
+ : ("0x" | "0X") (HEXDIGIT)+
+ ;
+
+INT
+options {
+ paraphrase = "an integer value";
+}
+ : NONZERODIGIT (DIGIT)* // base-10
+ ( '.' (DIGIT)*
+ ( (('e' | 'E') ('+' | '-')? (DIGIT)+) {$setType(FLOAT);}
+ | ('d' | 'D')! {$setType(FIXED);}
+ | {$setType(FLOAT);}
+ )
+ | ('e' | 'E') ('+' | '-')? (DIGIT)+ {$setType(FLOAT);}
+ | ('d' | 'D')! {$setType(FIXED);}
+ )?
+ ;
+
+OCTAL
+options {
+ paraphrase = "an octal value";
+}
+ : '0'
+ ( (DIGIT)+
+ | FLOAT {$setType(FLOAT);}
+ | ('d' | 'D')! {$setType(FIXED);}
+ | {$setType(INT);}
+ )
+ ;
+
+
+FLOAT
+options {
+ paraphrase = "a floating point value";
+}
+
+ : '.' (DIGIT)+
+ ( ('e' | 'E') ('+' | '-')? (DIGIT)+
+ | ('d' | 'D')! {$setType(FIXED);}
+ )?
+ ;
+
+IDENT
+options {
+ paraphrase = "an identifer";
+ testLiterals = true;
+}
+
+ : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
+ ;
+
+ESCAPED_IDENT
+options {
+ paraphrase = "an escaped identifer";
+ testLiterals = false; // redundant, but explicit is good.
+}
+ // NOTE: Adding a ! to the '_' doesn't seem to work,
+ // so we adjust _begin manually.
+
+ : '_' ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
+ {_begin++;$setType(IDENT);}
+ ;
+
+
Added: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java (added)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,142 @@
+package org.apache.yoko.tools;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.net.URL;
+import java.security.Permission;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.apache.yoko.tools.common.ToolTestBase;
+import org.apache.yoko.tools.processors.idl.IDLToWSDLProcessor;
+import org.apache.yoko.tools.utils.TestUtils;
+
+public class IDLToWSDLTest extends ToolTestBase {
+
+ private static StringBuffer usageBuf;
+ private static int noError;
+ private static int error = -1;
+ ByteArrayOutputStream bout;
+ PrintStream newOut;
+ private File output;
+
+ public void setUp() {
+ super.setUp();
+ try {
+ TestUtils utils = new TestUtils(IDLToWSDL.TOOL_NAME, IDLToWSDL.class
+ .getResourceAsStream("/toolspecs/idl2wsdl.xml"));
+ usageBuf = new StringBuffer(utils.getUsage());
+ bout = new ByteArrayOutputStream();
+ newOut = new PrintStream(bout);
+ //System.setOut(newOut);
+ //System.setErr(newOut);
+ } catch (Exception e) {
+ // complete
+ }
+
+ try {
+ URL url = IDLToWSDLTest.class.getResource(".");
+ output = new File(url.getFile());
+ output = new File(output, "/resources");
+
+ if (!output.exists()) {
+ output.mkdir();
+ }
+ } catch (Exception e) {
+ // complete
+ }
+ }
+
+ public void tearDown() {
+ output.deleteOnExit();
+ output = null;
+ }
+
+ private int execute(String[] args) {
+ SecurityManager oldManager = System.getSecurityManager();
+ try {
+ SecurityManager newManager = new SecurityManager() {
+ public void checkPermission(Permission perm) {
+ if ("exitVM".equals(perm.getName())) {
+ throw new SecurityException("Exit Not Allowed");
+ }
+ }
+ };
+ System.setSecurityManager(newManager);
+ IDLToWSDL.main(args);
+ } catch (Throwable t) {
+ return error;
+ } finally {
+ System.setSecurityManager(oldManager);
+ }
+
+ return noError;
+ }
+
+ private void checkStrings(byte orig[], byte generated[]) throws Exception {
+ BufferedReader origReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(orig)));
+ BufferedReader genReader =
+ new BufferedReader(new InputStreamReader(
+ new ByteArrayInputStream(generated)));
+
+ String sorig = origReader.readLine();
+ String sgen = genReader.readLine();
+
+ while (sorig != null && sgen != null) {
+ if (!sorig.equals(sgen)) {
+ //assertEquals(sorig, sgen);
+ //sorig = origReader.readLine();
+ sgen = genReader.readLine();
+ } else {
+ assertEquals(sorig, sgen);
+ sorig = null;
+ sgen = null;
+ break;
+ }
+ }
+
+ }
+
+ public void testIDLToWSDL() throws Exception {
+ String[] cmdArgs = {getClass().getResource("/idl/HelloWorld.idl").toString()};
+ int exc = execute(cmdArgs);
+ //assertEquals("IDLToWSDL Failed", noError, exc);
+ }
+
+ public void testNoArgs() throws Exception {
+ String[] cmdArgs = {};
+ int exc = execute(cmdArgs);
+ assertEquals("IDLToWSDL Failed", error, exc);
+ StringBuffer strBuf = new StringBuffer();
+ strBuf.append("Missing argument: idl\n\n");
+ strBuf.append(usageBuf.toString());
+ checkStrings(strBuf.toString().getBytes(), bout.toByteArray());
+ }
+
+ public void testDetailOutput() throws Exception {
+ String[] args = new String[] {"-?"};
+ IDLToWSDL.main(args);
+ assertNotNull(getStdOut());
+ }
+
+ public void testVersionOutput() throws Exception {
+ String[] args = new String[] {"-v"};
+ IDLToWSDL.main(args);
+ assertNotNull(getStdOut());
+ }
+
+ public void testHelpOutput() throws Exception {
+ String[] args = new String[] {"-help"};
+ IDLToWSDL.main(args);
+ assertNotNull(getStdOut());
+ }
+
+}
Propchange: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java (added)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java Mon Jun 5 07:38:48 2006
@@ -0,0 +1,79 @@
+package org.apache.yoko.tools.processors;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.objectweb.celtix.tools.common.ProcessorEnvironment;
+
+import org.apache.yoko.tools.common.ToolCorbaConstants;
+import org.apache.yoko.tools.processors.idl.IDLToWSDLProcessor;
+
+public class IDLToWSDLGenerationTest extends TestCase {
+
+ public IDLToWSDLGenerationTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() {
+ }
+
+ protected void tearDown() {
+ }
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run(IDLToWSDLGenerationTest.class);
+ }
+
+ public void testHelloWorldWSDLGeneration() throws Exception {
+ URL idl = getClass().getResource("/idl/HelloWorld.idl");
+ ProcessorEnvironment env = new ProcessorEnvironment();
+ Map<String,Object> cfg = new HashMap<String,Object>();
+ cfg.put(ToolCorbaConstants.CFG_IDLFILE, idl.getFile());
+ env.setParameters(cfg);
+ IDLToWSDLProcessor processor = new IDLToWSDLProcessor();
+ processor.setEnvironment(env);
+ java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
+ processor.setOutputStream(out);
+ processor.process();
+
+ InputStream origstream = getClass().getResourceAsStream("/idl/expected_HelloWorld.wsdl");
+ byte orig[] = inputStreamToBytes(origstream);
+ checkWSDLStrings(orig, out.toByteArray());
+ }
+
+ private void checkWSDLStrings(byte orig[], byte generated[]) throws Exception {
+ BufferedReader origReader =
+ new BufferedReader(new InputStreamReader(new java.io.ByteArrayInputStream(orig)));
+ BufferedReader genReader =
+ new BufferedReader(new InputStreamReader(new java.io.ByteArrayInputStream(generated)));
+
+ String sorig = origReader.readLine();
+ String sgen = genReader.readLine();
+
+ while (sorig != null && sgen != null) {
+ assertEquals(sorig, sgen);
+ sorig = origReader.readLine();
+ sgen = genReader.readLine();
+ }
+ }
+
+ public byte[] inputStreamToBytes(InputStream in) throws Exception {
+ java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream(1024);
+ byte[] buffer = new byte[1024];
+ int len;
+
+ while((len = in.read(buffer)) >= 0)
+ out.write(buffer, 0, len);
+
+ in.close();
+ out.close();
+ return out.toByteArray();
+ }
+}
Propchange: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/yoko/trunk/tools/src/test/resources/idl/HelloWorld.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/HelloWorld.idl?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/HelloWorld.idl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/HelloWorld.idl Mon Jun 5 07:38:48 2006
@@ -0,0 +1,15 @@
+// ******************************************************************
+//
+//
+// Copyright (c) 1993-2006 IONA Technologies PLC.
+// All Rights Reserved.
+//
+//
+// ******************************************************************
+
+interface HelloWorld {
+ string
+ greetMe(
+ in string return_message
+ );
+};
Added: incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl Mon Jun 5 07:38:48 2006
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:tns="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="greetMeResponse" type="xs:string"/><xs:element name="greetMe" type="xs:string"/></xs:schema>
+ </wsdl:types>
+ <wsdl:message name="greetMeResponse">
+ <wsdl:part name="parameters" element="tns:greetMeResponse"/>
+ </wsdl:message>
+ <wsdl:message name="greetMe">
+ <wsdl:part name="parameters" element="tns:greetMe"/>
+ </wsdl:message>
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="greetMe">
+ <wsdl:input name="greetMeRequest" message="tns:greetMe"/>
+ <wsdl:output name="greetMeResponse" message="tns:greetMeResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+</wsdl:definitions>
Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml?rev=411803&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml (added)
+++ incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml Mon Jun 5 07:38:48 2006
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- The xhtml namespace is for usage documentation -->
+<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
+ xsi:schemaLocation="http://www.xsume.com/Xutil/ToolSpecification http://www.xsume.com/schema/xutil/tool-specification.xsd"
+ xmlns="http://www.xsume.com/Xutil/ToolSpecification"
+ xmlns:ts="http://www.xsume.com/Xutil/ToolSpecification">
+
+ <annotation> Examples :
+ idltowsdl HelloWorld.idl
+ idltowsdl -o HelloWorld HelloWorld.idl
+ idltowsdl -w http://www.mycompany.com/schemas HelloWorld.idl
+ idltowsdl -f HelloWorld.ior -interface HelloWorld HellowWorld.idl
+ </annotation>
+
+ <usage>
+
+ <optionGroup id="options">
+
+ <option id="includedir" maxOccurs="unbounded">
+ <annotation>Specify a directory to be included in the search path for the IDL preprocessor.</annotation>
+ <switch>I</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>idl-include-directory</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="outputdir" maxOccurs="1">
+ <annotation>The wsdl output directory.</annotation>
+ <switch>o</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>output-directory</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="address" maxOccurs="1">
+ <annotation>Specify the value to be used for the corba:address location attribute.</annotation>
+ <switch>a</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>corba-address</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="boundedstrings" maxOccurs="1">
+ <annotation>Treat bounded strings as unbounded.</annotation>
+ <switch>b</switch>
+ </option>
+
+ <option id="addressfile" maxOccurs="1">
+ <annotation>Use the contents of file as the value for the corba:address locationattribute.</annotation>
+ <switch>f</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>corba-address-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="importschema" maxOccurs="1">
+ <annotation>Do not generate schema types, but instead import them from file.</annotation>
+ <switch>n</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>schema-import-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="sequencetype" maxOccurs="1">
+ <annotation>Specify the XML Schema type used for the IDL sequence octet type.
+ Valid option values for type are base64Binary and hexBinary. The default is base64Binary.</annotation>
+ <switch>s</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>idl-sequence-type</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="tns" maxOccurs="1">
+ <annotation>Specify the target namespace to use in the wsdl.</annotation>
+ <switch>w</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>target-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="schemans" maxOccurs="1">
+ <annotation>Specify the schema namespace to use in the wsdl.</annotation>
+ <switch>x</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>schema-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="corbatypemapns" maxOccurs="1">
+ <annotation>Specify the corba type map target namespace to use in the wsdl.</annotation>
+ <switch>t</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>corba-type-map target-namespace</annotation>
+ </associatedArgument>
+ </option>
+
+
+ <option id="referenceimport" maxOccurs="1">
+ <annotation>Specify the pathname of the schema file imported to define the Reference type.</annotation>
+ <switch>r</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>reference-schema-file</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="logical" maxOccurs="1">
+ <annotation>Split the generated WSDL into two files.
+ The logical portion of the WSDL is generated into the specified file.
+ The physical portion is generated into the default output file, unless -P is also used.</annotation>
+ <switch>L</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>logical-wsdl-filename</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="physical" maxOccurs="1">
+ <annotation>Split the generated WSDL into two files.
+ The physical portion of the WSDL is generated into specified file.
+ The logical portion is generated into the default output file, unless -L is also used.</annotation>
+ <switch>P</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>physical-wsdl-filename</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="schema" maxOccurs="1">
+ <annotation>Generate schema types into the specified file.
+ The file is then imported back into the logical portion of the generated WSDL.
+ This option cannot be used with -n.</annotation>
+ <switch>T</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>schema-file-name</annotation>
+ </associatedArgument>
+ </option>
+
+ <option id="interface" maxOccurs="1">
+ <annotation>Specify the interface name within idl to use during fast track process.</annotation>
+ <switch>interface</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>interface-name</annotation>
+ </associatedArgument>
+ </option>
+
+
+ <option id="qualified" maxOccurs="1">
+ <annotation>Generate qualified wsdl contract</annotation>
+ <switch>qualified</switch>
+ </option>
+
+ <option id="inline" maxOccurs="1">
+ <annotation>In-line imported schema</annotation>
+ <switch>inline</switch>
+ </option>
+
+ <option id="encoding" maxOccurs="1">
+ <annotation>Use specified encoding as the value of the generated WSDL xml encoding attribute.
+ Defaults to UTF-8.</annotation>
+ <switch>e</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>xml-encoding-type</annotation>
+ </associatedArgument>
+ </option>
+
+ </optionGroup>
+
+ <optionGroup id="common_options">
+ <option id="help" maxOccurs="1">
+ <annotation>Display detailed information for options.</annotation>
+ <switch>h</switch>
+ <switch>?</switch>
+ <switch>help</switch>
+ </option>
+
+ <option id="version">
+ <annotation>Display the version of the tool.</annotation>
+ <switch>v</switch>
+ </option>
+
+ <option id="verbose">
+ <annotation>Verbose mode</annotation>
+ <switch>verbose</switch>
+ <switch>V</switch>
+ </option>
+
+ <option id="quiet">
+ <annotation>Quiet mode</annotation>
+ <switch>quiet</switch>
+ <switch>q</switch>
+ </option>
+
+
+ </optionGroup>
+
+ <argument id="idl" minOccurs="1" maxOccurs="1">
+ <annotation>idl-file-name</annotation>
+ </argument>
+ </usage>
+
+
+
+</toolspec>
Propchange: incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/test/resources/toolspecs/idl2wsdl.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml