axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsosno...@apache.org
Subject svn commit: r392918 - in /webservices/axis2/trunk/java: ./ etc/ modules/codegen/ modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ modules/integration/ modules/security/
Date Mon, 10 Apr 2006 10:48:08 GMT
Author: dsosnoski
Date: Mon Apr 10 03:48:03 2006
New Revision: 392918

URL: http://svn.apache.org/viewcvs?rev=392918&view=rev
Log:
Restructing for separate XMLBeans code generation module

Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/maven.xml
    webservices/axis2/trunk/java/modules/codegen/project.xml
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis2/trunk/java/modules/integration/project.xml
    webservices/axis2/trunk/java/modules/security/project.xml

Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Mon Apr 10 03:48:03 2006
@@ -53,6 +53,7 @@
 modules/java2wsdl/project.xml,\
 modules/adb/project.xml,\
 modules/codegen/project.xml,\
+modules/xmlbeans/project.xml,\
 modules/wsdl/project.xml,\
 modules/java2wsdl/project.xml,\
 modules/core/project.xml,\

Modified: webservices/axis2/trunk/java/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/maven.xml?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/maven.xml (original)
+++ webservices/axis2/trunk/java/maven.xml Mon Apr 10 03:48:03 2006
@@ -396,6 +396,11 @@
             <ant:fileset file="modules/codegen/target/axis2-codegen-${pom.currentVersion}.jar"/>
         </ant:copy>
 
+        <!-- Copy the xmlbeans jar -->
+        <ant:copy toDir="target/temp/war/lib">
+            <ant:fileset file="modules/xmlbeans/target/axis2-xmlbeans-${pom.currentVersion}.jar"/>
+        </ant:copy>
+
         <!-- Copy the jibx jar -->
         <ant:copy toDir="target/temp/war/lib">
             <ant:fileset file="modules/jibx/target/axis2-jibx-${pom.currentVersion}.jar"/>
@@ -618,6 +623,7 @@
         <ant:copy toDir="${std.bin.temp.dir}/lib">
             <ant:fileset file="modules/adb/target/axis2-adb-${pom.currentVersion}.jar"/>
             <ant:fileset file="modules/codegen/target/axis2-codegen-${pom.currentVersion}.jar"/>
+            <ant:fileset file="modules/xmlbeans/target/axis2-xmlbeans-${pom.currentVersion}.jar"/>
             <ant:fileset file="modules/jibx/target/axis2-jibx-${pom.currentVersion}.jar"/>
         </ant:copy>
 
@@ -631,6 +637,11 @@
             <ant:fileset file="modules/codegen/target/axis2-codegen-${pom.currentVersion}.jar"/>
         </ant:copy>
 
+        <!-- Copy the xmlbeans jar -->
+        <ant:copy toDir="${std.bin.temp.dir}/lib">
+            <ant:fileset file="modules/xmlbeans/target/axis2-xmlbeans-${pom.currentVersion}.jar"/>
+        </ant:copy>
+
         <!-- Copy the samples -->
         <ant:copy todir="${std.bin.temp.dir}/samples">
             <ant:fileset dir="modules/samples/target/samples"/>
@@ -670,6 +681,7 @@
                 <ant:include name="**/modules/adb/**"/>
                 <ant:include name="**/modules/codegen/**"/>
                 <ant:include name="**/modules/webapp/**"/>
+                <ant:include name="**/modules/xmlbeans/**"/>
                 <ant:include name="**/modules/jibx/**"/>
                 <ant:include name="**/modules/addressing/**"/>
                 <ant:include name="**/modules/samples/**"/>
@@ -793,6 +805,7 @@
                 <ant:pathelement location="modules/adb/src"/>
                 <ant:pathelement location="modules/addressing/src"/>
                 <ant:pathelement location="modules/codegen/src"/>
+                <ant:pathelement location="modules/xmlbeans/src"/>
                 <ant:pathelement location="modules/java2wsdl/src"/>
                 <ant:pathelement location="modules/common/src"/>
                 <ant:pathelement location="modules/core/src"/>
@@ -884,6 +897,7 @@
             <ant:fileset file="modules/common/target/axis2-common-${pom.currentVersion}.jar"/>
             <ant:fileset file="modules/adb/target/axis2-adb-${pom.currentVersion}.jar"/>
             <ant:fileset file="modules/codegen/target/axis2-codegen-${pom.currentVersion}.jar"/>
+            <ant:fileset file="modules/xmlbeans/target/axis2-xmlbeans-${pom.currentVersion}.jar"/>
             <ant:fileset file="modules/jibx/target/axis2-jibx-${pom.currentVersion}.jar"/>
             <ant:fileset file="modules/java2wsdl/target/axis2-java2wsdl-${pom.currentVersion}.jar"/>
         </ant:copy>

