axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r226976 - in /webservices/axis/trunk/java/modules/wsdl/src/org/apache: axis2/wsdl/builder/wsdl4j/ axis2/wsdl/codegen/ axis2/wsdl/codegen/emitter/ axis2/wsdl/codegen/extension/ wsdl/ wsdl/extensions/ wsdl/extensions/impl/
Date Tue, 02 Aug 2005 09:40:10 GMT
Author: ajith
Date: Tue Aug  2 02:39:26 2005
New Revision: 226976

URL: http://svn.apache.org/viewcvs?rev=226976&view=rev
Log:
Fixed the imported schema problem
1.Schema element now has a schema stack
2.WSDLpump now searches for the imports and populates the schema stack, with the last on top
3.XMLBeansExtension now looks at the schema stack and processes them in order. No automatic
downloading of the schemas will happen

Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLTypes.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/SchemaImpl.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
(original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
Tue Aug  2 02:39:26 2005
@@ -60,6 +60,7 @@
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPBody;
@@ -74,6 +75,7 @@
 import java.util.Map;
 import java.util.Collection;
 import java.util.Vector;
+import java.util.Stack;
 
 /**
  * @author chathura@opensource.lk
@@ -147,29 +149,36 @@
             this.womDefinition.setTypes(wsdlTypes);
         }
 
+//        Map importsMap = wsdl4JDefinition.getImports();
+//        if (null!=importsMap && importsMap.size()>0){
+//           Object[] imports = importsMap.values().toArray();
+//            for (int i = 0; i < imports.length; i++) {
+//                Import wsdl4jImport = (Import) importsMap.values().
+//            }
+//        }
 
         // There can be types that are imported. Check the imports and
-        //do the necessary things
+        // These schemas are needed for the XMLBeans for code generation
+
         Map wsdlImports = wsdl4JDefinition.getImports();
+        Stack schemaStack = null;
+
         if (null != wsdlImports && !wsdlImports.isEmpty()){
             Collection importsCollection = wsdlImports.values();
-
             for (Iterator iterator = importsCollection.iterator(); iterator.hasNext();) {
                 Vector values = (Vector)iterator.next();
                 for (int i = 0; i < values.size(); i++) {
-                    Import wsdlImport = (Import)values.elementAt(i);;
+                    Import wsdlImport = (Import)values.elementAt(i);
+
                     if (wsdlImport.getDefinition()!=null){
                         Definition importedDef = wsdlImport.getDefinition();
                         //add the imported types
-                        if (null!=importedDef.getTypes()){
-                            WSDLTypes wsdlTypes = this.wsdlComponenetFactory.createTypes();
-                            this.copyExtensibleElements(importedDef.getTypes().
-                                    getExtensibilityElements(),
-                                    wsdlTypes);
-                            this.womDefinition.setTypes(wsdlTypes);
-                        }
+                        WSDLTypes wsdlTypes = this.wsdlComponenetFactory.createTypes();
+                        this.copyExtensibleElements(importedDef.getTypes().
+                                getExtensibilityElements(),
+                                wsdlTypes);
+                        this.womDefinition.setTypes(wsdlTypes);
                     }
-
                 }
 
             }
@@ -325,6 +334,25 @@
 
     }
 
+    private void pushSchemaElement(Schema originalSchema,Stack stack){
+        stack.push(originalSchema);
+        Map map = originalSchema.getImports();
+        Collection values;
+        if (map!=null && map.size()>0){
+            values = map.values();
+            for (Iterator iterator = values.iterator(); iterator.hasNext();) {
+                //recursively add the schema's
+                Vector v = (Vector)iterator.next();
+                for (int i = 0; i < v.size(); i++) {
+                    pushSchemaElement(((SchemaImport)v.get(i)).getReferencedSchema(),stack);
+                }
+
+            }
+        }else{
+            return;
+        }
+    }
+
     /////////////////////////////////////////////////////////////////////////////
     //////////////////////////// Internal Component Copying ///////////////////
     public void populateOperations(WSDLOperation wsdlOperation,
@@ -678,9 +706,15 @@
                 component.addExtensibilityElement(extensibilityElement);
             } else if (wsdl4jElement instanceof Schema) {
                 Schema schema = (Schema) wsdl4jElement;
+                //populate the imported schema stack
+                Stack schemaStack = new Stack();
+                //recursivly load the schema elements. The best thing is to push these into
+                //a stack and then pop from the other side
+                pushSchemaElement(schema, schemaStack);
                 org.apache.wsdl.extensions.Schema extensibilityElement = (org.apache.wsdl.extensions.Schema)
extensionFactory.getExtensionElement(
                         schema.getElementType());
                 extensibilityElement.setElelment(schema.getElement());
+                extensibilityElement.setImportedSchemaStack(schemaStack);
                 Boolean required = schema.getRequired();
                 if (null != required) {
                     extensibilityElement.setRequired(required.booleanValue());

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
(original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
Tue Aug  2 02:39:26 2005
@@ -112,8 +112,6 @@
             else
                 emitter.emitStub();
         } catch (Exception e) {
-            //System.out.println("Thrown here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
             throw new CodeGenerationException(e);
         }
 

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
(original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
Tue Aug  2 02:39:26 2005
@@ -134,8 +134,10 @@
             Map bindings = wom.getBindings();
             WSDLBinding axisBinding = null;
             WSDLService axisService = null;
-            if (bindings==null)
+            if (bindings==null){
                 throw new CodeGenerationException("Binding needs to be present!");
+            }
+            
             Collection bindingCollection = bindings.values();
             for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
                 axisBinding  =  (WSDLBinding)iterator.next();
@@ -159,7 +161,7 @@
                 //write the call back handlers
                 writeCallBackHandlers(axisBinding);
                 //write the test classes
-//            writeTestClasses(axisBinding);
+                writeTestClasses(axisBinding);
                 //write the databinding supporters
                 writeDatabindingSupporters(axisBinding);
                 //write a dummy implementation call for the tests to run.
@@ -168,7 +170,6 @@
                 //writeTestServiceXML(axisBinding);
             }
         } catch (Exception e) {
-            e.printStackTrace();
             throw new CodeGenerationException(e);
         }
     }
@@ -408,24 +409,36 @@
     public void emitSkeleton() throws CodeGenerationException {
         try {
             //get the binding
-            WSDLBinding axisBinding = this.configuration.getWom().getBinding(
-                    AxisBindingBuilder.AXIS_BINDING_QNAME);
-            //
-            testCompatibiltyAll(axisBinding);
-            //write interfaces
-            writeSkeleton(axisBinding);
-            //write interface implementations
-            writeServiceXml(axisBinding);
-            //write the local test classes
-//            writeLocalTestClasses(axisBinding);
-            //write a dummy implementation call for the tests to run.
-            writeTestSkeletonImpl(axisBinding);
-            //write a testservice.xml that will load the dummy skeleton impl for testing
-            writeTestServiceXML(axisBinding);
-            //write a MessageReceiver for this particular service.
-            writeMessageReceiver(axisBinding);
-            //////////////////////////////////////
+            WSDLDescription wom = this.configuration.getWom();
+            Map bindings = wom.getBindings();
+            WSDLBinding axisBinding = null;
+
+            if (bindings==null){
+                throw new CodeGenerationException("Binding needs to be present!");
+            }
+
+            Collection bindingCollection = bindings.values();
+
+            for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
+                axisBinding  =  (WSDLBinding)iterator.next();
+                //test the compatibility
+                testCompatibiltyAll(axisBinding);
+                //write interfaces
+                writeSkeleton(axisBinding);
+                //write interface implementations
+                writeServiceXml(axisBinding);
+                //write the local test classes
+//               writeLocalTestClasses(axisBinding);
+                //write a dummy implementation call for the tests to run.
+                writeTestSkeletonImpl(axisBinding);
+                //write a testservice.xml that will load the dummy skeleton impl for testing
+                writeTestServiceXML(axisBinding);
+                //write a MessageReceiver for this particular service.
+                writeMessageReceiver(axisBinding);
+            }
             // Call the emit stub method to generate the client side too
+            // Do we need to enforce this here ?????
+            // Perhaps we can introduce a flag to determine this!
             emitStub();
 
         } catch (Exception e) {
@@ -565,7 +578,7 @@
         String parameterName = null;
         if (outputMessage!=null){
             parameterName =  this.mapper.getParameterName(
-                            outputMessage.getElement()) ;
+                    outputMessage.getElement()) ;
             String typeMapping = this.mapper.getTypeMapping(
                     operation.getOutputMessage().getElement());
             typeMappingStr = typeMapping == null ? "" : typeMapping;

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
(original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
Tue Aug  2 02:39:26 2005
@@ -24,6 +24,9 @@
 import java.io.OutputStream;
 import java.io.Writer;
 import java.util.List;
+import java.util.Stack;
+import java.util.Vector;
+import java.net.URLClassLoader;
 
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
@@ -52,6 +55,10 @@
     }
 
     public void engage() {
+        //test whether the TCCL has the Xbeans classes
+        //ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+
         try {
             WSDLTypes typesList = configuration.getWom().getTypes();
             if (typesList == null) {
@@ -61,79 +68,86 @@
                 this.configuration.setTypeMapper(new DefaultTypeMapper());
                 return;
             }
+
             List typesArray = typesList.getExtensibilityElements();
             WSDLExtensibilityElement extensiblityElt = null;
-            XmlObject[] xmlObjects = new XmlObject[typesArray.size()];
 
             for (int i = 0; i < typesArray.size(); i++) {
                 extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
+                Vector xmlObjectsVector = new Vector();
+                Schema schema = null;
+                SchemaTypeSystem sts  = null;
 
                 if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
-
-                    try {
-                        Element schemaElement = ((Schema) extensiblityElt).getElelment();
-                        //System.out.println("schemaElement = " + schemaElement);
-                        XmlOptions options = new XmlOptions();
-                        //options.setCompileDownloadUrls();//download imported URL's
-                        options.setLoadAdditionalNamespaces(
-                                configuration.getWom().getNamespaces()); //add the namespaces
-                        //options.
-                        xmlObjects[i] =
-                                XmlObject.Factory.parse(schemaElement, options);
-                    } catch (Exception e) {
-                        throw new RuntimeException(e);
+                    schema = (Schema) extensiblityElt;
+                    XmlOptions options = new XmlOptions();
+                    options.setLoadAdditionalNamespaces(
+                            configuration.getWom().getNamespaces()); //add the namespaces
+
+                    Stack importedSchemaStack = schema.getImportedSchemaStack();
+                    //compile these schemas
+                    while (!importedSchemaStack.isEmpty()){
+                        xmlObjectsVector.add(
+                                XmlObject.Factory.parse(
+                                        ((javax.wsdl.extensions.schema.Schema)importedSchemaStack.pop()).getElement()
+                                        ,options));
                     }
                 }
-            }
-
-            final File outputFolder = configuration.getOutputLocation();
-
-            try {
-
-                //System.out.println(XmlBeans.loadXsd(xmlObjects));
 
-                SchemaTypeSystem sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
-                        xmlObjects,
+                sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
+                        convertToXMLObjectArray(xmlObjectsVector),
                         new BindingConfig(), XmlBeans.getContextTypeLoader(),
-                        new Filer() {
-                            public OutputStream createBinaryFile(String typename)
-                                    throws IOException {
-                                File file = new File(outputFolder, typename);
-                                file.getParentFile().mkdirs();
-                                file.createNewFile();
-                                return new FileOutputStream(file);
-                            }
-
-                            public Writer createSourceFile(String typename)
-                                    throws IOException {
-                                typename =
-                                        typename.replace('.', File.separatorChar);
-                                File file = new File(outputFolder,
-                                        typename + ".java");
-                                file.getParentFile().mkdirs();
-                                file.createNewFile();
-                                return new FileWriter(file);
-                            }
-                        }, new XmlOptions().setCompileDownloadUrls());
+                        new Axis2Filer(),
+                        null);
 
                 //create the type mapper
                 JavaTypeMapper mapper = new JavaTypeMapper();
                 SchemaType[] types = sts.documentTypes();
-
-                for (int i = 0; i < types.length; i++) {
-                    mapper.addTypeMapping(types[i].getDocumentElementName(),
-                            types[i].getFullJavaName());
+                int length = types.length;
+                for (int j = 0; j < length; j++) {
+                    mapper.addTypeMapping(types[j].getDocumentElementName(),
+                            types[j].getFullJavaName());
                 }
                 //set the type mapper to the config
                 configuration.setTypeMapper(mapper);
 
-            } catch (XmlException e) {
-                throw new RuntimeException(e);
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
+
     }
 
+    private XmlObject[] convertToXMLObjectArray(Vector vec){
+        XmlObject[] xmlObjects = new XmlObject[vec.size()];
+        for (int i = 0; i < vec.size(); i++) {
+            xmlObjects[i] = (XmlObject)vec.get(i);
+        }
+        return xmlObjects;
+    }
+    /**
+     * Private class to generate the filer
+     */
+    private class Axis2Filer implements Filer{
+
+        public OutputStream createBinaryFile(String typename)
+                throws IOException {
+            File file = new File(configuration.getOutputLocation(), typename);
+            file.getParentFile().mkdirs();
+            file.createNewFile();
+            return new FileOutputStream(file);
+        }
 
+        public Writer createSourceFile(String typename)
+                throws IOException {
+            typename =
+                    typename.replace('.', File.separatorChar);
+            File file = new File(configuration.getOutputLocation(),
+                    typename + ".java");
+            file.getParentFile().mkdirs();
+            file.createNewFile();
+            return new FileWriter(file);
+        }
+    }
 }
