You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/08/30 06:43:44 UTC

svn commit: r264704 - in /webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl: codegen/codegen-config.properties codegen/extension/XMLBeansExtension.java codegen/schema/ codegen/schema/xmime.xsd util/ConfigPropertyFileLoader.java

Author: ajith
Date: Mon Aug 29 21:43:31 2005
New Revision: 264704

URL: http://svn.apache.org/viewcvs?rev=264704&view=rev
Log:
Added the support for feeding of third party schema's to the code. The actual feeding of the these schemas is still not done due to some XMLBeans problems.

Added:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/schema/
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/schema/xmime.xsd
Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=264704&r1=264703&r2=264704&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Mon Aug 29 21:43:31 2005
@@ -3,4 +3,7 @@
 #######################################################################################################################
 #Extensions - The extensions are comma seperated
 #these are loaded in their lexical order
-codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
\ No newline at end of file
+codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
+#The thied party schemas to be loaded. ex. The Xmime extension
+# Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema  package
+codegen.thirdparty.schema=xmime.xsd
\ No newline at end of file

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=264704&r1=264703&r2=264704&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 Mon Aug 29 21:43:31 2005
@@ -4,12 +4,18 @@
 import org.apache.axis2.wsdl.codegen.XSLTConstants;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
 import org.apache.wsdl.*;
 import org.apache.wsdl.extensions.ExtensionConstants;
 import org.apache.wsdl.extensions.Schema;
 import org.apache.wsdl.extensions.SOAPBody;
 import org.apache.xmlbeans.*;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 import java.io.*;
 import java.util.*;
 
@@ -49,6 +55,8 @@
         //check the comptibilty
         checkCompatibility();
 
+        Element[] additionalSchemas = loadAdditionalSchemas();
+
         //test whether the TCCL has the Xbeans classes
         //ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
@@ -76,6 +84,14 @@
             //create the type mapper
             JavaTypeMapper mapper = new JavaTypeMapper();
 
+            // run the third party schemas
+//            for (int i = 0; i < additionalSchemas.length; i++) {
+//                System.out.println(additionalSchemas[i]);
+//                xmlObjectsVector.add(XmlObject.Factory.parse(
+//                        additionalSchemas[i]
+//                        ,null));
+//            }
+
             for (int i = 0; i < typesArray.size(); i++) {
                 extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
                 Schema schema;
@@ -85,27 +101,32 @@
                     XmlOptions options = new XmlOptions();
                     options.setLoadAdditionalNamespaces(
                             configuration.getWom().getNamespaces()); //add the namespaces
+                    //        options.
 
                     Stack importedSchemaStack = schema.getImportedSchemaStack();
                     //compile these schemas
                     while (!importedSchemaStack.isEmpty()){
                         javax.wsdl.extensions.schema.Schema tempSchema = (javax.wsdl.extensions.schema.Schema) importedSchemaStack.pop();
+                        Element element = tempSchema.getElement();
                         xmlObjectsVector.add(
                                 XmlObject.Factory.parse(
-                                        tempSchema.getElement()
+                                        element
                                         ,options));
 
-                    }
 
+                    }
 
                 }
 
             }
+
+
             sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
                     convertToXMLObjectArray(xmlObjectsVector),
                     new BindingConfig(), XmlBeans.getContextTypeLoader(),
                     new Axis2Filer(),
                     null);
+
             SchemaType[] schemaType = sts.documentTypes();
             SchemaType type;
             for (int j = 0; j < schemaType.length; j++) {
@@ -121,6 +142,33 @@
 
     }
 
+    private Element[] loadAdditionalSchemas() {
+        //load additional schemas
+        String[] schemaNames = ConfigPropertyFileLoader.getThirdPartySchemaNames();
+        Element[] schemaElements = null;
+
+        try {
+            ArrayList additionalSchemaElements = new ArrayList();
+            for (int i = 0; i < schemaNames.length; i++) {
+                InputStream schemaStream = this.getClass().getResourceAsStream("/org/apache/axis2/wsdl/codegen/schema/"+ schemaNames[i]);
+                Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(schemaStream);
+                additionalSchemaElements.add(doc.getDocumentElement());
+            }
+
+            //Create the Schema element array
+            schemaElements = new Element[additionalSchemaElements.size()];
+            for (int i = 0; i < additionalSchemaElements.size(); i++) {
+                schemaElements[i] = (Element) additionalSchemaElements.get(i);
+
+            }
+        } catch (Exception e) {
+            //log this and get going.
+            log.error("Additional schema loading failed!!",e);
+        }
+
+        return schemaElements;
+    }
+
 
     /**
      * Checking the compatibilty has to do with generating RPC/encoded stubs.
@@ -145,7 +193,7 @@
                 .iterator();
         while (extIterator.hasNext()) {
             WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
-            if (element.getType().equals(ExtensionConstants.SOAP_BODY)) {
+            if (ExtensionConstants.SOAP_BODY.equals(element.getType())) {
                 if (WSDLConstants.WSDL_USE_ENCODED.equals(
                         ((SOAPBody) element).getUse())) {
                     throw new RuntimeException(

Added: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/schema/xmime.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/schema/xmime.xsd?rev=264704&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/schema/xmime.xsd (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/schema/xmime.xsd Mon Aug 29 21:43:31 2005
@@ -0,0 +1,21 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns:tns="http://www.w3.org/2004/06/xmlmime"
+           targetNamespace="http://www.w3.org/2004/06/xmlmime" >
+ <xs:attribute name="contentType" >
+    <xs:simpleType>
+      <xs:restriction base="xs:string" >
+        <xs:pattern value="(text|application|image|audio|video|model|x-[-.a-z0-9]+)/[a-z0-9][-.+a-z0-9]+(;\s?.+=.+)*" />
+      </xs:restriction>
+    </xs:simpleType>
+</xs:attribute>
+<xs:element name="expectedMediaType" >
+    <xs:simpleType>
+      <xs:list itemType="tns:expectedMediaTypeItem" />
+    </xs:simpleType>
+</xs:element>
+<xs:simpleType name="expectedMediaTypeItem" >
+    <xs:restriction base="xs:string" >
+        <xs:pattern value="(text|application|image|audio|video|model|x-[-.a-z0-9]+)/(([a-z0-9][-.+a-z0-9]+)|\*)" />
+    </xs:restriction>
+</xs:simpleType>
+</xs:schema>
\ No newline at end of file

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java?rev=264704&r1=264703&r2=264704&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java Mon Aug 29 21:43:31 2005
@@ -10,8 +10,10 @@
 public class ConfigPropertyFileLoader {
 
     private static String[] extensionClassNames;
+    private static String[] thirdPartySchemaNames;
 
     private static final String CODE_GEN_KEY = "codegen.extension";
+    private static final String THIRD_PARTY_SCHEMA_KEY = "codegen.thirdparty.schema";
 
     static{
         try {
@@ -25,6 +27,12 @@
 
             }
 
+            String thirdPartySchemas = props.getProperty(THIRD_PARTY_SCHEMA_KEY);
+            if (thirdPartySchemas!=null){
+                thirdPartySchemaNames = thirdPartySchemas.split(",");
+
+            }
+
 
 
         } catch (IOException e) {
@@ -35,5 +43,9 @@
 
     public static String[] getExtensionClassNames() {
         return extensionClassNames;
+    }
+
+    public static String[] getThirdPartySchemaNames() {
+        return thirdPartySchemaNames;
     }
 }