Modified: webservices/axis2/trunk/java/modules/codegen/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/project.xml?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/project.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/project.xml Mon Apr 10 03:48:03 2006
@@ -70,15 +70,6 @@
             </properties>
         </dependency>
         <dependency>
-            <groupId>xmlbeans</groupId>
-            <artifactId>xbean</artifactId>
-            <version>${xbean.version}</version>
-            <type>jar</type>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
             <version>${commons.logging.version}</version>
@@ -192,14 +183,6 @@
             <groupId>jaxme</groupId>
             <artifactId>jaxmexs</artifactId>
             <version>${jaxme.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>jibx</groupId>
-            <artifactId>jibx-run</artifactId>
-            <version>${jibx.version}</version>
             <properties>
                 <module>true</module>
             </properties>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java
Mon Apr 10 03:48:03 2006
@@ -45,7 +45,6 @@
             return;
         }
 
-
         // check the JiBX binding definition file specified
         String path = (String)configuration.getProperties().get(BINDING_PATH_OPTION);
         if (path == null) {
@@ -54,18 +53,22 @@
         }
         try {
 
-            // load and call JiBX utilities to handle binding
-            Class clazz = null;
+            // try dummy load of framework class first to check missing jars
             try {
-                JiBXExtension.class.getClassLoader().loadClass(JIBX_MODEL_CLASS);
+                getClass().getClassLoader().loadClass(JIBX_MODEL_CLASS);
             } catch (ClassNotFoundException e) {
                 throw new RuntimeException("JiBX framework jars not in classpath");
             }
+            
+            // load the actual utility class
+            Class clazz = null;
             try {
                 clazz = JiBXExtension.class.getClassLoader().loadClass(JIBX_UTILITY_CLASS);
             } catch (ClassNotFoundException e) {
                 throw new RuntimeException("JiBX binding extension not in classpath");
             }
+            
+            // invoke utility class method for actual processing
             Method method = clazz.getMethod(BINDING_MAP_METHOD,
                     new Class[] { String.class });
             HashMap jibxmap = (HashMap)method.invoke(null, new Object[] { path });

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
Mon Apr 10 03:48:03 2006
@@ -16,23 +16,21 @@
 
 package org.apache.axis2.wsdl.codegen.extension;
 
-import org.apache.axis2.namespace.Constants;
-import org.apache.axis2.util.URLProcessor;
-import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
-import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
-import org.apache.axis2.wsdl.i18n.CodegenMessages;
-import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
-import org.apache.axis2.wsdl.util.XSLTConstants;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.xmlbeans.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import java.io.*;
-import java.util.*;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.i18n.CodegenMessages;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 public class XMLBeansExtension extends AbstractDBProcessingExtension {
     public static final String SCHEMA_FOLDER = "schemas";
@@ -45,6 +43,12 @@
     public static final String MAPPING_FOLDER = "Mapping";
     public static final String MAPPER_FILE_NAME = "mapper";
     public static final String SCHEMA_PATH = "/org/apache/axis2/wsdl/codegen/schema/";
+    
+    public static final String XMLBEANS_CONFIG_CLASS =
+        "org.apache.xmlbeans.BindingConfig";
+    public static final String XMLBEANS_UTILITY_CLASS =
+        "org.apache.axis2.xmlbeans.CodeGenerationUtility";
+    public static final String XMLBEANS_PROCESS_METHOD = "processSchemas";
 
     boolean debug = false;
 
@@ -57,163 +61,39 @@
 
         //check the comptibilty
         //checkCompatibility();
-
-        // Note  - typically we  need to check the presence of unwrapped or wrapped
-        // parameter style  here. However XMLBeans nicely generates classes for all
-        // elements,even internal ones and hence in this extension we do not have to
-        // special case anything
-
-        Element[] additionalSchemas = loadAdditionalSchemas();
-
         try {
-            //get the types from the types section
-            ArrayList schemas = configuration.getAxisService().getSchema();
-
-            //check for the imported types. Any imported types are supposed to be here also
-            if (schemas == null || schemas.isEmpty()) {
-                //there are no types to be code generated
-                //However if the type mapper is left empty it will be a problem for the other
-                //processes. Hence the default type mapper is set to the configuration
-                this.configuration.setTypeMapper(new DefaultTypeMapper());
-                return;
-            }
-
-            // todo - improve this code by using the schema compiler from
-            //xmlbeans directly
-
-            SchemaTypeSystem sts;
-            Vector xmlObjectsVector = new Vector();
-            //create the type mapper
-            JavaTypeMapper mapper = new JavaTypeMapper();
-            Map nameSpacesMap = configuration.getAxisService().getNameSpacesMap();
-            for (int i = 0; i < schemas.size(); i++) {
-
-                XmlSchema schema = (XmlSchema) schemas.get(i);
-                XmlOptions options = new XmlOptions();
-
-                options.setLoadAdditionalNamespaces(
-                        nameSpacesMap); //add the namespaces
-                xmlObjectsVector.add(
-                        XmlObject.Factory.parse(
-                                getSchemaAsString(schema)
-                                , options));
-
-            }
 
-            // add the third party schemas
-            //todo perhaps checking the namespaces would be a good idea to
-            //make the generated code work efficiently
-            for (int i = 0; i < additionalSchemas.length; i++) {
-                xmlObjectsVector.add(XmlObject.Factory.parse(
-                        additionalSchemas[i]
-                        , null));
-            }
+            // try dummy load of framework class first to check missing jars
+            try {
+                getClass().getClassLoader().loadClass(XMLBEANS_CONFIG_CLASS);
+            } catch (ClassNotFoundException e) {
+                throw new RuntimeException("XMLBeans framework jars not in classpath");
+            }
+            
+            // load the actual utility class
+            Class clazz = null;
+            try {
+                clazz = getClass().getClassLoader().loadClass(XMLBEANS_UTILITY_CLASS);
+            } catch (ClassNotFoundException e) {
+                throw new RuntimeException("XMLBeans binding extension not in classpath");
+            }
+            
+            // invoke utility class method for actual processing
+            Method method = clazz.getMethod(XMLBEANS_PROCESS_METHOD,
+                    new Class[] { List.class, Element[].class, CodeGenConfiguration.class
});
+            ArrayList schemas = configuration.getAxisService().getSchema();
+            Element[] additionalSchemas = loadAdditionalSchemas();
+            TypeMapper mapper = (TypeMapper)method.invoke(null,
+                new Object[] { schemas, additionalSchemas, configuration });
 
-            //compile the type system
-            XmlObject[] objeArray = convertToXMLObjectArray(xmlObjectsVector);
-            BindingConfig config = new Axis2BindingConfig();
-
-            //set the STS name to null. it makes the generated class include a unique (but
random) STS name
-            sts = XmlBeans.compileXmlBeans(null, null,
-                    objeArray,
-                    config, XmlBeans.getContextTypeLoader(),
-                    new Axis2Filer(),
-                    null);
-
-            // prune the generated schema type system and add the list of base64 types
-            FindBase64Types(sts);
-            findPlainBase64Types(sts);
-
-            //get the schematypes and add the document types to the type mapper
-            SchemaType[] schemaType = sts.documentTypes();
-            SchemaType type;
-            for (int j = 0; j < schemaType.length; j++) {
-                type = schemaType[j];
-                mapper.addTypeMappingName(type.getDocumentElementName(),
-                        type.getFullJavaName());
-            }
-            //set the type mapper to the config
+            // set the type mapper to the config
             configuration.setTypeMapper(mapper);
 
-
         } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
-    }
-
-
-    /**
-     * Populate the base64 types
-     * The algo is to look for simpletypes that have base64 content, and then step out of
that
-     * onestep and get the element. For now there's an extended check to see whether the
simple type
-     * is related to the Xmime:contentType!
-     *
-     * @param sts
-     */
-    private void FindBase64Types(SchemaTypeSystem sts) {
-        List allSeenTypes = new ArrayList();
-        List base64ElementQNamesList = new ArrayList();
-        SchemaType outerType;
-//add the document types and global types
-        allSeenTypes.addAll(Arrays.asList(sts.documentTypes()));
-        allSeenTypes.addAll(Arrays.asList(sts.globalTypes()));
-        for (int i = 0; i < allSeenTypes.size(); i++) {
-            SchemaType sType = (SchemaType) allSeenTypes.get(i);
-
-            if (sType.getContentType() == SchemaType.SIMPLE_CONTENT && sType.getPrimitiveType()
!= null) {
-                if (Constants.BASE_64_CONTENT_QNAME.equals(sType.getPrimitiveType().getName()))
{
-                    outerType = sType.getOuterType();
-//check the outer type further to see whether it has the contenttype attribute from
-//XMime namespace
-                    SchemaProperty[] properties = sType.getProperties();
-                    for (int j = 0; j < properties.length; j++) {
-                        if (Constants.XMIME_CONTENT_TYPE_QNAME.equals(properties[j].getName()))
{
-                            base64ElementQNamesList.add(outerType.getDocumentElementName());
-                            break;
-                        }
-                    }
-                }
-            }
-            //add any of the child types if there are any
-            allSeenTypes.addAll(Arrays.asList(sType.getAnonymousTypes()));
-        }
-
-        configuration.putProperty(XSLTConstants.BASE_64_PROPERTY_KEY, base64ElementQNamesList);
-    }
-
-    private void findPlainBase64Types(SchemaTypeSystem sts) {
-        ArrayList allSeenTypes = new ArrayList();
-
-        allSeenTypes.addAll(Arrays.asList(sts.documentTypes()));
-        allSeenTypes.addAll(Arrays.asList(sts.globalTypes()));
-
-        ArrayList base64Types = new ArrayList();
-
-        for (Iterator iterator = allSeenTypes.iterator(); iterator.hasNext();) {
-            SchemaType stype = (SchemaType) iterator.next();
-            findPlainBase64Types(stype, base64Types);
-        }
-
-        configuration.putProperty(XSLTConstants.PLAIN_BASE_64_PROPERTY_KEY, base64Types);
-    }
-
-    private void findPlainBase64Types(SchemaType stype, ArrayList base64Types) {
-
-        SchemaProperty[] elementProperties = stype.getElementProperties();
-
-        for (int i = 0; i < elementProperties.length; i++) {
-            SchemaType schemaType = elementProperties[i].getType();
-
-            if (schemaType.isPrimitiveType()) {
-                SchemaType primitiveType = schemaType.getPrimitiveType();
-
-                if (Constants.BASE_64_CONTENT_QNAME.equals(primitiveType.getName())) {
-                    base64Types.add(elementProperties[i].getName());
-                }
-
+            if (e instanceof RuntimeException) {
+                throw (RuntimeException)e;
             } else {
-                findPlainBase64Types(schemaType, base64Types);
+                throw new RuntimeException(e);
             }
         }
     }
@@ -258,83 +138,4 @@
         documentBuilderFactory.setNamespaceAware(true);
         return documentBuilderFactory.newDocumentBuilder();
     }
