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 2007/05/04 15:08:03 UTC
svn commit: r535283 - in /incubator/yoko/trunk/tools/src:
main/java/org/apache/yoko/tools/common/
main/java/org/apache/yoko/tools/processors/idl/ test/resources/idl/
Author: enolan
Date: Fri May 4 08:08:02 2007
New Revision: 535283
URL: http://svn.apache.org/viewvc?view=rev&rev=535283
Log:
Yoko-430 - updates.
Modified:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/WSDLCorbaWriterImpl.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLPT.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLT.wsdl
incubator/yoko/trunk/tools/src/test/resources/idl/expected_OptionsSchema.wsdl
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/WSDLCorbaWriterImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/WSDLCorbaWriterImpl.java?view=diff&rev=535283&r1=535282&r2=535283
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/WSDLCorbaWriterImpl.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/WSDLCorbaWriterImpl.java Fri May 4 08:08:02 2007
@@ -30,6 +30,7 @@
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
import javax.xml.namespace.QName;
import org.w3c.dom.Attr;
@@ -142,9 +143,18 @@
while (it.hasNext()) {
ExtensibilityElement extElement = (ExtensibilityElement) it.next();
if (extElement instanceof Schema) {
- printDOMElement(((Schema) extElement).getElement(),
- pw,
- DEFAULT_INDENT_LEVEL + 2);
+ Schema schemaElement = (Schema)extElement;
+ if (schemaElement.getElement() != null) {
+ printDOMElement(schemaElement.getElement(),
+ pw,
+ DEFAULT_INDENT_LEVEL + 2);
+ } else if (schemaElement.getImports() != null) {
+ printSchemaImports(extElement.getElementType(),
+ schemaElement,
+ pw,
+ DEFAULT_INDENT_LEVEL + 2,
+ def);
+ }
pw.println();
} else {
super.printExtensibilityElements(class1, list, def, pw);
@@ -174,6 +184,35 @@
}
indent(pw, indentCount);
pw.print("</" + element.getNodeName() + ">");
+ }
+
+ private void printSchemaImports(QName schemaName, Schema schemaElement, PrintWriter pw, int indentCount,
+ Definition def) throws WSDLException {
+ Map imports = schemaElement.getImports();
+ indent(pw, indentCount);
+ pw.print("<" + schemaName.getLocalPart() + ">");
+ String tagName = "xsd:import";
+
+ Iterator importListIterator = imports.values().iterator();
+ while (importListIterator.hasNext()) {
+ List importList = (List)importListIterator.next();
+ Iterator importIterator = importList.iterator();
+
+ while (importIterator.hasNext()) {
+ SchemaImport schemaImport = (SchemaImport)importIterator.next();
+ pw.println();
+ indent(pw, indentCount + 2);
+ pw.print("<" + tagName);
+ DOMUtils.printAttribute(Constants.ATTR_NAMESPACE,
+ schemaImport.getNamespaceURI(), pw);
+ DOMUtils.printAttribute(Constants.ATTR_LOCATION,
+ schemaImport.getSchemaLocationURI(), pw);
+ pw.println("/>");
+ }
+ }
+ indent(pw, indentCount);
+ pw.print("</" + schemaName.getLocalPart() + ">");
+
}
public void indent(PrintWriter pw, int count) {
Modified: 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?view=diff&rev=535283&r1=535282&r2=535283
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java Fri May 4 08:08:02 2007
@@ -184,7 +184,7 @@
if (logical == null || physical == null) {
if (outputWriter == null) {
- outputWriter = getOutputWriter(idl, outputDir);
+ outputWriter = getOutputWriter(idl + ".wsdl", outputDir);
}
}
@@ -208,7 +208,7 @@
schemaFilename, logical, physical);
} else {
if (outputWriter == null) {
- outputWriter = getOutputWriter(idl, outputDir);
+ outputWriter = getOutputWriter(idl + ".wsdl", outputDir);
}
visitor.writeDefinition(outputWriter);
}
@@ -223,7 +223,7 @@
* encoding = env.get(ToolCorbaConstants.CFG_WSDL_ENCODING).toString();
* outputWriter = fw.getWriter("", idl + ".wsdl", encoding); } else {
*/
- return fw.getWriter("", filename + ".wsdl");
+ return fw.getWriter("", filename);
// }
}
Modified: 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?view=diff&rev=535283&r1=535282&r2=535283
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java Fri May 4 08:08:02 2007
@@ -38,6 +38,7 @@
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.ExtensionRegistry;
import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.bind.JAXBException;
@@ -274,8 +275,8 @@
importDef.setNamespaceURI(definition.getTargetNamespace());
def.addImport(importDef);
return def;
- }
-
+ }
+
// Gets the logical definition for a file - an import will be added for the
// schema types if -T is used and a separate schema file generated.
// if -n is used an import will be added for the schema types and no types generated.
@@ -286,14 +287,14 @@
// checks for -T option.
if (schemaFilename != null) {
writeSchemaDefinition(definition, schemaWriter);
- writeImport(def, schemaFilename);
+ def = addSchemaImport(def, schemaFilename);
} else {
// checks for -n option
if (importSchemaFilename == null) {
Types types = definition.getTypes();
def.setTypes(types);
} else {
- writeImport(def, importSchemaFilename);
+ def = addSchemaImport(def, importSchemaFilename);
}
}
@@ -455,6 +456,24 @@
types.addExtensibilityElement(wsdlSchema);
definition.setTypes(types);
+ }
+
+ private Definition addSchemaImport(Definition def, String schemaFilename) throws Exception {
+ Types types = def.createTypes();
+ Schema wsdlSchema = (Schema)
+ def.getExtensionRegistry().createExtension(Types.class,
+ new QName(Constants.URI_2001_SCHEMA_XSD,
+ "schema"));
+
+ //org.w3c.dom.Element el = XmlSchemaSerializer.serializeSchema(schema, true)[0].getDocumentElement();
+ //wsdlSchema.setElement(el);
+ SchemaImport schemaimport = wsdlSchema.createImport();
+ schemaimport.setNamespaceURI(def.getTargetNamespace());
+ schemaimport.setSchemaLocationURI(schemaFilename);
+ wsdlSchema.addImport(schemaimport);
+ types.addExtensibilityElement(wsdlSchema);
+ def.setTypes(types);
+ return def;
}
private void addAnyType() {
Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLPT.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLPT.wsdl?view=diff&rev=535283&r1=535282&r2=535283
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLPT.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLPT.wsdl Fri May 4 08:08:02 2007
@@ -18,8 +18,11 @@
* under the License.
-->
<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/OptionsLPT" xmlns:tns="http://schemas.apache.org/yoko/idl/OptionsLPT" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:import namespace="http://schemas.apache.org/yoko/idl/OptionsLPT" location="expected_SchemaLPT.xsd">
- </wsdl:import>
+ <wsdl:types>
+ <schema>
+ <xsd:import namespace="http://schemas.apache.org/yoko/idl/OptionsLPT" location="expected_SchemaLPT.xsd"/>
+ </schema>
+ </wsdl:types>
<wsdl:message name="getEmployee">
<wsdl:part name="inparameter" element="tns:getEmployee">
</wsdl:part>
Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLT.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLT.wsdl?view=diff&rev=535283&r1=535282&r2=535283
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLT.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_LogicalLT.wsdl Fri May 4 08:08:02 2007
@@ -18,8 +18,11 @@
* under the License.
-->
<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/OptionsLT" xmlns:tns="http://schemas.apache.org/yoko/idl/OptionsLT" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:import namespace="http://schemas.apache.org/yoko/idl/OptionsLT" location="expected_SchemaLT.xsd">
- </wsdl:import>
+ <wsdl:types>
+ <schema>
+ <xsd:import namespace="http://schemas.apache.org/yoko/idl/OptionsLT" location="expected_SchemaLT.xsd"/>
+ </schema>
+ </wsdl:types>
<wsdl:message name="getEmployeeResponse">
<wsdl:part name="outparameter" element="tns:getEmployeeResponse">
</wsdl:part>
Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_OptionsSchema.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_OptionsSchema.wsdl?view=diff&rev=535283&r1=535282&r2=535283
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_OptionsSchema.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_OptionsSchema.wsdl Fri May 4 08:08:02 2007
@@ -24,8 +24,11 @@
<corba:member name="number" idltype="corba:long" />
</corba:struct>
</corba:typeMapping>
- <wsdl:import namespace="http://schemas.apache.org/yoko/idl/OptionsSchema" location="expected_Schema.xsd">
- </wsdl:import>
+ <wsdl:types>
+ <schema>
+ <xsd:import namespace="http://schemas.apache.org/yoko/idl/OptionsSchema" location="expected_Schema.xsd"/>
+ </schema>
+ </wsdl:types>
<wsdl:message name="getEmployee">
<wsdl:part name="inparameter" element="tns:getEmployee">
</wsdl:part>