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 2006/02/26 06:08:59 UTC

svn commit: r381055 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: schema/SchemaConstants.java schema/template/ADBBeanTemplate.xsl wsdl/codegen/extension/SimpleDBExtension.java

Author: ajith
Date: Sat Feb 25 21:08:54 2006
New Revision: 381055

URL: http://svn.apache.org/viewcvs?rev=381055&view=rev
Log:
1. added a new parameter to the simpleDBExtension to pass in a custom package name
2. Fixed two minor omissions in the ADB code generaton

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java?rev=381055&r1=381054&r2=381055&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java Sat Feb 25 21:08:54 2006
@@ -101,6 +101,7 @@
         public static final String WRAP_SCHEMA_CLASSES = "w";
         public static final String WRITE_SCHEMA_CLASSES = "r";
         public static final String STYLE = "s";
+        public static final String PACKAGE = "p";
 
     }
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=381055&r1=381054&r2=381055&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Sat Feb 25 21:08:54 2006
@@ -207,7 +207,6 @@
                     <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
                     <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
                      <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
-                    <xsl:if test="position()>1">,</xsl:if>
                     <xsl:choose>
                         <xsl:when test="@anyAtt">
                             attribList.add(null);
@@ -289,7 +288,7 @@
             <xsl:variable name="attribName">tempAttrib<xsl:value-of select="$propertyName"/></xsl:variable>
 
             String <xsl:value-of select="$attribName"/> =
-              reader.getAttributeValue("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>")
+              reader.getAttributeValue("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>");
            if (<xsl:value-of select="$attribName"/>!=null){
                  object.set<xsl:value-of select="$javaName"/>(
                    org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=381055&r1=381054&r2=381055&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Sat Feb 25 21:08:54 2006
@@ -26,6 +26,9 @@
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.wsdl.WSDLExtensibilityElement;
 import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.WSDLInterface;
+import org.apache.wsdl.WSDLOperation;
+import org.apache.wsdl.MessageReference;
 import org.apache.wsdl.extensions.ExtensionConstants;
 import org.apache.wsdl.extensions.Schema;
 import org.w3c.dom.Element;
@@ -37,6 +40,8 @@
 import java.util.Map;
 import java.util.Stack;
 import java.util.Vector;
+import java.util.HashMap;
+import java.util.ArrayList;
 
 /**
  * Extension for simple data binding.
@@ -68,7 +73,7 @@
             XmlSchemaCollection schemaColl = new XmlSchemaCollection();
             //add the base uri
             if (configuration.getBaseURI()!=null){
-                 schemaColl.setBaseUri(configuration.getBaseURI());
+                schemaColl.setBaseUri(configuration.getBaseURI());
             }
 
 
@@ -103,16 +108,16 @@
             CompilerOptions options = new CompilerOptions();
 
             //set the default options
-            setDefaultOptions(options);
+            populateDefaultOptions(options);
 
             //set the user parameters. the user parameters get the preference over
             //the default ones. But the user better know what he's doing if he
             //used module specific parameters
-            setUserparameters(options);
+            populateUserparameters(options);
 
             SchemaCompiler schemaCompiler = new SchemaCompiler(options);
-            schemaCompiler
-                    .compile(xmlSchemaTypeVector);
+            // run the schema compiler
+            schemaCompiler.compile(xmlSchemaTypeVector);
 
             //create the type mapper
             JavaTypeMapper mapper = new JavaTypeMapper();
@@ -164,30 +169,71 @@
 
     }
 
+//    /**
+//     *  populates the unwrapped Qnames from the messagereference
+//     */
+//
+//    private void populateUnwrappedElements(List unwrappedElementQNames) {
+//        Map wsdlInterfaces = configuration.getWom().getWsdlInterfaces();
+//        Iterator interaceIterator = wsdlInterfaces.values().iterator();
+//        WSDLInterface wsdlInterface;
+//        while (interaceIterator.hasNext()) {
+//            wsdlInterface =  (WSDLInterface)interaceIterator.next();
+//            HashMap allOperations = wsdlInterface.getAllOperations();
+//            Iterator operationsIterator = allOperations.values().iterator();
+//            while (operationsIterator.hasNext()) {
+//                WSDLOperation operation =  (WSDLOperation)operationsIterator.next();
+//                MessageReference inputMessage = operation.getInputMessage();
+//                if (inputMessage!= null){
+//                    Map metadataBag = inputMessage.getMetadataBag();
+//                    Iterator qNameIterator = metadataBag.keySet().iterator();
+//                    while (qNameIterator.hasNext()) {
+//                        unwrappedElementQNames.add(qNameIterator.next());
+//                    }
+//                }
+//
+//                //at this point we should add the output messages as well
+//                MessageReference outputMessage = operation.getOutputMessage();
+//                if (outputMessage!=null){
+//                    unwrappedElementQNames.add(outputMessage.getElementQName());
+//                }
+//            }
+//        }
+//    }
+
     /**
      *
      * @param options
      */
-    private void setUserparameters(CompilerOptions options){
+    private void populateUserparameters(CompilerOptions options){
         Map propertyMap = configuration.getProperties();
         if (propertyMap.containsKey(SchemaConstants.SchemaCompilerArguments.WRAP_SCHEMA_CLASSES)){
             if (Boolean.valueOf(
                     propertyMap.get(SchemaConstants.SchemaCompilerArguments.WRAP_SCHEMA_CLASSES).toString()).
                     booleanValue()) {
-             options.setWrapClasses(true);
+                options.setWrapClasses(true);
             }else{
-              options.setWrapClasses(false);
+                options.setWrapClasses(false);
             }
         }
 
         if (propertyMap.containsKey(SchemaConstants.SchemaCompilerArguments.WRITE_SCHEMA_CLASSES)){
-          if (Boolean.valueOf(
+            if (Boolean.valueOf(
                     propertyMap.get(SchemaConstants.SchemaCompilerArguments.WRITE_SCHEMA_CLASSES).toString()).
                     booleanValue()) {
-             options.setWriteOutput(true);
+                options.setWriteOutput(true);
             }else{
-              options.setWriteOutput(false);
+                options.setWriteOutput(false);
+            }
+        }
+
+        // add the custom package name
+        if (propertyMap.containsKey(SchemaConstants.SchemaCompilerArguments.PACKAGE)){
+            String packageName = (String)propertyMap.get(SchemaConstants.SchemaCompilerArguments.PACKAGE);
+            if (packageName!=null || !"".equals(packageName)){
+               options.setPackageName(packageName);
             }
+
         }
     }
 
@@ -196,7 +242,8 @@
      *
      * @param options
      */
-    private void setDefaultOptions(CompilerOptions options) {
+    private void populateDefaultOptions(CompilerOptions options) {
+        //create the output directory
         File outputDir = new File(configuration.getOutputLocation(), "src");
         if(!outputDir.exists()) {
             outputDir.mkdirs();