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 en...@apache.org on 2006/08/16 09:40:35 UTC
svn commit: r431869 - in /incubator/yoko/trunk/tools/src:
main/java/org/apache/yoko/tools/processors/idl/
test/java/org/apache/yoko/tools/processors/ test/resources/idl/
Author: enolan
Date: Wed Aug 16 02:40:34 2006
New Revision: 431869
URL: http://svn.apache.org/viewvc?rev=431869&view=rev
Log:
Yoko-125 - Apply Matteo Patch to add support for IDL enum to IDLToWSDL tool.
Added:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java (with props)
incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl (with props)
Modified:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java?rev=431869&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java Wed Aug 16 02:40:34 2006
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.yoko.tools.processors.idl;
+
+import javax.xml.namespace.QName;
+
+import antlr.collections.AST;
+
+import org.apache.schemas.yoko.bindings.corba.Enum;
+import org.apache.schemas.yoko.bindings.corba.Enumerator;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+
+import org.apache.ws.commons.schema.constants.Constants;
+
+import org.apache.yoko.tools.common.CORBAConstants;
+
+public class EnumVisitor extends TypesVisitorBase {
+
+ public EnumVisitor(XmlSchemaCollection xmlSchemas,
+ XmlSchema xmlSchema,
+ TypeMappingType typeMappingType) {
+ super(xmlSchemas, xmlSchema, typeMappingType);
+ }
+
+ public void visit(AST enumNode) {
+ AST enumNameNode = enumNode.getFirstChild();
+
+ // xmlschema:enum
+ XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema);
+ enumSchemaSimpleType.setName(enumNameNode.toString());
+
+ XmlSchemaSimpleTypeRestriction enumSchemaSimpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
+ enumSchemaSimpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
+
+ //XmlSchemaSimpleTypeContent xmlSchemaSimpleTypeContent = enumSchemaSimpleTypeRestriction;
+ enumSchemaSimpleType.setContent(enumSchemaSimpleTypeRestriction);
+
+
+ // corba:enum
+ Enum corbaEnum = new Enum();
+ corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameNode.toString()));
+ corbaEnum.setRepositoryID(CORBAConstants.REPO_STRING
+ + enumNameNode.toString()
+ + CORBAConstants.IDL_VERSION);
+ corbaEnum.setType(enumSchemaSimpleType.getQName());
+
+
+ AST node = enumNameNode.getNextSibling();
+ while (node != null) {
+ // xmlschema:enumeration
+ XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
+ enumeration.setValue(node.toString());
+ enumSchemaSimpleTypeRestriction.getFacets().add(enumeration);
+
+ // corba:enumerator
+ Enumerator enumerator = new Enumerator();
+ enumerator.setValue(node.toString());
+ corbaEnum.getEnumerator().add(enumerator);
+
+ node = node.getNextSibling();
+ }
+
+ // add xmlschema:enum
+ schema.addType(enumSchemaSimpleType);
+ schema.getItems().add(enumSchemaSimpleType);
+
+ // add corba:enum
+ typeMap.getStructOrExceptionOrUnion().add(corbaEnum);
+ }
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=431869&r1=431868&r2=431869&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java Wed Aug 16 02:40:34 2006
@@ -78,6 +78,7 @@
case IDLTokenTypes.LITERAL_struct:
case IDLTokenTypes.LITERAL_exception:
case IDLTokenTypes.LITERAL_const:
+ case IDLTokenTypes.LITERAL_enum:
typesVisitor.visit(node2);
break;
default:
Modified: 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=431869&r1=431868&r2=431869&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java Wed Aug 16 02:40:34 2006
@@ -169,6 +169,10 @@
ConstVisitor constVisitor = new ConstVisitor(schemas, schema, typeMap);
constVisitor.visit(node);
break;
+ case IDLTokenTypes.LITERAL_enum:
+ EnumVisitor enumVisitor = new EnumVisitor(schemas, schema, typeMap);
+ enumVisitor.visit(node);
+ break;
case IDLTokenTypes.IDENT: {
XmlSchemaType stype = TypesUtils.findType(schemas, schema, node);
if (currentType instanceof XmlSchemaElement) {
Modified: 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=431869&r1=431868&r2=431869&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java Wed Aug 16 02:40:34 2006
@@ -150,4 +150,8 @@
testWSDLGeneration("/idl/Const.idl", "/idl/expected_Const.wsdl");
}
+ public void testEnumGeneration() throws Exception {
+ testWSDLGeneration("/idl/Enum.idl", "/idl/expected_Enum.wsdl");
+ }
+
}
Added: incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl?rev=431869&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/Enum.idl Wed Aug 16 02:40:34 2006
@@ -0,0 +1,26 @@
+enum e_type1 {e1_1, e1_2, e1_3};
+
+interface if1 {
+ enum e_type2 {e2_1, e2_2, e2_3};
+
+ void if1_op1(in e_type2 in_e_type2);
+ void if1_op2(out e_type2 out_e_type2);
+ void if1_op3(inout e_type2 inout_e_type2);
+};
+
+interface if2 {
+ void if2_op1(in e_type1 in_e_type1);
+ void if2_op2(out e_type1 out_e_type1);
+ void if2_op3(inout e_type1 inout_e_type1);
+};
+
+/*
+module M
+{
+ enum e_type3 {e3_1, e3_2, e3_3};
+ interface if2 {
+ enum e_type4 {e4_1, e4_2, e4_3};
+ };
+
+};
+*/
Added: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl?rev=431869&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl Wed Aug 16 02:40:34 2006
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/Enum" xmlns:tns="http://schemas.apache.org/yoko/idl/Enum" xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <corba:typeMapping targetNamespace="http://schemas.apache.org/yoko/idl/Enum/typemap">
+ <corba:enum xmlns:ns4="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" repositoryID="IDL:e_type1:1.0" name="e_type1" type="ns4:e_type1">
+ <corba:enumerator value="e1_1" />
+ <corba:enumerator value="e1_2" />
+ <corba:enumerator value="e1_3" />
+ </corba:enum>
+ <corba:enum xmlns:ns4="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" repositoryID="IDL:e_type2:1.0" name="e_type2" type="ns4:e_type2">
+ <corba:enumerator value="e2_1" />
+ <corba:enumerator value="e2_2" />
+ <corba:enumerator value="e2_3" />
+ </corba:enum>
+ </corba:typeMapping>
+ <wsdl:types>
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/Enum" xmlns="http://schemas.apache.org/yoko/idl/Enum" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:simpleType name="e_type1">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="e1_1">
+ </xs:enumeration>
+ <xs:enumeration value="e1_2">
+ </xs:enumeration>
+ <xs:enumeration value="e1_3">
+ </xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="e_type2">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="e2_1">
+ </xs:enumeration>
+ <xs:enumeration value="e2_2">
+ </xs:enumeration>
+ <xs:enumeration value="e2_3">
+ </xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:element name="if1_op1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="in_e_type2" type="e_type2">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if1_op1Response">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if1_op2">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if1_op2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="out_e_type2" type="e_type2">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if1_op3">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="inout_e_type2" type="e_type2">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if1_op3Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="inout_e_type2" type="e_type2">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if2_op1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="in_e_type1" type="e_type1">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if2_op1Response">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if2_op2">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if2_op2Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="out_e_type1" type="e_type1">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if2_op3">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="inout_e_type1" type="e_type1">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="if2_op3Response">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="inout_e_type1" type="e_type1">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="if1_op1Response">
+ <wsdl:part name="outparameter" element="tns:if1_op1Response"/>
+ </wsdl:message>
+ <wsdl:message name="if2_op2">
+ <wsdl:part name="inparameter" element="tns:if2_op2"/>
+ </wsdl:message>
+ <wsdl:message name="if1_op3Response">
+ <wsdl:part name="outparameter" element="tns:if1_op3Response"/>
+ </wsdl:message>
+ <wsdl:message name="if1_op1">
+ <wsdl:part name="inparameter" element="tns:if1_op1"/>
+ </wsdl:message>
+ <wsdl:message name="if2_op1Response">
+ <wsdl:part name="outparameter" element="tns:if2_op1Response"/>
+ </wsdl:message>
+ <wsdl:message name="if2_op1">
+ <wsdl:part name="inparameter" element="tns:if2_op1"/>
+ </wsdl:message>
+ <wsdl:message name="if2_op3">
+ <wsdl:part name="inparameter" element="tns:if2_op3"/>
+ </wsdl:message>
+ <wsdl:message name="if1_op3">
+ <wsdl:part name="inparameter" element="tns:if1_op3"/>
+ </wsdl:message>
+ <wsdl:message name="if2_op3Response">
+ <wsdl:part name="outparameter" element="tns:if2_op3Response"/>
+ </wsdl:message>
+ <wsdl:message name="if1_op2">
+ <wsdl:part name="inparameter" element="tns:if1_op2"/>
+ </wsdl:message>
+ <wsdl:message name="if2_op2Response">
+ <wsdl:part name="outparameter" element="tns:if2_op2Response"/>
+ </wsdl:message>
+ <wsdl:message name="if1_op2Response">
+ <wsdl:part name="outparameter" element="tns:if1_op2Response"/>
+ </wsdl:message>
+ <wsdl:portType name="if2">
+ <wsdl:operation name="if2_op1">
+ <wsdl:input name="if2_op1Request" message="tns:if2_op1"/>
+ <wsdl:output name="if2_op1Response" message="tns:if2_op1Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="if2_op2">
+ <wsdl:input name="if2_op2Request" message="tns:if2_op2"/>
+ <wsdl:output name="if2_op2Response" message="tns:if2_op2Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="if2_op3">
+ <wsdl:input name="if2_op3Request" message="tns:if2_op3"/>
+ <wsdl:output name="if2_op3Response" message="tns:if2_op3Response"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:portType name="if1">
+ <wsdl:operation name="if1_op1">
+ <wsdl:input name="if1_op1Request" message="tns:if1_op1"/>
+ <wsdl:output name="if1_op1Response" message="tns:if1_op1Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="if1_op2">
+ <wsdl:input name="if1_op2Request" message="tns:if1_op2"/>
+ <wsdl:output name="if1_op2Response" message="tns:if1_op2Response"/>
+ </wsdl:operation>
+ <wsdl:operation name="if1_op3">
+ <wsdl:input name="if1_op3Request" message="tns:if1_op3"/>
+ <wsdl:output name="if1_op3Response" message="tns:if1_op3Response"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="if1CORBABinding" type="tns:if1">
+ <corba:binding repositoryID="IDL:if1:1.0" />
+ <wsdl:operation name="if1_op1">
+ <corba:operation name="if1_op1">
+ <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="in" name="in_e_type2" idltype="e_type2" />
+ </corba:operation>
+ <wsdl:input name="if1_op1Request">
+ </wsdl:input>
+ <wsdl:output name="if1_op1Response">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="if1_op2">
+ <corba:operation name="if1_op2">
+ <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="out" name="out_e_type2" idltype="e_type2" />
+ </corba:operation>
+ <wsdl:input name="if1_op2Request">
+ </wsdl:input>
+ <wsdl:output name="if1_op2Response">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="if1_op3">
+ <corba:operation name="if1_op3">
+ <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="inout" name="inout_e_type2" idltype="e_type2" />
+ </corba:operation>
+ <wsdl:input name="if1_op3Request">
+ </wsdl:input>
+ <wsdl:output name="if1_op3Response">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="if2CORBABinding" type="tns:if2">
+ <corba:binding repositoryID="IDL:if2:1.0" />
+ <wsdl:operation name="if2_op1">
+ <corba:operation name="if2_op1">
+ <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="in" name="in_e_type1" idltype="e_type1" />
+ </corba:operation>
+ <wsdl:input name="if2_op1Request">
+ </wsdl:input>
+ <wsdl:output name="if2_op1Response">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="if2_op2">
+ <corba:operation name="if2_op2">
+ <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="out" name="out_e_type1" idltype="e_type1" />
+ </corba:operation>
+ <wsdl:input name="if2_op2Request">
+ </wsdl:input>
+ <wsdl:output name="if2_op2Response">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="if2_op3">
+ <corba:operation name="if2_op3">
+ <corba:param xmlns="http://schemas.apache.org/yoko/idl/Enum/typemap" mode="inout" name="inout_e_type1" idltype="e_type1" />
+ </corba:operation>
+ <wsdl:input name="if2_op3Request">
+ </wsdl:input>
+ <wsdl:output name="if2_op3Response">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="if2CORBAService">
+ <wsdl:port name="if2CORBAPort" binding="tns:if2CORBABinding">
+ <corba:address location="IOR:" />
+ </wsdl:port>
+ </wsdl:service>
+ <wsdl:service name="if1CORBAService">
+ <wsdl:port name="if1CORBAPort" binding="tns:if1CORBABinding">
+ <corba:address location="IOR:" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Enum.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml