ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r365284 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/template/java/ tool/src/org/apache/axis2/tool/ant/
Date Mon, 02 Jan 2006 04:16:37 GMT
Author: ajith
Date: Sun Jan  1 20:16:23 2006
New Revision: 365284

URL: http://svn.apache.org/viewcvs?rev=365284&view=rev
Log:
1. Updated the DatabindingTemplate.xsl to have the toEnvelope methods for all the databinding
frameworks.
2. Updated the TestClassTemplate.xsl and the TestObjectCreationTemplate.xsl to build the necessary
test objects for all frameworks.
3. Updated the AntCodegenTask.java to suit the changes in the code generator

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
    webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl?rev=365284&r1=365283&r2=365284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
Sun Jan  1 20:16:23 2006
@@ -21,15 +21,14 @@
                 (org.apache.axis2.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader()))
;
 
                 org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
-                <xsl:choose>
-                    <xsl:when test="$base64">
+                <xsl:if test="$base64">
                          optimizeContent(documentElement,qNameArray);
-                    </xsl:when>
-                </xsl:choose>
+                </xsl:if>
+
                   ((org.apache.axis2.om.impl.OMNodeEx)documentElement).setParent(null);
                   return documentElement;
                 }
-                
+
                 public org.apache.axis2.soap.SOAPEnvelope toEnvelope(org.apache.axis2.soap.SOAPFactory
factory, <xsl:value-of select="@type"/> param){
                     org.apache.axis2.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
                     envelope.getBody().addChild(toOM(param));
@@ -55,7 +54,9 @@
         return null;
         }
 
-     private void optimizeContent(org.apache.axis2.om.OMElement element, javax.xml.namespace.QName[]
qNames){
+    <!-- Generate the base 64 optimize methods only if the base64 items are present -->
   
+   <xsl:if test="$base64">
+   private void optimizeContent(org.apache.axis2.om.OMElement element, javax.xml.namespace.QName[]
qNames){
         for (int i = 0; i &lt; qNames.length; i++) {
             markElementsAsOptimized(qNames[i],element);
         }
@@ -75,7 +76,7 @@
             markElementsAsOptimized(qName,(org.apache.axis2.om.OMElement)childElements.next());
         }
     }
-
+    </xsl:if>
     </xsl:template>
     <!-- #################################################################################
 -->
        <!-- ############################   ADB template   ##############################
 -->
@@ -105,10 +106,10 @@
                             return null;
                         }
                     }
-                    
+
                     public  org.apache.axis2.soap.SOAPEnvelope toEnvelope(org.apache.axis2.soap.SOAPFactory
factory, <xsl:value-of select="@type"/> param){
                         if (param instanceof org.apache.axis2.databinding.ADBBean){
-                            org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new

+                            org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
                                     org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(param.MY_QNAME),
                                                                                      factory);
                             return builder.getEnvelope();
@@ -150,9 +151,11 @@
            public  org.apache.axis2.om.OMElement  toOM(org.apache.axis2.om.OMElement param){
                return param;
            }
-           
+
            public org.apache.axis2.soap.SOAPEnvelope toEnvelope(org.apache.axis2.soap.SOAPFactory
factory, org.apache.axis2.om.OMElement param){
-               return param;
+                org.apache.axis2.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
+                envelope.getBody().addChild(param));
+                return envelope;
            }
        </xsl:template>
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=365284&r1=365283&r2=365284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
Sun Jan  1 20:16:23 2006
@@ -146,7 +146,6 @@
                                     new Object[]{<xsl:for-each select="input/param[@type!='']"><xsl:if
test="position()>1">,</xsl:if><xsl:value-of select="@name"/></xsl:for-each>});
                                 </xsl:when>
                                 <xsl:when test="$style='doc'">
-
                                     //Style is Doc.
                                     <xsl:for-each select="input/param[@location='body']">
                                         env = toEnvelope(getFactory(this._clientOptions.getSoapVersionURI()),
<xsl:value-of select="@name"/>);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl?rev=365284&r1=365283&r2=365284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
Sun Jan  1 20:16:23 2006
@@ -44,6 +44,7 @@
                 <xsl:for-each select="input/param[@type!='']">
                     <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of
