axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r791238 - in /webservices/axis2/trunk/java/modules: adb-codegen/src/org/apache/axis2/schema/template/ adb/src/org/apache/axis2/databinding/
Date Sun, 05 Jul 2009 12:56:15 GMT
Author: veithen
Date: Sun Jul  5 12:56:14 2009
New Revision: 791238

URL: http://svn.apache.org/viewvc?rev=791238&view=rev
Log:
* AXIS2-4416: Avoid generating unnecessary anonymous inner classes.
* Avoid using reflection in ADBHelperDataSource.

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl?rev=791238&r1=791237&r2=791238&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
Sun Jul  5 12:56:14 2009
@@ -685,12 +685,7 @@
         <xsl:choose>
             <xsl:when test="@type">
                org.apache.axiom.om.OMDataSource dataSource =
-                       new org.apache.axis2.databinding.ADBDataSource(this,parentQName){
-
-                 public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter
xmlWriter) throws javax.xml.stream.XMLStreamException {
-                       <xsl:value-of select="$name"/>.this.serialize(parentQName,xmlWriter);
-                 }
-               };
+                       new org.apache.axis2.databinding.ADBDataSource(this,parentQName);
                return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
                parentQName,factory,dataSource);
             </xsl:when>

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl?rev=791238&r1=791237&r2=791238&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-helpermode.xsl
Sun Jul  5 12:56:14 2009
@@ -565,12 +565,7 @@
                final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{
 
                org.apache.axiom.om.OMDataSource dataSource =
-                       new org.apache.axis2.databinding.ADBHelperDataSource(bean,parentQName,"<xsl:value-of
select="$fullyQualifiedHelperName"/>"){
-
-                 public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter
xmlWriter) throws javax.xml.stream.XMLStreamException {
-                       <xsl:value-of select="$helpername"/>.this.serialize(bean,parentQName,xmlWriter);
-                 }
-               };
+                       new org.apache.axis2.databinding.ADBHelperDataSource(bean,parentQName,this);
 
                <xsl:choose>
                    <xsl:when test="@type">

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java?rev=791238&r1=791237&r2=791238&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java
Sun Jul  5 12:56:14 2009
@@ -40,7 +40,7 @@
 import java.io.Writer;
 import java.util.HashMap;
 
-public abstract class ADBDataSource implements OMDataSourceExt {
+public class ADBDataSource implements OMDataSourceExt {
     protected QName parentQName;
     private ADBBean bean;
     
@@ -51,7 +51,7 @@
      *
      * @param bean
      */
-    protected ADBDataSource(ADBBean bean, QName parentQName) {
+    public ADBDataSource(ADBBean bean, QName parentQName) {
         this.bean = bean;
         this.parentQName = parentQName;
     }
@@ -90,13 +90,10 @@
      */
     public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException{
         MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlWriter);
-        serialize(mtomAwareXMLStreamWriter);
+        bean.serialize(parentQName, mtomAwareXMLStreamWriter);
         mtomAwareXMLStreamWriter.flush();
     }
 
-    public abstract void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException;
-
-
     /**
      * @throws XMLStreamException
      * @see org.apache.axiom.om.OMDataSource#getReader()

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java?rev=791238&r1=791237&r2=791238&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBHelperDataSource.java
Sun Jul  5 12:56:14 2009
@@ -37,15 +37,13 @@
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.HashMap;
 
-public abstract class ADBHelperDataSource implements OMDataSourceExt {
+public class ADBHelperDataSource<T> implements OMDataSourceExt {
 
     protected QName parentQName;
-    private Object bean;
-    protected String helperClassName;
+    private T bean;
+    private final ADBHelper<T> helper;
     
     HashMap map = null;  // Map of properties
 
@@ -54,10 +52,10 @@
      *
      * @param bean
      */
-    protected ADBHelperDataSource(Object bean, QName parentQName, String helperClassName)
{
+    public ADBHelperDataSource(T bean, QName parentQName, ADBHelper<T> helper) {
         this.bean = bean;
         this.parentQName = parentQName;
-        this.helperClassName = helperClassName;
+        this.helper = helper;
     }
 
 
@@ -95,34 +93,16 @@
      */
     public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException{
         MTOMAwareXMLStreamWriter mtomAwareXMLStreamWriter = new MTOMAwareXMLSerializer(xmlWriter);
-        serialize(mtomAwareXMLStreamWriter);
+        helper.serialize(bean, parentQName, mtomAwareXMLStreamWriter);
         mtomAwareXMLStreamWriter.flush();
     }
 
-    public abstract void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException;
-
-
     /**
      * @throws XMLStreamException
      * @see org.apache.axiom.om.OMDataSource#getReader()
      */
     public XMLStreamReader getReader() throws XMLStreamException {
-        // since only ADBBeans related to elements can be serialized
-        try {
-            Class helperClass = Class.forName(helperClassName);
-            Method method = helperClass.getMethod("getPullParser", new Class[] { Object.class,
-                    QName.class });
-            return (XMLStreamReader)method.invoke(null, new Object[] { bean, parentQName
});
-        } catch (ClassNotFoundException e) {
-            throw new XMLStreamException(e);
-        } catch (NoSuchMethodException e) {
-            throw new XMLStreamException(e);
-        } catch (IllegalAccessException e) {
-            throw new XMLStreamException(e);
-        } catch (InvocationTargetException e) {
-            throw new XMLStreamException(e);
-        }
-
+        return helper.getPullParser(bean, parentQName);
     }
 
     /**



Mime
View raw message