You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2006/06/18 21:54:57 UTC

svn commit: r415186 - in /webservices/axis2/trunk/java/modules: adb-codegen/src/org/apache/axis2/schema/ codegen/src/org/apache/axis2/wsdl/codegen/ codegen/src/org/apache/axis2/wsdl/codegen/emitter/ codegen/src/org/apache/axis2/wsdl/codegen/extension/ ...

Author: ajith
Date: Sun Jun 18 12:54:56 2006
New Revision: 415186

URL: http://svn.apache.org/viewvc?rev=415186&view=rev
Log:
1. Halfway through implementing unwrapping support
  I. The initial unwrapping extension. Still experimental and I owe an explanation in the mailing list!
  II. Added the extension to the codegen-config.properties file
2. Refactored the codegen-config.properties (with line breaks) for easy reading.(and added the above extension)
3. Modified the databinding extensions to pick the existing type mapper before creating a new one. This allows one to have a pre populated type map
4. Removed the static default class name (OMElement) and made it a field. This allows the data binding frameworks to override the default as appropriate. However the override was only added to XMLbeans extension.
5. Set the log levels of the pretty printers to debug. It is painful to see the class not found exception in info level!
6. Added a sanity check to the TypeMapperExtension.java to test the compatibility of databinding frameworks 
 

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java
    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/SchemaUnwrapperExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/TypeMapperExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMapper.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMappingAdapter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
    webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/PrettyPrinter.java
    webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/XMLPrettyPrinter.java
    webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.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?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- 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 Sun Jun 18 12:54:56 2006
@@ -3,6 +3,7 @@
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
 import org.apache.axis2.wsdl.util.XSLTConstants;
 
 import javax.xml.namespace.QName;
@@ -57,8 +58,12 @@
         schemaCompiler.compile(schemaList);
 
         //create the type mapper