select="@name"/><xsl:text>=
                                                         </xsl:text>(<xsl:value-of
select="@type"/>)getTestObject(<xsl:value-of select="@type"/>.class);
+                    // todo Fill in the <xsl:value-of select="@name"/> here
                 </xsl:for-each>
                  
                 <xsl:choose>
@@ -89,13 +90,17 @@
          */
         public  void testStart<xsl:value-of select="@name"/>() throws java.lang.Exception{
             <xsl:value-of select="$package"/>.<xsl:value-of select="$stubname"/>
stub = new <xsl:value-of select="$package"/>.<xsl:value-of select="$stubname"/>();
-             //create a new databinder
              <xsl:choose>
              <xsl:when test="count(input/param)>0">
+                  <xsl:for-each select="input/param[@type!='']">
+                    <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of
select="@name"/><xsl:text>=
+                                                        </xsl:text>(<xsl:value-of
select="@type"/>)getTestObject(<xsl:value-of select="@type"/>.class);
+                    // todo Fill in the <xsl:value-of select="@name"/> here
+                </xsl:for-each>
+
                 stub.start<xsl:value-of select="@name"/>(
                          <xsl:for-each select="input/param">
-                             <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if>(<xsl:value-of
select="@type"/>)getTestObject(<xsl:value-of select="@type"/>.class)
-                        </xsl:if>
+                             <xsl:if test="position()>1">,</xsl:if><xsl:value-of
select="@name"/>
                         </xsl:for-each>,
                     new <xsl:value-of select="$tempCallbackName"/>()
                 );

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl?rev=365284&r1=365283&r2=365284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
Sun Jan  1 20:16:23 2006
@@ -4,11 +4,26 @@
     <!-- #################################################################################
 -->
     <!-- ############################   xmlbeans template   ##############################
 -->
     <xsl:template match="databinders[@dbtype='xmlbeans']">
-        //Create an ADBBean and provide it as the test object
-        //todo Fill this properly
+        //Create the desired XmlObject and provide it as the test object
         public  org.apache.xmlbeans.XmlObject getTestObject(java.lang.Class type) throws
Exception{
-           <!--Need to fix this-->
-           return null;
+        java.lang.reflect.Method creatorMethod = null;
+                if (org.apache.xmlbeans.XmlObject.class.isAssignableFrom(type)){
+                    Class[] declaredClasses = type.getDeclaredClasses();
+                    for (int i = 0; i &lt; declaredClasses.length; i++) {
+                        Class declaredClass = declaredClasses[i];
+                        if (declaredClass.getName().endsWith("$Factory")){
+                            creatorMethod = declaredClass.getMethod("newInstance",null);
+                            break;
+                        }
+
+                    }
+                }
+                if (creatorMethod!=null){
+                    return  (org.apache.xmlbeans.XmlObject)creatorMethod.invoke(null,null);
+                }else{
+                    throw new Exception("Creator not found!");
+                }
+
         }
 
     </xsl:template>
@@ -16,12 +31,8 @@
     <!-- ############################   ADB template   ###################################
 -->
     <xsl:template match="databinders[@dbtype='adb']">
         //Create an ADBBean and provide it as the test object
-        //todo Fill this properly
         public org.apache.axis2.databinding.ADBBean getTestObject(java.lang.Class type) throws
Exception{
-           org.apache.axis2.databinding.ADBBean bean = (org.apache.axis2.databinding.ADBBean)type.newInstance();
-
-
-           return bean;
+           return (org.apache.axis2.databinding.ADBBean) type.newInstance();
         }
 
     </xsl:template>
@@ -29,14 +40,10 @@
     <!-- ############################   none template!!!   ###############################
 -->
     <xsl:template match="databinders[@dbtype='none']">
         //Create an OMElement and provide it as the test object
-        //todo Fill this properly
         public org.apache.axis2.om.OMElement getTestObject(java.lang.Object dummy){
-
            org.apache.axis2.om.OMFactory factory = org.apache.axis2.om.OMAbstractFactory.getOMFactory();
            org.apache.axis2.om.OMNamespace defNamespace = factory.createOMNamespace("",null);
            return org.apache.axis2.om.OMAbstractFactory.getOMFactory().createOMElement("test",defNamespace);
-
-
         }
     </xsl:template>
 

Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java?rev=365284&r1=365283&r2=365284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java
(original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java
Sun Jan  1 20:16:23 2006
@@ -36,103 +36,157 @@
     private String output = ".";
     private String packageName = URLProcessor.DEFAULT_PACKAGE;
     private String language = ConfigPropertyFileLoader.getDefaultLanguage();
+    private String databindingName=ConfigPropertyFileLoader.getDefaultDBFrameworkName();
 
     private boolean asyncOnly = false;
     private boolean syncOnly = false;
     private boolean serverSide = false;
     private boolean testcase = false;
-    private boolean generateServerXml = false;
+    private boolean generateServiceXml = false;
+    private boolean generateAllClasses = false;
+    private boolean unwrapClasses = false;
+
     private Path classpath;
- 
- 
+
+
+
+
     /**
      * 
      */
     public AntCodegenTask() {
         super();
     }
-    
-    
+
+
     /**
-      * set the classpath
-      * @return
-      */
-     public Path createClasspath() {
-         if (classpath == null) {
-             classpath = new Path(getProject());
-         }
-         return classpath.createPath();
-     }
+     * set the classpath
+     * @return
+     */
+    public Path createClasspath() {
+        if (classpath == null) {
+            classpath = new Path(getProject());
+        }
+        return classpath.createPath();
+    }
 
     /**
-     *
+     * Fill the option map. This map is passed onto
+     * the code generation API to generate the code
      */
     private Map fillOptionMap() {
         Map optionMap = new HashMap();
 
+        ////////////////////////////////////////////////////////////////
+        //WSDL file name
         optionMap.put(
-            CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION,
-            new CommandLineOption(
                 CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION,
-                getStringArray(WSDLFileName)));
+                new CommandLineOption(
+                        CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION,
+                        getStringArray(WSDLFileName)));
+        //output location
+        optionMap.put(
+                CommandLineOptionConstants.OUTPUT_LOCATION_OPTION,
+                new CommandLineOption(
+                        CommandLineOptionConstants.OUTPUT_LOCATION_OPTION,
+                        getStringArray(output)));
+        //////////////////////////////////////////////////////////////////
+        // Databinding type
+        optionMap.put(
+                CommandLineOptionConstants.DATA_BINDING_TYPE_OPTION,
+                new CommandLineOption(
+                        CommandLineOptionConstants.DATA_BINDING_TYPE_OPTION,
+                        getStringArray(databindingName)));
 
+        // Async only option - forcing to generate async methods only
         if (asyncOnly) {
             optionMap.put(
-                CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION,
-                new CommandLineOption(
                     CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION,
-                    new String[0]));
+                    new CommandLineOption(
+                            CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION,
+                            new String[0]));
         }
+        // Sync only option - forcing to generate Sync methods only
         if (syncOnly) {
             optionMap.put(
-                CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION,
-                new CommandLineOption(
                     CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION,
-                    new String[0]));
+                    new CommandLineOption(
+                            CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION,
+                            new String[0]));
         }