-
-
-    private XmlObject[] convertToXMLObjectArray(Vector vec) {
-        return (XmlObject[]) vec.toArray(new XmlObject[vec.size()]);
-    }
-
-    /**
-     * Private class to generate the filer
-     */
-    private class Axis2Filer implements Filer {
-
-        public OutputStream createBinaryFile(String typename)
-                throws IOException {
-            File resourcesDirectory = new File(configuration.getOutputLocation(), "resources");
-            if (!resourcesDirectory.exists()) {
-                resourcesDirectory.mkdirs();
-            }
-            File file = new File(resourcesDirectory, typename);
-            file.getParentFile().mkdirs();
-            file.createNewFile();
-            return new FileOutputStream(file);
-        }
-
-        public Writer createSourceFile(String typename)
-                throws IOException {
-            typename =
-                    typename.replace('.', File.separatorChar);
-            File outputDir = new File(configuration.getOutputLocation(), "src");
-            if (!outputDir.exists()) {
-                outputDir.mkdirs();
-            }
-            File file = new File(outputDir,
-                    typename + ".java");
-            file.getParentFile().mkdirs();
-            file.createNewFile();
-            return new FileWriter(file);
-        }
-    }
-
-    /**
-     * Convert schema into a String
-     *
-     * @param schema
-     */
-    private String getSchemaAsString(XmlSchema schema) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        schema.write(baos);
-        return baos.toString();
-    }
-
-    /**
-     * Custom binding configuration for the code generator. This controls
-     * how the namespaces are suffixed/prefixed
-     */
-    private class Axis2BindingConfig extends BindingConfig {
-        public String lookupPackageForNamespace(String uri) {
-            return URLProcessor.makePackageName(uri);
-        }
-    }
-
-//    /**
-//     *
-//     */
-//    public static class Axis2SchemaCompilerExtension implements SchemaCompilerExtension{
-//        private SchemaTypeSystem sts;
-//
-//        public SchemaTypeSystem getSts() {
-//            return sts;
-//        }
-//
-//        public void schemaCompilerExtension(SchemaTypeSystem schemaTypeSystem, Map parms)
{
-//            this.sts = schemaTypeSystem;
-//        }
-//
-//        public String getExtensionName() {
-//            return "Axis2.xmlbeans.extension";
-//        }
-//    }
 }
-

Modified: webservices/axis2/trunk/java/modules/integration/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/project.xml?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/project.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/project.xml Mon Apr 10 03:48:03 2006
@@ -78,6 +78,11 @@
         </dependency>
         <dependency>
             <groupId>axis2</groupId>
+            <artifactId>axis2-xmlbeans</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
             <artifactId>axis2-addressing</artifactId>
             <version>${pom.currentVersion}</version>
         </dependency>

Modified: webservices/axis2/trunk/java/modules/security/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/project.xml?rev=392918&r1=392917&r2=392918&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/project.xml (original)
+++ webservices/axis2/trunk/java/modules/security/project.xml Mon Apr 10 03:48:03 2006
@@ -62,6 +62,16 @@
             <artifactId>axis2-adb</artifactId>
             <version>${pom.currentVersion}</version>
         </dependency>         
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-jibx</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>         
+       <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-xmlbeans</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>         
         <!-- external JARs -->
         <dependency>
             <groupId>axis</groupId>



Mime
View raw message