+

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLTypes.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLTypes.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLTypes.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/WSDLTypes.java Tue Aug  2
02:39:26 2005
@@ -26,7 +26,6 @@
     /**
      * Adds the <code>ExtensionElement</code> to the map keyed with the <code>QName</code>
      *
-     * @param qName
      * @param element
      */
     public void addElement(WSDLExtensibilityElement element);

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java Tue
Aug  2 02:39:26 2005
@@ -19,6 +19,8 @@
 import org.apache.wsdl.WSDLExtensibilityElement;
 import org.w3c.dom.Element;
 
+import java.util.Stack;
+
 /**
  * @author chathura@opensource.lk
  */
@@ -30,8 +32,18 @@
 
     /**
      * Sets the Schema Element as a DOM Element.
-     *
      * @param elelment
      */
     public void setElelment(Element elelment);
+    /**
+     *
+     * @return
+     */
+    public Stack getImportedSchemaStack();
+    /**
+     * 
+     * @param importedSchemaStack
+     */
+    public void setImportedSchemaStack(Stack importedSchemaStack) ;
+
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/SchemaImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/SchemaImpl.java?rev=226976&r1=226975&r2=226976&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/SchemaImpl.java
(original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/SchemaImpl.java
Tue Aug  2 02:39:26 2005
@@ -21,6 +21,8 @@
 import org.apache.wsdl.impl.WSDLExtensibilityElementImpl;
 import org.w3c.dom.Element;
 
+import java.util.Stack;
+
 /**
  * @author chathura@opensource.lk
  */
@@ -28,9 +30,18 @@
         Schema {
 
     private Element elelment;
+    private Stack importedSchemaStack= new Stack();
 
     public SchemaImpl() {
         type = SCHEMA;
+    }
+
+    public Stack getImportedSchemaStack() {
+        return importedSchemaStack;
+    }
+
+    public void setImportedSchemaStack(Stack importedSchemaStack) {
+        this.importedSchemaStack = importedSchemaStack;
     }
 
     /**



Mime
View raw message