+
+        //Package
         optionMap.put(
-            CommandLineOptionConstants.PACKAGE_OPTION,
-            new CommandLineOption(
                 CommandLineOptionConstants.PACKAGE_OPTION,
-                getStringArray(packageName)));
+                new CommandLineOption(
+                        CommandLineOptionConstants.PACKAGE_OPTION,
+                        getStringArray(packageName)));
+
+        //stub language
         optionMap.put(
-            CommandLineOptionConstants.STUB_LANGUAGE_OPTION,
-            new CommandLineOption(
                 CommandLineOptionConstants.STUB_LANGUAGE_OPTION,
-                getStringArray(language)));
-        optionMap.put(
-            CommandLineOptionConstants.OUTPUT_LOCATION_OPTION,
-            new CommandLineOption(
-                CommandLineOptionConstants.OUTPUT_LOCATION_OPTION,
-                getStringArray(output)));
+                new CommandLineOption(
+                        CommandLineOptionConstants.STUB_LANGUAGE_OPTION,
+                        getStringArray(language)));
+
+
+        //server side and generate services.xml options
         if (serverSide) {
             optionMap.put(
-                CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION,
-                new CommandLineOption(
                     CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION,
-                    new String[0]));
+                    new CommandLineOption(
+                            CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION,
+                            new String[0]));
 
