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 am...@apache.org on 2006/11/23 08:27:03 UTC

svn commit: r478499 - in /webservices/axis2/trunk/java/modules: adb-codegen/src/org/apache/axis2/schema/ adb-codegen/src/org/apache/axis2/schema/writer/ codegen/src/org/apache/axis2/wsdl/codegen/emitter/

Author: amilas
Date: Wed Nov 22 23:27:02 2006
New Revision: 478499

URL: http://svn.apache.org/viewvc?view=rev&rev=478499
Log:
applied the patch for the issue AXIS2_1762

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java Wed Nov 22 23:27:02 2006
@@ -7,9 +7,7 @@
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.wsdl.WSDLUtil;
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
-import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
-import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
-import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.databinding.*;
 import org.apache.axis2.wsdl.util.Constants;
 import org.apache.axis2.util.URLProcessor;
 import org.apache.axis2.AxisFault;
@@ -78,7 +76,15 @@
         //First try to take the one that is already there
         TypeMapper mapper = configuration.getTypeMapper();
         if (mapper == null) {
-            mapper = new JavaTypeMapper();
+            if (configuration.getOutputLanguage() != null &&
+                    !configuration.getOutputLanguage().trim().equals("") &&
+                    configuration.getOutputLanguage().toLowerCase().equals("c")) {
+                mapper = new CTypeMapper();
+
+            }  else {
+                mapper = new JavaTypeMapper();
+            }
+
         }
 
         if (options.isWriteOutput()) {

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Wed Nov 22 23:27:02 2006
@@ -127,18 +127,8 @@
     public static final String ANY_ELEMENT_FIELD_NAME = "extraElement";
     public static final String EXTRA_ATTRIBUTE_FIELD_NAME = "extraAttributes";
 
-    public static final String DEFAULT_CLASS_NAME = OMElement.class.getName();
-    public static final String DEFAULT_CLASS_ARRAY_NAME = "org.apache.axiom.om.OMElement[]";
-
-    public static final String DEFAULT_ATTRIB_CLASS_NAME = OMAttribute.class.getName();
-    public static final String DEFAULT_ATTRIB_ARRAY_CLASS_NAME = "org.apache.axiom.om.OMAttribute[]";
-
-
     private static int typeCounter = 0;
 
-
-
-
     /**
      * @return the processes element map
      * includes the Qname of the element as the key and a
@@ -462,7 +452,7 @@
             log.warn(SchemaCompilerMessages.getMessage("schema.elementWithNoType", xsElt.getQName().toString()));
             metainf.registerMapping(xsElt.getQName(),
                     null,
-                    DEFAULT_CLASS_NAME,
+                    writer.getDefaultClassName(),
                     SchemaConstants.ANY_TYPE);
         }
 
@@ -615,7 +605,7 @@
         }else if (xsElt.getRefName()!=null){
 
             if(xsElt.getRefName().equals(SchemaConstants.XSD_SCHEMA)){
-                innerElementMap.put(xsElt.getQName(), SchemaCompiler.DEFAULT_CLASS_NAME);
+                innerElementMap.put(xsElt.getQName(), writer.getDefaultClassName());
                 return;
             }
             //process the referenced type. It could be thought that the referenced element replaces this
@@ -824,7 +814,7 @@
             //contained schema type. We better set the default then
             //however it's better if the default can be set through the
             //property file
-            className = DEFAULT_CLASS_NAME;
+            className = writer.getDefaultClassName();
             log.warn(SchemaCompilerMessages
                     .getMessage("schema.typeMissing", qName.toString()));
         }
@@ -1039,7 +1029,7 @@
             processParticle(extension.getParticle(),metaInfHolder,parentSchema);
             String className = findClassName(extension.getBaseTypeName(), false);
 
-            if (!SchemaCompiler.DEFAULT_CLASS_NAME.equals(className)) {
+            if (!writer.getDefaultClassName().equals(className)) {
                 //the particle has been processed, However since this is an extension we need to
                 //add the basetype as an extension to the complex type class.
                 // The basetype has been processed already
@@ -1075,7 +1065,7 @@
             processParticle(restriction.getParticle(),metaInfHolder,parentSchema);
             String className = findClassName(restriction.getBaseTypeName(), false);
 
-            if (!SchemaCompiler.DEFAULT_CLASS_NAME.equals(className)) {
+            if (!writer.getDefaultClassName().equals(className)) {
                 metaInfHolder.setRestriction(true);
                 metaInfHolder.setRestrictionClassName(findClassName(restriction.getBaseTypeName(), false));
                 //Note  - this is no array! so the array boolean is false
@@ -1351,7 +1341,7 @@
         QName qName = new QName(EXTRA_ATTRIBUTE_FIELD_NAME);
         metainf.registerMapping(qName,
                 null,
-                DEFAULT_ATTRIB_ARRAY_CLASS_NAME,//always generate an array of
+                writer.getDefaultAttribClassName(),//always generate an array of
                 //OMAttributes
                 SchemaConstants.ANY_TYPE);
         metainf.addtStatus(qName, SchemaConstants.ATTRIBUTE_TYPE);
@@ -1559,7 +1549,7 @@
                         if(referencedQName.equals(SchemaConstants.XSD_SCHEMA)) {
                             metainfHolder.registerMapping(referencedQName,
                                     null,
-                                    DEFAULT_CLASS_NAME,
+                                    writer.getDefaultClassName(),
                                     SchemaConstants.ANY_TYPE);
                         } else {
                             throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.referencedElementNotFound",referencedQName.toString()));
@@ -1605,7 +1595,7 @@
                 boolean isArray =  ((Boolean) processedElementArrayStatusMap.get(any)).booleanValue();
                 metainfHolder.registerMapping(anyElementFieldName,
                         null,
-                        isArray?DEFAULT_CLASS_ARRAY_NAME:DEFAULT_CLASS_NAME,
+                        isArray?writer.getDefaultClassArrayName():writer.getDefaultClassName(),
                         SchemaConstants.ANY_TYPE);
                 //if it's an array register an extra status flag with the system
                 if (isArray){

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java Wed Nov 22 23:27:02 2006
@@ -118,4 +118,13 @@
      * @param namespaceToUse
      */
     public void writeExtensionMapper(BeanWriterMetaInfoHolder[] metainfArray) throws SchemaCompilationException;
+
+    public String getDefaultClassName();
+
+    public String getDefaultClassArrayName();
+
+    public String getDefaultAttribClassName();
+
+    public String getDefaultAttribArrayClassName();
+
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/CStructWriter.java Wed Nov 22 23:27:02 2006
@@ -59,7 +59,7 @@
     private List namesList;
     private static int count = 0;
     private boolean wrapClasses = false;
-    private boolean writeClasses=false;
+    private boolean writeClasses = false;
 
     protected File rootDir;
 
@@ -72,6 +72,16 @@
 
     private Map baseTypeMap = new JavaTypeMap().getTypeMap();
 
+    // a list of externally identified QNames to be processed. This becomes
+    // useful when  only a list of external elements need to be processed
+
+    public static final String DEFAULT_CLASS_NAME = "axiom_node_t*";
+    public static final String DEFAULT_CLASS_ARRAY_NAME = "axis2_array_list_t";
+
+    public static final String DEFAULT_ATTRIB_CLASS_NAME = "axiom_attribute_t*";
+    public static final String DEFAULT_ATTRIB_ARRAY_CLASS_NAME = "axis2_array_list_t";
+
+
 
     /**
      * Default constructor
@@ -84,21 +94,36 @@
      * obtain the raw DOMmodels used to write the classes.
      * This has no meaning when the classes are supposed to be wrapped  so the
      *
-     * @see BeanWriter#getModelMap()
      * @return Returns Map.
+     * @see BeanWriter#getModelMap()
      */
-    public Map getModelMap(){
+    public Map getModelMap() {
         return modelMap;
     }
 
+    public String getDefaultClassName() {
+        return DEFAULT_CLASS_NAME;
+    }
+
+    public String getDefaultClassArrayName() {
+        return DEFAULT_CLASS_ARRAY_NAME;
+    }
+
+    public String getDefaultAttribClassName() {
+        return DEFAULT_ATTRIB_CLASS_NAME;
+    }
+
+    public String getDefaultAttribArrayClassName() {
+        return DEFAULT_ATTRIB_ARRAY_CLASS_NAME;
+    }
     public void init(CompilerOptions options) throws SchemaCompilationException {
         try {
             initWithFile(options.getOutputLocation());
 
             writeClasses = options.isWriteOutput();
-            if (!writeClasses){
+            if (!writeClasses) {
                 wrapClasses = false;
-            }else{
+            } else {
                 wrapClasses = options.isWrapClasses();
             }
 
@@ -131,6 +156,7 @@
      * @param metainf
      * @return Returns String.
      * @throws org.apache.axis2.schema.SchemaCompilationException
+     *
      */
     public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
 
@@ -179,8 +205,8 @@
         try {
             if (wrapClasses) {
 
-                File outSource = createOutFile(CStructWriter.WRAPPED_DATABINDING_CLASS_NAME,".c");
-                File outHeader = createOutFile(CStructWriter.WRAPPED_DATABINDING_CLASS_NAME,".h");
+                File outSource = createOutFile(CStructWriter.WRAPPED_DATABINDING_CLASS_NAME, ".c");
+                File outHeader = createOutFile(CStructWriter.WRAPPED_DATABINDING_CLASS_NAME, ".h");
                 //parse with the template and create the files
                 parseSource(globalWrappedSourceDocument, outSource);
                 parseHeader(globalWrappedHeaderDocument, outHeader);
@@ -196,7 +222,8 @@
      * @param metainf
      * @return Returns String.
      * @throws org.apache.axis2.schema.SchemaCompilationException
-     * @see org.apache.axis2.schema.writer.BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType, java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
+     *
+     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType, java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
      */
     public String write(XmlSchemaSimpleType simpleType, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
         try {
@@ -230,7 +257,9 @@
     }
 
 
-    /** Make the fully qualified class name for an element or named type
+    /**
+     * Make the fully qualified class name for an element or named type
+     *
      * @param qName the qualified Name for this element or type in the schema
      * @return the appropriate fully qualified class name to use in generated code
      */
@@ -283,10 +312,10 @@
             Document modelSource = XSLTUtils.getDocument();
             Document modelHeader = XSLTUtils.getDocument();
             //make the XML
-            modelSource.appendChild(getBeanElement(modelSource, className, originalName,  qName, isElement, metainf, propertyNames, typeMap));
-            modelHeader.appendChild(getBeanElement(modelHeader, className, originalName,  qName, isElement, metainf, propertyNames, typeMap));
+            modelSource.appendChild(getBeanElement(modelSource, className, originalName, qName, isElement, metainf, propertyNames, typeMap));
+            modelHeader.appendChild(getBeanElement(modelHeader, className, originalName, qName, isElement, metainf, propertyNames, typeMap));
 
-            if (writeClasses){
+            if (writeClasses) {
                 //create the file
                 File outSource = createOutFile(className, ".c");
                 File outHeader = createOutFile(className, ".h");
@@ -297,11 +326,11 @@
 
             //add the model to the model map
             modelMap.put(
-                    new QName(qName.getNamespaceURI(),className)
-                    ,modelSource);
+                    new QName(qName.getNamespaceURI(), className)
+                    , modelSource);
             modelMap.put(
-                    new QName(qName.getNamespaceURI(),className)
-                    ,modelHeader);
+                    new QName(qName.getNamespaceURI(), className)
+                    , modelHeader);
 
 
         }
@@ -323,6 +352,7 @@
      * @param typeMap
      * @return Returns Element.
      * @throws org.apache.axis2.schema.SchemaCompilationException
+     *
      */
     private Element getBeanElement(
             Document model, String className, String originalName,
@@ -346,7 +376,7 @@
             XSLTUtils.addAttribute(model, "unwrapped", "yes", rootElt);
         }
 
-        if (!writeClasses){
+        if (!writeClasses) {
             XSLTUtils.addAttribute(model, "skip-write", "yes", rootElt);
         }
 
@@ -376,41 +406,41 @@
         }
 
         //populate all the information
-        populateInfo(metainf, model, rootElt, propertyNames, typeMap,false);
+        populateInfo(metainf, model, rootElt, propertyNames, typeMap, false);
 
 
         return rootElt;
     }
 
     /**
-     *
      * @param metainf
      * @param model
      * @param rootElt
      * @param propertyNames
      * @param typeMap
      * @throws org.apache.axis2.schema.SchemaCompilationException
+     *
      */
     private void populateInfo(BeanWriterMetaInfoHolder metainf,
                               Document model,
                               Element rootElt,
                               ArrayList propertyNames,
-                              Map typeMap,boolean isInherited)throws SchemaCompilationException{
-        if (metainf.getParent()!=null){
-            populateInfo(metainf.getParent(),model,rootElt,propertyNames,typeMap,true);
+                              Map typeMap, boolean isInherited) throws SchemaCompilationException {
+        if (metainf.getParent() != null) {
+            populateInfo(metainf.getParent(), model, rootElt, propertyNames, typeMap, true);
         }
-        addPropertyEntries(metainf, model, rootElt, propertyNames, typeMap,isInherited);
+        addPropertyEntries(metainf, model, rootElt, propertyNames, typeMap, isInherited);
 
     }
 
     /**
-     *
      * @param metainf
      * @param model
      * @param rootElt
      * @param propertyNames
      * @param typeMap
      * @throws org.apache.axis2.schema.SchemaCompilationException
+-     *
      */
     private void addPropertyEntries(BeanWriterMetaInfoHolder metainf, Document model, Element rootElt, ArrayList propertyNames,
                                     Map typeMap,
@@ -443,26 +473,25 @@
             if (CClassNameForElement == null) {
                 CClassNameForElement = CStructWriter.DEFAULT_C_CLASS_NAME;
             }
-            CClassNameForElement=   getShortTypeName(CClassNameForElement);
+            CClassNameForElement = getShortTypeName(CClassNameForElement);
 
 
             XSLTUtils.addAttribute(model, "type", CClassNameForElement, property);
 
-
             /**
              * Caps for use in C macros
              */
             XSLTUtils.addAttribute(model, "caps-cname", xmlName.toUpperCase(), property);
             XSLTUtils.addAttribute(model, "caps-type", CClassNameForElement.toUpperCase(), property);
 
-            if (PrimitiveTypeFinder.isPrimitive(CClassNameForElement)){
+            if (PrimitiveTypeFinder.isPrimitive(CClassNameForElement)) {
                 XSLTUtils.addAttribute(model, "primitive", "yes", property);
             }
             //add an attribute that says the type is default
-            if (isDefault(CClassNameForElement)){
+            if (isDefault(CClassNameForElement)) {
                 XSLTUtils.addAttribute(model, "default", "yes", property);
             }
-            
+
             if (typeMap.containsKey(metainf.getSchemaQNameForQName(name))) {
                 XSLTUtils.addAttribute(model, "ours", "yes", property);
             }
@@ -471,24 +500,24 @@
                 XSLTUtils.addAttribute(model, "attribute", "yes", property);
             }
 
-            if (metainf.isNillable(name)){
+            if (metainf.isNillable(name)) {
                 XSLTUtils.addAttribute(model, "nillable", "yes", property);
             }
 
             String shortTypeName;
             if (metainf.getSchemaQNameForQName(name) != null) {
                 //see whether the QName is a basetype
-                if (baseTypeMap.containsKey(metainf.getSchemaQNameForQName(name))){
-                    shortTypeName= metainf.getSchemaQNameForQName(name).getLocalPart();
-                }else{
-                    shortTypeName =  getShortTypeName(CClassNameForElement);
+                if (baseTypeMap.containsKey(metainf.getSchemaQNameForQName(name))) {
+                    shortTypeName = metainf.getSchemaQNameForQName(name).getLocalPart();
+                } else {
+                    shortTypeName = getShortTypeName(CClassNameForElement);
                 }
-            }else{
-                shortTypeName =  getShortTypeName(CClassNameForElement);
+            } else {
+                shortTypeName = getShortTypeName(CClassNameForElement);
             }
             XSLTUtils.addAttribute(model, "shorttypename", shortTypeName, property);
 
-            if (isInherited){
+            if (isInherited) {
                 XSLTUtils.addAttribute(model, "inherited", "yes", property);
             }
 
@@ -511,9 +540,8 @@
 
             if (metainf.getArrayStatusForQName(name)) {
                 String attrName = name.getLocalPart();
-                int arrayTokenStart=attrName.indexOf("Array");
-                if ( arrayTokenStart >= 0 )
-                {
+                int arrayTokenStart = attrName.indexOf("Array");
+                if (arrayTokenStart >= 0) {
                     String arrayEle = attrName.substring(0, arrayTokenStart);
                     XSLTUtils.addAttribute(model, "arrayele", arrayEle, property);
                 }
@@ -536,12 +564,13 @@
 
     /**
      * Test whether the given class name matches the default
+     *
      * @param javaClassNameForElement
      * @return bool
      */
     private boolean isDefault(String javaClassNameForElement) {
-        return SchemaCompiler.DEFAULT_CLASS_NAME.equals(javaClassNameForElement)||
-                SchemaCompiler.DEFAULT_CLASS_ARRAY_NAME.equals(javaClassNameForElement);
+        return getDefaultClassName().equals(javaClassNameForElement) ||
+                getDefaultClassArrayName().equals(javaClassNameForElement);
     }
 
 
@@ -549,6 +578,7 @@
      * Given the xml name, make a unique class name taking into account that some
      * file systems are case sensitive and some are not.
      * -Consider the Jax-WS spec for this
+     *
      * @param listOfNames
      * @param xmlName
      * @return Returns String.
@@ -584,11 +614,11 @@
         String templateName = javaBeanTemplateName;
         if (templateName != null) {
             try {
-                String sourceTemplateName = templateName + "Source.xsl" ;
+                String sourceTemplateName = templateName + "Source.xsl";
                 xslStream = clazz.getResourceAsStream(sourceTemplateName);
                 sourceTemplateCache = TransformerFactory.newInstance().newTemplates(new StreamSource(xslStream));
 
-                String headerTemplateName =  templateName + "Header.xsl";
+                String headerTemplateName = templateName + "Header.xsl";
                 xslStream = clazz.getResourceAsStream(headerTemplateName);
                 headerTemplateCache = TransformerFactory.newInstance().newTemplates(new StreamSource(xslStream));
 
@@ -653,6 +683,7 @@
         outStream.close();
 
     }
+
     /**
      * Get a prefix for a namespace URI.  This method will ALWAYS
      * return a valid prefix - if the given URI is already mapped in this
@@ -703,9 +734,9 @@
         return prefix;
     }
 
-    private String getShortTypeName(String typeClassName){
-        if (typeClassName.endsWith("[]")){
-            typeClassName = typeClassName.substring(0,typeClassName.lastIndexOf("["));
+    private String getShortTypeName(String typeClassName) {
+        if (typeClassName.endsWith("[]")) {
+            typeClassName = typeClassName.substring(0, typeClassName.lastIndexOf("["));
         }
         return typeClassName;
 
@@ -713,8 +744,9 @@
 
     /**
      * Keep unimplemented
-     * @see BeanWriter#registerExtensionMapperPackageName(String)
+     *
      * @param mapperPackageName
+     * @see BeanWriter#registerExtensionMapperPackageName(String)
      */
     public void registerExtensionMapperPackageName(String mapperPackageName) {
         //unimplemented
@@ -722,16 +754,18 @@
 
     /**
      * Keep unimplemented
-     * @see BeanWriter#writeExtensionMapper(org.apache.axis2.schema.BeanWriterMetaInfoHolder[])
+     *
      * @param metainfArray
+     * @see BeanWriter#writeExtensionMapper(org.apache.axis2.schema.BeanWriterMetaInfoHolder[])
      */
-    public void writeExtensionMapper(BeanWriterMetaInfoHolder[] metainfArray) throws SchemaCompilationException{
+    public void writeExtensionMapper(BeanWriterMetaInfoHolder[] metainfArray) throws SchemaCompilationException {
         //unimplemented
     }
 
     /**
      * Keep unimplemented
-     * @see org.apache.axis2.schema.writer.BeanWriter#getExtensionMapperPackageName() 
+     *
+     * @see BeanWriter#getExtensionMapperPackageName()
      */
     public String getExtensionMapperPackageName() {
         return null;

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Wed Nov 22 23:27:02 2006
@@ -11,6 +11,8 @@
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -23,22 +25,21 @@
 import java.io.*;
 import java.util.*;
 
-
 /*
- * Copyright 2004,2005 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 2004,2005 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.
+*/
 
 /**
  * Java Bean writer for the schema compiler.
@@ -86,6 +87,16 @@
 
     public static final String EXTENSION_MAPPER_CLASSNAME = "ExtensionMapper";
 
+    // a list of externally identified QNames to be processed. This becomes
+    // useful when  only a list of external elements need to be processed
+
+    public static final String DEFAULT_CLASS_NAME = OMElement.class.getName();
+    public static final String DEFAULT_CLASS_ARRAY_NAME = "org.apache.axiom.om.OMElement[]";
+
+    public static final String DEFAULT_ATTRIB_CLASS_NAME = OMAttribute.class.getName();
+    public static final String DEFAULT_ATTRIB_ARRAY_CLASS_NAME = "org.apache.axiom.om.OMAttribute[]";
+
+
     /**
      * Default constructor
      */
@@ -105,10 +116,26 @@
         return modelMap;
     }
 
+    public String getDefaultClassName() {
+        return DEFAULT_CLASS_NAME;
+    }
+
+    public String getDefaultClassArrayName() {
+        return DEFAULT_CLASS_ARRAY_NAME;
+    }
+
+    public String getDefaultAttribClassName() {
+        return DEFAULT_ATTRIB_CLASS_NAME;
+    }
+
+    public String getDefaultAttribArrayClassName() {
+        return DEFAULT_ATTRIB_ARRAY_CLASS_NAME;
+    }
+
     public void init(CompilerOptions options) throws SchemaCompilationException {
         try {
-	    modelMap = new HashMap();
-	    ns2packageNameMap = new HashMap();	
+            modelMap = new HashMap();
+            ns2packageNameMap = new HashMap();
 
             initWithFile(options.getOutputLocation());
             packageName = options.getPackageName();
@@ -571,7 +598,7 @@
             }
 
             if (javaClassNameForElement == null) {
-                javaClassNameForElement = SchemaCompiler.DEFAULT_CLASS_NAME;
+                javaClassNameForElement = getDefaultClassName();
                 log.warn(SchemaCompilerMessages
                         .getMessage("schema.typeMissing", name.toString()));
             }
@@ -653,7 +680,8 @@
                 XSLTUtils.addAttribute(model, "rewrite", "yes", property);
                 XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
             } else if (metainf.isRestriction() && !missingQNames.contains(name) &&
-                    (minOccursChanged(name, missingQNames, metainf) || maxOccursChanged(name, missingQNames, metainf))) {
+                    (minOccursChanged(name, missingQNames, metainf) || maxOccursChanged(name, missingQNames, metainf)))
+            {
 
                 XSLTUtils.addAttribute(model, "restricted", "yes", property);
                 XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
@@ -826,11 +854,13 @@
 
                     if (!javaClassForParentElement.equals(javaClassForElement)) {
                         if (javaClassForParentElement.endsWith("[]")) {
-                            if ((javaClassForParentElement.substring(0, javaClassForParentElement.indexOf('['))).equals(javaClassForElement)) {
+                            if ((javaClassForParentElement.substring(0, javaClassForParentElement.indexOf('['))).equals(javaClassForElement))
+                            {
                                 continue;
                             }
                         } else if (javaClassForElement.endsWith("[]")) {
-                            if ((javaClassForElement.substring(0, javaClassForElement.indexOf('['))).equals(javaClassForParentElement)) {
+                            if ((javaClassForElement.substring(0, javaClassForElement.indexOf('['))).equals(javaClassForParentElement))
+                            {
                                 continue;
                             }
                         } else {
@@ -907,9 +937,9 @@
      * @param javaClassNameForElement
      */
     private boolean isDefault(String javaClassNameForElement) {
-        return SchemaCompiler.DEFAULT_CLASS_NAME
+        return getDefaultClassName()
                 .equals(javaClassNameForElement)
-                || SchemaCompiler.DEFAULT_CLASS_ARRAY_NAME
+                || getDefaultClassArrayName()
                 .equals(javaClassNameForElement);
     }
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java Wed Nov 22 23:27:02 2006
@@ -25,7 +25,6 @@
 import org.apache.axis2.description.PolicyInclude;
 import org.apache.axis2.description.AxisMessage;
 import org.apache.neethi.Policy;
-import org.apache.axiom.om.OMFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -556,76 +555,74 @@
         return paramElement;  //*/
     }
     /**
-     * @param doc
-     * @param operation
-     * @return Returns Element.
-     */
-    protected Element getOutputParamElement(Document doc, AxisOperation operation) {
-        Element paramElement = doc.createElement("param");
-        AxisMessage outputMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
-        String typeMappingStr;
-        String parameterName;
-
-        if (outputMessage != null) {
-            parameterName = this.mapper.getParameterName(outputMessage.getElementQName());
-            String typeMapping = this.mapper.getTypeMappingName(outputMessage.getElementQName());
-            typeMappingStr = (typeMapping == null)
-                    ? ""
-                    : typeMapping;
-        } else {
-            parameterName = "";
-            typeMappingStr = "";
-        }
+         * @param doc
+         * @param operation
+         * @param param
+         */
+        protected void addCSpecifcAttributes(Document doc, AxisOperation operation, Element param) {
+            String typeMappingStr;
+            Map typeMap = CTypeInfo.getTypeMap();
+            Iterator typeMapIterator = typeMap.keySet().iterator();
+
+            AxisMessage message = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+            QName typeMapping = message.getElementQName();
+
+            String paramType = this.mapper.getTypeMappingName(message.getElementQName());
+            if (doc == null || paramType == null || param == null) {
+                return;
+            }
 
-        if (JAVA_DEFAULT_TYPE.equals(typeMappingStr))
-        {
-            typeMappingStr = C_DEFAULT_TYPE;
-        }
-        addAttribute(doc, "name", parameterName, paramElement);
-        addAttribute(doc, "type", typeMappingStr, paramElement);
-        addAttribute(doc, "caps-type", typeMappingStr.toUpperCase(), paramElement);
+            if (message != null) {
+                String type = this.mapper.getTypeMappingName(message.getElementQName());
+                typeMappingStr = (type == null)
+                        ? ""
+                        : type;
+            } else {
+                 typeMappingStr = "";
+            }
 
+            addAttribute(doc, "caps-type", paramType.toUpperCase(), param);
+            boolean isOurs = true;
+            while (typeMapIterator.hasNext()) {
+                if (typeMapIterator.next().equals(typeMapping)) {
+                    isOurs = false;
+                    break;
+                }
+            }
 
-        // the following methods are moved from addOurs functioin
-        Map typeMap =  CTypeInfo.getTypeMap();
-        Iterator it= typeMap.keySet().iterator();
-        boolean isOurs = true;
-        while (it.hasNext()){
-            if (it.next().equals(typeMappingStr)){
-                isOurs = false;
-                break;
+            if (isOurs && !paramType.equals("") && !paramType.equals("void") &&
+                    !paramType.equals("org.apache.axiom.om.OMElement") &&
+                    !typeMappingStr.equals(C_DEFAULT_TYPE)) {
+                addAttribute(doc, "ours", "yes", param);
             }
         }
 
-        if ( isOurs && typeMappingStr.length() != 0 && !typeMappingStr.equals("void") &&
-                !typeMappingStr.equals(C_DEFAULT_TYPE) ){
-            addAttribute(doc, "ours", "yes", paramElement);
-        }
-        else
-        {
-            isOurs = false;
-        }
+        /**
+         * @param doc
+         * @param operation
+         * @return Returns the parameter element.
+         */
+        protected Element[] getInputParamElement(Document doc, AxisOperation operation) {
+            Element[] param = super.getInputParamElement(doc, operation);
+            for (int i = 0; i < param.length; i++) {
+                addCSpecifcAttributes(doc, operation, param[i]);
+            }
 
-        if ( isOurs)
-        {
-            typeMappingStr = C_OUR_TYPE_PREFIX + typeMappingStr + C_OUR_TYPE_SUFFIX;
+            return param;
         }
-        //adds the short type
-        addShortType(paramElement,typeMappingStr);
 
+        /**
+         * @param doc
+         * @param operation
+         * @return Returns Element.
+         */
+        protected Element getOutputParamElement(Document doc, AxisOperation operation) {
+            Element param = super.getOutputParamElement(doc, operation);
+            addCSpecifcAttributes(doc, operation, param);
 
-        // add an extra attribute to say whether the type mapping is the default
-        if (mapper.getDefaultMappingName().equals(typeMappingStr)) {
-            addAttribute(doc, "default", "yes", paramElement);
+            return param;
         }
-
-        // add this as a body parameter
-        addAttribute(doc, "location", "body", paramElement);
-        addAttribute(doc, "opname", operation.getName().getLocalPart(), paramElement);
-
-        return paramElement;
-    }
-
+    
     /**
      * Gets the output directory for source files.
      *

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java?view=diff&rev=478499&r1=478498&r2=478499
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java Wed Nov 22 23:27:02 2006
@@ -42,14 +42,14 @@
 
         // The XSD Primitives are mapped to java primitives.
         CTypeInfo.addTypemapping(XSD_BOOLEAN,"axis2_bool_t");
-        //CTypeMap.addTypemapping(XSD_DOUBLE, double.class.getName());
+        CTypeInfo.addTypemapping(XSD_DOUBLE, "double");
         CTypeInfo.addTypemapping(XSD_FLOAT, "float");
         CTypeInfo.addTypemapping(XSD_INT, "int");
         CTypeInfo.addTypemapping(XSD_INTEGER,
                 "int");
         CTypeInfo.addTypemapping(XSD_LONG, "long");
         CTypeInfo.addTypemapping(XSD_SHORT, "short");
-        CTypeInfo.addTypemapping(XSD_BYTE, "byte");
+        CTypeInfo.addTypemapping(XSD_BYTE, "axis2_byte_t");
         CTypeInfo.addTypemapping(XSD_ANY,  "axiom_node_t*");
         CTypeInfo.addTypemapping(XSD_DECIMAL, "int");
 
@@ -92,11 +92,11 @@
                 "int");
 
         // xsd:token
-        CTypeInfo.addTypemapping(XSD_TOKEN, Token.class.getName());
+        CTypeInfo.addTypemapping(XSD_TOKEN, "axiom_node_t*");
 
         // a xsd:normalizedString
         CTypeInfo.addTypemapping(XSD_NORMALIZEDSTRING,
-                "axis2_char*");
+                "axis2_char_t*");
 
         // a xsd:unsignedLong
         CTypeInfo.addTypemapping(XSD_UNSIGNEDLONG,
@@ -112,11 +112,11 @@
 
         // a xsd:unsignedByte
         CTypeInfo.addTypemapping(XSD_UNSIGNEDBYTE,
-                "unsinged char");
+                "unsigned char");
 
         // a xsd:nonNegativeInteger
         CTypeInfo.addTypemapping(XSD_NONNEGATIVEINTEGER,
-                "unsinged int");
+                "unsigned int");
 
         // a xsd:negativeInteger
         CTypeInfo.addTypemapping(XSD_NEGATIVEINTEGER,
@@ -124,53 +124,54 @@
 
         // a xsd:positiveInteger
         CTypeInfo.addTypemapping(XSD_POSITIVEINTEGER,
-                "unsinged int");
+                "unsigned int");
 
         // a xsd:nonPositiveInteger
         CTypeInfo.addTypemapping(XSD_NONPOSITIVEINTEGER,
                 "int");
 
         // a xsd:Name
-        CTypeInfo.addTypemapping(XSD_NAME, Name.class.getName());
+        CTypeInfo.addTypemapping(XSD_NAME, "axiom_node_t*");
 
         // a xsd:NCName
-        CTypeInfo.addTypemapping(XSD_NCNAME, NCName.class.getName());
+        CTypeInfo.addTypemapping(XSD_NCNAME, "axiom_node_t*");
 
         // a xsd:ID
-        CTypeInfo.addTypemapping(XSD_ID, Id.class.getName());
+        CTypeInfo.addTypemapping(XSD_ID, "axiom_node_t*");
 
         // a xml:lang
         // addTypemapping(XML_LANG,Language.class.getName());
 
         // a xsd:language
-        CTypeInfo.addTypemapping(XSD_LANGUAGE, Language.class.getName());
+        CTypeInfo.addTypemapping(XSD_LANGUAGE, "axiom_node_t*");
 
         // a xsd:NmToken
-        CTypeInfo.addTypemapping(XSD_NMTOKEN, NMToken.class.getName());
+        CTypeInfo.addTypemapping(XSD_NMTOKEN, "axiom_node_t*");
 
         // a xsd:NmTokens
-        CTypeInfo.addTypemapping(XSD_NMTOKENS, NMTokens.class.getName());
+        CTypeInfo.addTypemapping(XSD_NMTOKENS, "axiom_node_t*");
 
         // a xsd:NOTATION
-        CTypeInfo.addTypemapping(XSD_NOTATION, Notation.class.getName());
+        CTypeInfo.addTypemapping(XSD_NOTATION, "axiom_node_t*");
 
         // a xsd:XSD_ENTITY
-        CTypeInfo.addTypemapping(XSD_ENTITY, Entity.class.getName());
+        CTypeInfo.addTypemapping(XSD_ENTITY, "axiom_node_t*");
 
         // a xsd:XSD_ENTITIES
-        CTypeInfo.addTypemapping(XSD_ENTITIES, Entities.class.getName());
+        CTypeInfo.addTypemapping(XSD_ENTITIES, "axiom_node_t*");
 
         // a xsd:XSD_IDREF
-        CTypeInfo.addTypemapping(XSD_IDREF, IDRef.class.getName());
+        CTypeInfo.addTypemapping(XSD_IDREF, "axiom_node_t*");
 
         // a xsd:XSD_XSD_IDREFS
-        CTypeInfo.addTypemapping(XSD_IDREFS, IDRefs.class.getName());
+        CTypeInfo.addTypemapping(XSD_IDREFS, "axiom_node_t*");
 
         // a xsd:Duration
-        CTypeInfo.addTypemapping(XSD_DURATION, Duration.class.getName());
+        CTypeInfo.addTypemapping(XSD_DURATION, "axiom_node_t*");
 
         // a xsd:anyURI
-        CTypeInfo.addTypemapping(XSD_ANYURI, URI.class.getName());
+        CTypeInfo.addTypemapping(XSD_ANYURI,
+                "axis2_uri_t*");
 
 
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org