-        JavaTypeMapper mapper = new JavaTypeMapper();
-
+        //First try to take the one that is already there
+        TypeMapper mapper = configuration.getTypeMapper();
+        if (mapper==null){
+            mapper =new JavaTypeMapper();
+        }
+        
         if (options.isWriteOutput()){
             //get the processed element map and transfer it to the type mapper
             Map processedMap = schemaCompiler.getProcessedElementMap();

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Sun Jun 18 12:54:56 2006
@@ -48,12 +48,15 @@
 import java.util.Map;
 
 public class CodeGenerationEngine {
+
     private static final Log log = LogFactory.getLog(CodeGenerationEngine.class);
 
+    /** Array List for pre-extensions. Extensions that run before the emitter */
     private List preExtensions = new ArrayList();
+    /** Array List for post-extensions. Extensions that run after the codegens*/
     private List postExtensions = new ArrayList();
 
-
+    /** Codegen configuration  reference */
     private CodeGenConfiguration configuration;
 
     /**
@@ -94,7 +97,11 @@
                 if (configuration.getServiceName()!=null){
                     serviceQname = new QName(description.getTargetNamespace().toString(), configuration.getServiceName());
                 }
-                configuration.setAxisService(new WSDL20ToAxisServiceBuilder(description, serviceQname, configuration.getPortName()).populateService());
+                configuration.setAxisService(
+                        new WSDL20ToAxisServiceBuilder(description,
+                                serviceQname,
+                                configuration.getPortName()).
+                                populateService());
 
             }else{
                 //It'll be WSDL 1.1
@@ -135,7 +142,7 @@
         if (extensions!=null){
             for (int i = 0; i < extensions.length; i++) {
                 //load the Extension class
-                addPreExtension((CodeGenExtension) getObjectFromClassName(extensions[i]));
+                addPreExtension((CodeGenExtension) getObjectFromClassName(extensions[i].trim()));
             }
         }
         
@@ -144,7 +151,7 @@
         if (postExtensions!=null){
             for (int i = 0; i < postExtensions.length; i++) {
                 //load the Extension class
-                addPostExtension((CodeGenExtension) getObjectFromClassName(postExtensions[i]));
+                addPostExtension((CodeGenExtension) getObjectFromClassName(postExtensions[i].trim()));
             }
         }
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Sun Jun 18 12:54:56 2006
@@ -6,10 +6,19 @@
 # these are loaded in their lexical order
 # Note the last extension - It includes a check to figure out whether proper databinding has taken place
 # This extension should appear AFTER all the databinding extensions inorder to function properly
-codegen.extension=org.apache.axis2.wsdl.codegen.extension.JaxMeExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.JiBXExtension,org.apache.axis2.wsdl.codegen.extension.JAXBRIExtension,org.apache.axis2.wsdl.codegen.extension.TypeMapperExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension,org.apache.axis2.wsdl.codegen.extension.PolicyEvaluator
+codegen.extension=org.apache.axis2.wsdl.codegen.extension.SchemaUnwrapperExtension,org.apache.axis2.wsdl.codegen.extension.JaxMeExtension, \
+  org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension, \
+  org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension, \
+  org.apache.axis2.wsdl.codegen.extension.JiBXExtension, \
+  org.apache.axis2.wsdl.codegen.extension.JAXBRIExtension, \
+  org.apache.axis2.wsdl.codegen.extension.TypeMapperExtension, \
+  org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension, \
+  org.apache.axis2.wsdl.codegen.extension.PolicyEvaluator
 #extensions that work after the main emitter. These will include functionality such as
 #formatters
-post.codegen.extension=org.apache.axis2.wsdl.codegen.extension.JavaPrettyPrinterExtension,org.apache.axis2.wsdl.codegen.extension.XMLPrettyPrinterExtension,org.apache.axis2.wsdl.codegen.extension.WSDLPrettyPrinterExtension
+post.codegen.extension=org.apache.axis2.wsdl.codegen.extension.JavaPrettyPrinterExtension, \
+  org.apache.axis2.wsdl.codegen.extension.XMLPrettyPrinterExtension, \
+  org.apache.axis2.wsdl.codegen.extension.WSDLPrettyPrinterExtension
 #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.SimpleDBExtension
 # The third party schemas to be loaded. e.g. The Xmime extension
 # Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package.

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Sun Jun 18 12:54:56 2006
@@ -528,7 +528,7 @@
 
             // add an extra attribute to say whether the type mapping is
             // the default
-            if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMapping)) {
+            if (mapper.getDefaultMappingName().equals(typeMapping)) {
                 addAttribute(doc, "default", "yes", faultElement);
             }
             addAttribute(doc, "value", getParamInitializer(typeMapping),
@@ -1633,7 +1633,7 @@
 
                 // add an extra attribute to say whether the type mapping is
                 // the default
-                if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMapping)) {
+                if (mapper.getDefaultMappingName().equals(typeMapping)) {
                     addAttribute(doc, "default", "yes", paramElement);
                 }
                 addAttribute(doc, "value", getParamInitializer(typeMapping),
@@ -1676,7 +1676,7 @@
                     : typeMapping, param);
 
             // add an extra attribute to say whether the type mapping is the default
-            if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMapping)) {
+            if (mapper.getDefaultMappingName().equals(typeMapping)) {
                 addAttribute(doc, "default", "yes", param);
             }
 
@@ -1725,7 +1725,7 @@
         addAttribute(doc, "type", typeMappingStr, param);
 
         // add an extra attribute to say whether the type mapping is the default
-        if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMappingStr)) {
+        if (mapper.getDefaultMappingName().equals(typeMappingStr)) {
             addAttribute(doc, "default", "yes", param);
         }
 

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?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- 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 Sun Jun 18 12:54:56 2006
@@ -12,63 +12,7 @@
  * Most code from Axis 1 Codebase*
  * Most code JavaTypeMap
  */
-public class CTypeInfo {
-
-    public static final String URI_DEFAULT_SCHEMA_XSD = Constants.URI_2001_SCHEMA_XSD;
-    public static final QName XSD_STRING = new QName(URI_DEFAULT_SCHEMA_XSD, "string");
-    public static final QName XSD_BOOLEAN = new QName(URI_DEFAULT_SCHEMA_XSD, "boolean");
-    public static final QName XSD_DOUBLE = new QName(URI_DEFAULT_SCHEMA_XSD, "double");
-    public static final QName XSD_FLOAT = new QName(URI_DEFAULT_SCHEMA_XSD, "float");
-    public static final QName XSD_INT = new QName(URI_DEFAULT_SCHEMA_XSD, "int");
-    public static final QName XSD_INTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "integer");
-    public static final QName XSD_LONG = new QName(URI_DEFAULT_SCHEMA_XSD, "long");
-    public static final QName XSD_SHORT = new QName(URI_DEFAULT_SCHEMA_XSD, "short");
-    public static final QName XSD_BYTE = new QName(URI_DEFAULT_SCHEMA_XSD, "byte");
-    public static final QName XSD_DECIMAL = new QName(URI_DEFAULT_SCHEMA_XSD, "decimal");
-    public static final QName XSD_BASE64 = new QName(URI_DEFAULT_SCHEMA_XSD, "base64Binary");
-    public static final QName XSD_HEXBIN = new QName(URI_DEFAULT_SCHEMA_XSD, "hexBinary");
-    public static final QName XSD_ANYSIMPLETYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anySimpleType");
-    public static final QName XSD_ANYTYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anyType");
-    public static final QName XSD_ANY = new QName(URI_DEFAULT_SCHEMA_XSD, "any");
-    public static final QName XSD_QNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "QName");
-    public static final QName XSD_DATETIME = new QName(URI_DEFAULT_SCHEMA_XSD, "dateTime");
-    public static final QName XSD_DATE = new QName(URI_DEFAULT_SCHEMA_XSD, "date");
-    public static final QName XSD_TIME = new QName(URI_DEFAULT_SCHEMA_XSD, "time");
-
-
-    public static final QName XSD_UNSIGNEDLONG = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedLong");
-    public static final QName XSD_UNSIGNEDINT = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedInt");
-    public static final QName XSD_UNSIGNEDSHORT = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedShort");
-    public static final QName XSD_UNSIGNEDBYTE = new QName(URI_DEFAULT_SCHEMA_XSD, "unsignedByte");
-    public static final QName XSD_POSITIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "positiveInteger");
-    public static final QName XSD_NEGATIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "negativeInteger");
-    public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "nonNegativeInteger");
-    public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "nonPositiveInteger");
-
-    public static final QName XSD_YEARMONTH = new QName(URI_DEFAULT_SCHEMA_XSD, "gYearMonth");
-    public static final QName XSD_MONTHDAY = new QName(URI_DEFAULT_SCHEMA_XSD, "gMonthDay");
-    public static final QName XSD_YEAR = new QName(URI_DEFAULT_SCHEMA_XSD, "gYear");
-    public static final QName XSD_MONTH = new QName(URI_DEFAULT_SCHEMA_XSD, "gMonth");
-    public static final QName XSD_DAY = new QName(URI_DEFAULT_SCHEMA_XSD, "gDay");
-    public static final QName XSD_DURATION = new QName(URI_DEFAULT_SCHEMA_XSD, "duration");
-
-    public static final QName XSD_NAME = new QName(URI_DEFAULT_SCHEMA_XSD, "Name");
-    public static final QName XSD_NCNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "NCName");
-    public static final QName XSD_NMTOKEN = new QName(URI_DEFAULT_SCHEMA_XSD, "NMTOKEN");
-    public static final QName XSD_NMTOKENS = new QName(URI_DEFAULT_SCHEMA_XSD, "NMTOKENS");
-    public static final QName XSD_NOTATION = new QName(URI_DEFAULT_SCHEMA_XSD, "NOTATION");
-    public static final QName XSD_ENTITY = new QName(URI_DEFAULT_SCHEMA_XSD, "ENTITY");
-    public static final QName XSD_ENTITIES = new QName(URI_DEFAULT_SCHEMA_XSD, "ENTITIES");
-    public static final QName XSD_IDREF = new QName(URI_DEFAULT_SCHEMA_XSD, "IDREF");
-    public static final QName XSD_IDREFS = new QName(URI_DEFAULT_SCHEMA_XSD, "IDREFS");
-    public static final QName XSD_ANYURI = new QName(URI_DEFAULT_SCHEMA_XSD, "anyURI");
-    public static final QName XSD_LANGUAGE = new QName(URI_DEFAULT_SCHEMA_XSD, "language");
-    public static final QName XSD_ID = new QName(URI_DEFAULT_SCHEMA_XSD, "ID");
-    public static final QName XSD_SCHEMA = new QName(URI_DEFAULT_SCHEMA_XSD, "schema");
-
-    public static final QName XSD_NORMALIZEDSTRING = new QName(URI_DEFAULT_SCHEMA_XSD, "normalizedString");
-    public static final QName XSD_TOKEN = new QName(URI_DEFAULT_SCHEMA_XSD, "token");
-
+public class CTypeInfo extends Constants{
 
     public static Map getTypeMap() {
         return CTypeInfo.typeMap;

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JaxMeExtension.java Sun Jun 18 12:54:56 2006
@@ -19,6 +19,7 @@
 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.i18n.CodegenMessages;
 import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
 import org.apache.ws.commons.schema.XmlSchema;
@@ -82,8 +83,12 @@
 
 
             Vector xmlObjectsVector = new Vector();
-            //create the type mapper
-            JavaTypeMapper mapper = new JavaTypeMapper();
+             //create the type mapper
+        //First try to take the one that is already there
+        TypeMapper mapper = configuration.getTypeMapper();
+        if (mapper==null){
+            mapper =new JavaTypeMapper();
+        }
 
             for (int i = 0; i < typesList.size(); i++) {
                 XmlSchema schema = (XmlSchema) typesList.get(i);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/JiBXExtension.java?rev=415186&r1=415185&r2=415186&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 Sun Jun 18 12:54:56 2006
@@ -21,6 +21,7 @@
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
 
 import javax.xml.namespace.QName;
 import java.lang.reflect.Method;
@@ -58,7 +59,7 @@
             } catch (ClassNotFoundException e) {
                 throw new RuntimeException("JiBX framework jars not in classpath");
             }
-            
+
             // load the actual utility class
             Class clazz;
             try {
@@ -66,7 +67,7 @@
             } 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 });