-            if (generateServerXml) {
+            //services XML generation - effective only when specified as the server side
+            if (generateServiceXml) {
                 optionMap.put(
-                    CommandLineOptionConstants
-                        .GENERATE_SERVICE_DESCRIPTION_OPTION,
-                    new CommandLineOption(
                         CommandLineOptionConstants
-                            .GENERATE_SERVICE_DESCRIPTION_OPTION,
-                        new String[0]));
+                                .GENERATE_SERVICE_DESCRIPTION_OPTION,
+                        new CommandLineOption(
+                                CommandLineOptionConstants
+                                        .GENERATE_SERVICE_DESCRIPTION_OPTION,
+                                new String[0]));
             }
+            //generate all option - Only valid when generating serverside code
+            if (generateAllClasses) {
+                optionMap.put(
+                        CommandLineOptionConstants.GENERATE_ALL_OPTION,
+                        new CommandLineOption(
+                                CommandLineOptionConstants.GENERATE_ALL_OPTION,
+                                new String[0]));
+            }
+
         }
+
+        //generate the test case
         if (testcase) {
             optionMap.put(
-                CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION,
-                new CommandLineOption(
                     CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION,
-                    new String[0]));
+                    new CommandLineOption(
+                            CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION,
+                            new String[0]));
+        }
+
+        //Unwrap classes option - this determines whether the generated classes are inside
the stub/MR
+        //or gets generates as seperate classes
+        if (unwrapClasses) {
+            optionMap.put(
+                    CommandLineOptionConstants.UNWRAP_CLASSES_OPTION,
+                    new CommandLineOption(
+                            CommandLineOptionConstants.UNWRAP_CLASSES_OPTION,
+                            new String[0]));
         }
+
+
         return optionMap;
     }
 
-
+    /**
+     * Utility method to convert a string into a single item string[]
+     * @param value
+     * @return
+     */
     private String[] getStringArray(String value) {
         String[] values = new String[1];
         values[0] = value;
@@ -142,24 +196,25 @@
     public void execute() throws BuildException {
         try {
             /**
-             * This needs the ClassLoader we use to load the task have all the dependancyies
set, hope that 
+             * This needs the ClassLoader we use to load the task have all the dependancies
set, hope that
              * is ok for now
+             *
+             * todo look into this further!!!!!
              */
-            
-            
+
+
             AntClassLoader cl = new AntClassLoader(
-                                    null,
-                                    getProject(),
-                                    classpath,
-                                    false);
-            
+                    null,
+                    getProject(),
+                    classpath,
+                    false);
+
             Thread.currentThread().setContextClassLoader(cl);
             cl.addPathElement(output);
-            System.out.println("path is "+cl.getClasspath());    
 
             Map commandLineOptions = this.fillOptionMap();
             CommandLineOptionParser parser =
-                new CommandLineOptionParser(commandLineOptions);
+                    new CommandLineOptionParser(commandLineOptions);
             new CodeGenerationEngine(parser).generate();
         } catch (Throwable e) {
             throw new BuildException(e);
@@ -199,17 +254,17 @@
         this.testcase = testcase;
     }
 
-    public void setGenerateServerXml(boolean generateServerXml) {
-        this.generateServerXml = generateServerXml;
+    public void setGenerateServiceXml(boolean generateServiceXml) {
+        this.generateServiceXml = generateServiceXml;
     }
 
-    public static void main(String[] args) {
-        AntCodegenTask task = new AntCodegenTask();
-        task.setWSDLFileName(
-            "modules/samples/test-resources/wsdl/compound2.wsdl");
-        task.setOutput("temp");
-        task.execute();
-    }
+//    public static void main(String[] args) {
+//        AntCodegenTask task = new AntCodegenTask();
+//        task.setWSDLFileName(
+//                "modules/samples/test-resources/wsdl/compound2.wsdl");
+//        task.setOutput("temp");
+//        task.execute();
+//    }
 
     /**
      * @return
@@ -225,4 +280,11 @@
         classpath = path;
     }
 
+    public String getDatabindingName() {
+        return databindingName;
+    }
+
+    public void setDatabindingName(String databindingName) {
+        this.databindingName = databindingName;
+    }
 }



Mime
View raw message