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/19 06:37:01 UTC

svn commit: r415244 - in /webservices/axis2/trunk/java/modules: adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl adb/src/org/apache/axis2/databinding/ADBDataSource.java

Author: ajith
Date: Sun Jun 18 21:37:01 2006
New Revision: 415244

URL: http://svn.apache.org/viewvc?rev=415244&view=rev
Log:
1. Adding the preliminary code for direct writing (discussed at http://marc.theaimsgroup.com/?t=115046153600002&r=1&w=2)
  I. Added a new ADBDataSource.java to act as the data source for ADB beans
  II. modified the ADBBeanTemplate.xsl to have a getOMElement method in the ADBBean. The code is yet to be completed!

Note - Need the latest AXIOM jars to build this since this change depends on one of the AXIOM changes

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

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=415244&r1=415243&r2=415244&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Sun Jun 18 21:37:01 2006
@@ -241,6 +241,55 @@
 
         </xsl:for-each>
 
+     <!-- get OMElement methods that allows direct writing -->
+     /**
+     *
+     * @param parentQName
+     * @param factory
+     * @return
+     */
+    public org.apache.axiom.om.OMElement getOMElement(
+            javax.xml.namespace.QName parentQName,
+            final org.apache.axiom.om.OMFactory factory){
+       <xsl:choose>
+            <xsl:when test="@type">
+               org.apache.axiom.om.OMDataSource dataSource =
+               new org.apache.axis2.databinding.ADBDataSource(this){
+                   public void serialize(
+                          javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
+
+                         //yet to be generated!!
+
+                   }
+
+               };
+
+       return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
+               parentQName,factory,dataSource);
+            </xsl:when>
+
+            <xsl:otherwise>
+               org.apache.axiom.om.OMDataSource dataSource =
+               new org.apache.axis2.databinding.ADBDataSource(this){
+                   public void serialize(
+                         javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
+
+                         //yet to be generated!
+                    }
+               };
+
+       return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
+               MY_QNAME,factory,dataSource);
+
+            </xsl:otherwise>
+       </xsl:choose>
+
+
+
+
+
+    }
+
         /**
         * databinding method to get an XML representation of this object
         *

Added: 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=415244&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBDataSource.java Sun Jun 18 21:37:01 2006
@@ -0,0 +1,83 @@
+package org.apache.axis2.databinding;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.util.StAXUtils;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLOutputFactory;
+import java.io.OutputStream;
+import java.io.Writer;
+/*
+ * 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.
+ */
+
+public abstract class ADBDataSource implements OMDataSource {
+
+    private ADBBean bean;
+
+    /**
+     * Constructor taking in an ADBBean
+     * @param bean
+     */
+    protected ADBDataSource(ADBBean bean) {
+        this.bean = bean;
+    }
+
+
+    /**
+     * @see OMDataSource#serialize(java.io.OutputStream, org.apache.axiom.om.OMOutputFormat)
+     * @param output
+     * @param format
+     * @throws XMLStreamException
+     */
+    public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
+       serialize(StAXUtils.createXMLStreamWriter(output));
+    }
+
+    /**
+     * @see OMDataSource#serialize(java.io.Writer, org.apache.axiom.om.OMOutputFormat)
+     * @param writer
+     * @param format
+     * @throws XMLStreamException
+     */
+    public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
+        serialize(StAXUtils.createXMLStreamWriter(writer));
+    }
+
+    /**
+     * This needs to be generated inside the ADB bean
+     * @see OMDataSource#serialize(javax.xml.stream.XMLStreamWriter)
+     * @param xmlWriter
+     * @throws XMLStreamException
+     */
+    public abstract void serialize(XMLStreamWriter xmlWriter)
+            throws XMLStreamException;
+
+
+    /**
+     * @see org.apache.axiom.om.OMDataSource#getReader()
+     * @return
+     * @throws XMLStreamException
+     */
+    public XMLStreamReader getReader() throws XMLStreamException {
+        // since only ADBBeans related to elements can be serialized
+        // we are safe in passing null here. 
+        return bean.getPullParser(null);
+    }
+
+}



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