@@ -84,8 +85,13 @@
             }
 
 
-            // build type mapping from JiBX mappings for elements
-            JavaTypeMapper mapper = new JavaTypeMapper();
+            //create the type mapper
+            //First try to take the one that is already there
+            TypeMapper mapper = configuration.getTypeMapper();
+            if (mapper==null){
+                mapper =new JavaTypeMapper();
+            }
+
             for (Iterator iter = elements.iterator(); iter.hasNext();) {
                 QName qname = (QName)iter.next();
                 if (qname != null) {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java Sun Jun 18 12:54:56 2006
@@ -2,14 +2,21 @@
 
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisOperation;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+import org.apache.axis2.description.AxisMessage;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
 
+import javax.xml.namespace.QName;
 import java.util.Iterator;
-import java.util.ArrayList;
 import java.util.List;
+import java.util.LinkedList;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -27,44 +34,85 @@
  */
 
 /**
- * This extension invlokes the schema unwrapper depending on the users setting.
+ * This extension invokes the schema unwrapper depending on the users setting.
  * it is desirable to put this extension before other extensions since extnsions
  * such as the databinding extension may well depend on the schema being unwrapped
  * previously
  */
 public class SchemaUnwrapperExtension extends AbstractCodeGenerationExtension {
 
+    /**
+     *
+     * @param configuration
+     * @throws CodeGenerationException
+     */
     public void engage(CodeGenConfiguration configuration) throws CodeGenerationException {
         if (!configuration.isParametersWrapped()){
             //walk the schema and find the top level elements
             AxisService axisService = configuration.getAxisService();
-            List schemaList = axisService.getSchema();
-            for (int i = 0; i < schemaList.size(); i++) {
-                walkSchema((XmlSchema)schemaList.get(i));
-            }
-
-
-
-
-
-
 
+            for(Iterator operations = axisService.getOperations();
+                operations.hasNext();){
+                AxisOperation op = (AxisOperation)operations.next();
 
+                //todo check whether we need to unwrap this message depending on
+                //the binding state.
 
+               // walkSchema(op.getMessage(
+               //         WSDLConstants.MESSAGE_LABEL_IN_VALUE),configuration);
+            }
         }
     }
 
-    //walk the given schema
-    public void walkSchema(XmlSchema schema){
-        //get the schema and find the elements
-        XmlSchemaObjectTable elementTable = schema.getElements();
-        for (Iterator it = elementTable.getValues();
-             it.hasNext();){
-            //take the type of the schema element
-
+    /**
+     * walk the given schema element
+     */
+
+    public void walkSchema(AxisMessage message,CodeGenConfiguration config){
+
+        XmlSchemaType schemaType = message.getSchemaElement().getSchemaType();
+        //create a type mapper
+        if (schemaType instanceof XmlSchemaComplexType){
+            XmlSchemaComplexType cmplxType = (XmlSchemaComplexType)schemaType;
+            XmlSchemaParticle particle = cmplxType.getParticle();
+            if (particle instanceof XmlSchemaSequence){
+                // get the name of the operation name and namespace,
+                // part name and hang them somewhere ? The ideal place
+                // would be the property bag in the codegen config!
+                QName opName = ((AxisOperation)message.getParent()).getName();
+                List partNameList = new LinkedList();
+
+                XmlSchemaSequence sequence = (XmlSchemaSequence)particle;
+                XmlSchemaObjectCollection items = sequence.getItems();
+                for (Iterator i = items.getIterator();i.hasNext();){
+                    Object item = i.next();
+                    // get each and every element in the sequence and
+                    // traverse through them
+                    if (item instanceof XmlSchemaElement){
+                        //add the element name to the part name list
+                        partNameList.add(((XmlSchemaElement)item).getName());
+                    }else{
+                        // if the particle contains anything other than
+                        // a XMLSchemaElement then we are not in a position
+                        // to unwrap it
+                        //todo throw an Exception ??
+                    }
+                }
+
+                //attach the opName and the parts name list into the
+                //codegen configuration
+                // config.getConfigurationProperties()
+
+
+            }else{
+                //we do not know how to deal with other particles
+                //such as xs:all or xs:choice
+                //todo throw an Exception ??
+            }
+        }else{
+            //we've no idea how to unwrap a non complex type!!!!!!
+            //todo throw an Exception ??
         }
-
-
 
     }
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/TypeMapperExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/TypeMapperExtension.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/TypeMapperExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/TypeMapperExtension.java Sun Jun 18 12:54:56 2006
@@ -4,6 +4,7 @@
 import org.apache.axis2.wsdl.codegen.CodeGenerationException;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.i18n.CodegenMessages;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -80,10 +81,20 @@
             //if present. If a user wants to mix types then it must be
             //from the same databinding framework!
 
+            //first do a sanity check to see whether the user is trying to
+            //mix databinding types!
+
+            String databindingName = rootMappingsElement.
+                    getAttribute(DB_FRAMEWORK_ATTRIBUTE_NAME);
+            if (!databindingName.equals(configuration.getDatabindingType())){
+                throw new CodeGenerationException(
+                        CodegenMessages.
+                                getMessage("extension.databindingMismatch")
+                );
+            }
             configuration.
                     setDatabindingType(
-                            rootMappingsElement.
-                                    getAttribute(DB_FRAMEWORK_ATTRIBUTE_NAME));
+                            databindingName);
 
 
             NodeList mappingList = rootMappingsElement.

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMapper.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMapper.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMapper.java Sun Jun 18 12:54:56 2006
@@ -23,10 +23,7 @@
 
 public interface TypeMapper {
 
-    /**
-     * Default class name is the OMElement ?
-     */
-    public static final String DEFAULT_CLASS_NAME = OMElement.class.getName();
+   
 
     /**
      * Returns whether the mapping is the object type or the normal class name type
@@ -90,4 +87,18 @@
      * i.e. Qname to model objects
      */
     public Map getAllMappedObjects();
+
+    /**
+     *
+     * @return the default mapping name for this type mapper
+     */
+    public String getDefaultMappingName();
+
+    /**
+     * Sets the default type mapping - the databinders may
+     * change the default mapping to suit their default
+     * mapping
+     * @param defaultMapping
+     */
+    public void setDefaultMappingName(String defaultMapping);
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMappingAdapter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMappingAdapter.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMappingAdapter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/TypeMappingAdapter.java Sun Jun 18 12:54:56 2006
@@ -17,6 +17,7 @@
 package org.apache.axis2.wsdl.databinding;
 
 import org.apache.axis2.namespace.Constants;
+import org.apache.axiom.om.OMElement;
 
 import javax.xml.namespace.QName;
 import java.util.HashMap;
@@ -24,6 +25,13 @@
 
 public abstract class TypeMappingAdapter implements TypeMapper {
 
+    /**
+     * Default class name is the OMElement or the default case
+     * However the extensions can override the default class
+     * to suit the databinding framework!
+     */
+    protected String defaultClassName = OMElement.class.getName();
+
     //todo get this from a constant
     protected static final String XSD_SCHEMA_URL = Constants.URI_2001_SCHEMA_XSD;
 
@@ -44,7 +52,8 @@
 
 
     /**
-     * Gets the type mapping name. If type mapping is not found, returns default. 
+     * Gets the type mapping name.
+     * If type mapping is not found, returns default.
      *
      * @see TypeMapper#getTypeMappingName(javax.xml.namespace.QName)
      */
@@ -55,7 +64,7 @@
             if (o != null) {
                 return (String) o;
             } else {
-                return DEFAULT_CLASS_NAME;
+                return defaultClassName;
             }
         }
 
@@ -118,5 +127,20 @@
      */
     public Map getAllMappedObjects() {
         return qName2ObjectMap;
+    }
+
+    /**
+     * @see org.apache.axis2.wsdl.databinding.TypeMapper#getDefaultMappingName()
+     */
+    public String getDefaultMappingName() {
+        return defaultClassName;
+    }
+
+    /**
+     * @see TypeMapper#setDefaultMappingName(String) 
+     * @param defaultMapping
+     */
+    public void setDefaultMappingName(String defaultMapping) {
+        this.defaultClassName = defaultMapping;
     }
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties Sun Jun 18 12:54:56 2006
@@ -66,6 +66,7 @@
 extension.invalidWSDL=Invalid WSDL: The WSDL Types Schema does not define a targetNamespace in {0}
 extension.additionalSchemaFailure=Additional schema loading failed!!
 extension.encodedNotSupported=The use 'encoded' is not supported!
+extension.databindingMismatch=The specified databinding frameworks do not match!
 
 emitter.unknownStyle=Unknown code generation style {0}
 emitter.cannotFindBinding=Cannot find a binding!!

Modified: webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/PrettyPrinter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/PrettyPrinter.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/PrettyPrinter.java (original)
+++ webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/PrettyPrinter.java Sun Jun 18 12:54:56 2006
@@ -69,7 +69,7 @@
             format.invoke(prettifier, new Object[]{});
             log.debug("Pretty printed file : " + file);
         } catch (ClassNotFoundException e) {
-            log.info("Jalopy/Log4j not found - unable to pretty print " + file);
+            log.debug("Jalopy/Log4j not found - unable to pretty print " + file);
         } catch (Exception e) {
             log.warn("Exception occurred while trying to pretty print file " + file, e);
         } catch (Throwable t) {

Modified: webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/XMLPrettyPrinter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/XMLPrettyPrinter.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/XMLPrettyPrinter.java (original)
+++ webservices/axis2/trunk/java/modules/common/src/org/apache/axis2/util/XMLPrettyPrinter.java Sun Jun 18 12:54:56 2006
@@ -93,7 +93,7 @@
             }
             log.debug("Pretty printed file : " + file);
         } catch (ClassNotFoundException e) {
-            log.info("Tidy not found - unable to pretty print " + file);
+            log.debug("Tidy not found - unable to pretty print " + file);
         } catch (Exception e) {
             log.warn("Exception occurred while trying to pretty print file " + file, e);
         } catch (Throwable t) {

Modified: webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java?rev=415186&r1=415185&r2=415186&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java (original)
+++ webservices/axis2/trunk/java/modules/xmlbeans/src/org/apache/axis2/xmlbeans/CodeGenerationUtility.java Sun Jun 18 12:54:56 2006
@@ -106,7 +106,16 @@
             List topLevelSchemaList = new ArrayList();
 
             //create the type mapper
-            JavaTypeMapper mapper = new JavaTypeMapper();
+            //First try to take the one that is already there
+            TypeMapper mapper = cgconfig.getTypeMapper();
+            if (mapper==null){
+                mapper =new JavaTypeMapper();
+            }
+
+            //change the  default class name of the mapper to
+            //xmlbeans specific XMLObject
+            mapper.setDefaultMappingName(XmlObject.class.getName());
+
             Map nameSpacesMap = cgconfig.getAxisService().getNameSpacesMap();
 
             // process all the schemas and make a list of all of them for
@@ -309,8 +318,8 @@
                 throws IOException {
             File resourcesDirectory =
                     flatten?
-                    location:
-                    new File(location, RESOURCE_DIR_NAME);
+                            location:
+                            new File(location, RESOURCE_DIR_NAME);
 
             if (!resourcesDirectory.exists()) {
                 resourcesDirectory.mkdirs();
@@ -328,8 +337,8 @@
 
             File outputDir =
                     flatten?
-                    location:
-                    new File(location, SOURCE_DIR_NAME);
+                            location:
+                            new File(location, SOURCE_DIR_NAME);
 
             if (!outputDir.exists()) {
                 outputDir.mkdirs();
@@ -453,7 +462,7 @@
         public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
             //System.out.println("Lookup:" + "[ " + publicId + "]" + "[" + systemId + "]");
             try {
-               for (int i = 0; i < schemas.length; i++){
+                for (int i = 0; i < schemas.length; i++){
                     SchemaDocument.Schema schema = schemas[i].getSchema();
                     if (schema.getTargetNamespace() != null &&
                             publicId != null &&



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