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/15 15:24:16 UTC

svn commit: r232811 - in /webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen: CodeGenConfiguration.java CodeGenerationEngine.java extension/XMLBeansExtension.java

Author: ajith
Date: Mon Aug 15 06:23:51 2005
New Revision: 232811

URL: http://svn.apache.org/viewcvs?rev=232811&view=rev
Log:
Fixed the multiple schema element bug. 
Codegen engine is also improved

Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.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/extension/XMLBeansExtension.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=232811&r1=232810&r2=232811&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java Mon Aug 15 06:23:51 2005
@@ -1,18 +1,18 @@
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed 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.
- */
+* Copyright 2001-2004 The Apache Software Foundation.
+*
+* Licensed 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.axis2.wsdl.codegen;
 
@@ -115,9 +115,11 @@
         }
 
 // Unused code commented out by gdaniels...
-//
-//        CommandLineOption dataBindingOption = (CommandLineOption) optionMap.get(
-//                DATA_BINDING_TYPE_OPTION);
+        CommandLineOption dataBindingOption = (CommandLineOption) optionMap.get(
+                DATA_BINDING_TYPE_OPTION);
+        if (dataBindingOption!=null){
+            this.databindingType = Integer.parseInt(dataBindingOption.getOptionValue());
+        }
 
     }
 

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=232811&r1=232810&r2=232811&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 Mon Aug 15 06:23:51 2005
@@ -60,30 +60,22 @@
     private void loadExtensions() {
         //Ideally these extensions should be loaded through a configuration taken
         //from some external location. Say a config file.
-
-        AxisBindingBuilder axisBindingBuilder = new AxisBindingBuilder();
-        axisBindingBuilder.init(this.configuration);
-        axisBindingBuilder.engage();
-
-        WSDLValidatorExtension validatorExtension = new WSDLValidatorExtension();
-        validatorExtension.init(this.configuration);
-        this.moduleEndpoints.add(validatorExtension);
-
-        PackageFinder packageFinder = new PackageFinder();
-        packageFinder.init(this.configuration);
-        this.moduleEndpoints.add(packageFinder);
-
+        addExtension(new AxisBindingBuilder());
+        addExtension(new WSDLValidatorExtension());
+        addExtension(new PackageFinder());
         //Xbeans extension
-        XMLBeansExtension xbeansExtension = new XMLBeansExtension();
-        xbeansExtension.init(this.configuration);
-        this.moduleEndpoints. add(xbeansExtension);
+        addExtension(new XMLBeansExtension());
+        //simple databinding extension
+        //addExtension(new SimpleDBExtension());
+        //default extension. Does the cleanup
+        addExtension(new DefaultDatabindingExtension());
 
-        //default databinding extension
-//        AbstractCodeGenerationExtension dbExt = new SimpleDBExtension();
-//        dbExt.init(this.configuration);
-//        this.moduleEndpoints.add(dbExt);
     }
 
+    private void addExtension(AbstractCodeGenerationExtension ext){
+        ext.init(this.configuration);
+        this.moduleEndpoints.add(ext);
+    }
     public void generate() throws CodeGenerationException {
         try {
             for (int i = 0; i < this.moduleEndpoints.size(); i++) {

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=232811&r1=232810&r2=232811&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 15 06:23:51 2005
@@ -1,6 +1,7 @@
 package org.apache.axis2.wsdl.codegen.extension;
 
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
 import org.apache.wsdl.WSDLExtensibilityElement;
@@ -41,6 +42,12 @@
     }
 
     public void engage() {
+
+        //test the databinding type. If not just fall through
+        if (configuration.getDatabindingType()!= XSLTConstants.DataBindingTypes.XML_BEANS){
+            return;
+        }
+
         //test whether the TCCL has the Xbeans classes
         //ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
@@ -57,12 +64,12 @@
 
             List typesArray = typesList.getExtensibilityElements();
             WSDLExtensibilityElement extensiblityElt = null;
-
+            SchemaTypeSystem sts  = null;
+          
+            Vector xmlObjectsVector = new Vector();
             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())) {
                     schema = (Schema) extensiblityElt;
@@ -80,24 +87,26 @@
                     }
                 }
 
-                sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
-                        convertToXMLObjectArray(xmlObjectsVector),
-                        new BindingConfig(), XmlBeans.getContextTypeLoader(),
-                        new Axis2Filer(),
-                        null);
-
-                //create the type mapper
-                JavaTypeMapper mapper = new JavaTypeMapper();
-                SchemaType[] types = sts.documentTypes();
-                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);
+            }
 
+            sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
+                    convertToXMLObjectArray(xmlObjectsVector),
+                    new BindingConfig(), XmlBeans.getContextTypeLoader(),
+                    new Axis2Filer(),
+                    null);
+
+            //create the type mapper
+            JavaTypeMapper mapper = new JavaTypeMapper();
+            SchemaType[] schemaType = sts.documentTypes();
+            SchemaType type;
+            for (int i = 0; i < schemaType.length; i++) {
+                type = schemaType[i];
+                mapper.addTypeMapping(type.getDocumentElementName(),
+                        type.getFullJavaName());
             }
+
+            //set the type mapper to the config
+            configuration.setTypeMapper(mapper);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }