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 2004/12/23 11:07:10 UTC

svn commit: r123182 - in webservices/axis/trunk/java/dev/scratch/prototype2/src: java/org/apache/axis/impl/llom java/org/apache/axis/impl/llom/builder java/org/apache/axis/impl/llom/factory java/org/apache/axis/impl/llom/serialize java/org/apache/axis/om java/org/apache/axis/transport test/org/apache/axis/clientapi test/org/apache/axis/om test/org/apache/axis/om/builder test/org/apache/axis/om/impl/seriliazer test/org/apache/axis/om/impl/streamwrapper

Author: ajith
Date: Thu Dec 23 02:07:09 2004
New Revision: 123182

URL: http://svn.apache.org/viewcvs?view=rev&rev=123182
Log:
Made a major change to the serilaizing. Now serilizing can take place by calling the node.serialize method
Added:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMSerializer.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/ElementSerializerTest.java
Removed:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleObjectOMSerializer.java
Modified:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMAttributeImpl.java	Thu Dec 23 02:07:09 2004
@@ -44,13 +44,10 @@
     }
 
     public QName getQName(){
-
-
         String namespaceName = namespace != null ? namespace.getName() : null;
         return new QName(namespaceName, localName);
     }
 
-    // -------- Getters and Setters
     public String getLocalName() {
         return localName;
     }
@@ -74,5 +71,7 @@
     public OMNamespace getNamespace(){
         return namespace;
     }
+
+
 
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java	Thu Dec 23 02:07:09 2004
@@ -2,13 +2,19 @@
 
 import org.apache.axis.impl.llom.traverse.OMChildrenIterator;
 import org.apache.axis.impl.llom.traverse.OMChildrenQNameIterator;
+import org.apache.axis.impl.llom.serialize.StreamingOMSerializer;
+
+import org.apache.axis.impl.llom.util.StreamWriterToContentHandlerConverter;
 import org.apache.axis.om.*;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.ListIterator;
+import java.util.Stack;
 
 
 /**
@@ -27,13 +33,13 @@
  * limitations under the License.
  * <p/>
  */
-public class OMElementImpl extends OMNamedNodeImpl implements OMElement {
+public class OMElementImpl extends OMNamedNodeImpl implements OMElement, OMConstants {
 
     private OMNode firstChild;
-    private OMXMLParserWrapper builder;
-    private OMAttributeImpl firstAttribute;
+    protected OMXMLParserWrapper builder;
     private ArrayList namespaces;
     private ArrayList attributes;
+    private Stack namespaceStack;
 
     public OMElementImpl(OMElement parent) {
         super(parent);
@@ -396,4 +402,168 @@
             throw new UnsupportedOperationException("This element was not created in a manner to be switched");
         return new OMStAXWrapper(builder, this, cacheOff);
     }
+
+
+    public void serialize(XMLStreamWriter writer, boolean cache, Stack namespacePrefixStack) throws XMLStreamException {
+        boolean firstElement = false;
+
+        if (namespacePrefixStack == null) {
+            this.namespaceStack = new Stack();
+            firstElement = true;
+        } else {
+            this.namespaceStack = namespacePrefixStack;
+        }
+
+        int namespaceCount = 0;
+
+        short builderType = PULL_TYPE_BUILDER; //default is pull type
+        if (builder != null)
+            builderType = this.builder.getBuilderType();
+        if (builderType == PUSH_TYPE_BUILDER) {
+            builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(writer)); //for now only SAX
+        }
+
+        //Special case for the pull type building with cache off
+        //The getPullParser method returns the current elements itself.
+        if (!cache) {
+            if (firstChild == null && nextSibling == null && !isComplete() && builderType == PULL_TYPE_BUILDER) {
+                StreamingOMSerializer streamingOMSerializer = new StreamingOMSerializer();
+                streamingOMSerializer.setNamespacePrefixStack(namespaceStack);
+                streamingOMSerializer.serialize(this.getPullParser(!cache), writer);
+                return;
+            }
+        }
+
+        if (!cache) {
+            if (isComplete()) {
+                //serialize own normally
+                serializeNormal(writer, cache);
+
+                if (nextSibling != null) {
+                    //serilize next sibling
+                    nextSibling.serialize(writer, cache, namespaceStack);
+                } else {
+                    if (parent == null) {
+                        return;
+                    } else if (parent.isComplete()) {
+                        return;
+                    } else {
+                        //do the special serialization
+                        //Only the push serializer is left now
+                        builder.next();
+                    }
+
+
+                }
+            } else if (firstChild != null) {
+                namespaceCount = serializeStartpart(writer);
+                firstChild.serialize(writer, cache, namespaceStack);
+                serializeEndpart(writer, namespaceCount);
+            } else {
+                //do the special serilization
+                //Only the push serializer is left now
+                builder.next();
+            }
+
+
+        } else {
+            //serialize own normally
+            serializeNormal(writer, cache);
+            //serialize the siblings if this is not the first element
+            if (!firstElement){
+                if (this.getNextSibling() != null) {
+                    this.getNextSibling().serialize(writer, cache, namespaceStack);
+                }
+            }
+        }
+
+
+    }
+
+    private int serializeStartpart(XMLStreamWriter writer) throws XMLStreamException {
+        int nsPushCount = 0;
+        String prefix = null;
+        String nameSpaceName = null;
+
+        if (ns != null) {
+            prefix = ns.getPrefix();
+            nameSpaceName = ns.getName();
+            if (prefix != null) {
+                writer.writeStartElement(prefix, this.getLocalName(), nameSpaceName);
+                if (serializeNamespace(ns, writer)) nsPushCount++;
+            } else {
+                writer.writeStartElement(nameSpaceName, this.getLocalName());
+
+            }
+        }
+        //add the elements attributes
+        if (attributes != null) {
+            int attCount = attributes.size();
+            for (int i = 0; i < attCount; i++) {
+                serializeAttribute((OMAttribute) attributes.get(i), writer);
+            }
+        }
+        //add the namespaces
+        Iterator namespaces = this.getAllDeclaredNamespaces();
+        while (namespaces.hasNext()) {
+            if (serializeNamespace((OMNamespace) namespaces.next(), writer)) nsPushCount++;
+        }
+
+        return nsPushCount;
+    }
+
+    private void serializeEndpart(XMLStreamWriter writer, int namespaceCount) throws XMLStreamException {
+
+        for (int i = 0; i < namespaceCount; i++) {
+            namespaceStack.pop();
+        }
+
+        writer.writeEndElement();
+        writer.flush();
+    }
+
+    private void serializeNormal(XMLStreamWriter writer, boolean cache) throws XMLStreamException {
+
+        int namespaceCount = serializeStartpart(writer);
+
+        if (getFirstChild() != null) {
+            getFirstChild().serialize(writer, cache, namespaceStack);
+        }
+
+        serializeEndpart(writer, namespaceCount);
+
+    }
+
+    protected void serializeAttribute(OMAttribute attr, XMLStreamWriter writer) throws XMLStreamException {
+        //first check whether the attribute is associated with a namespace
+        OMNamespace ns = attr.getNamespace();
+        String prefix = null;
+        String namespaceName = null;
+        if (ns != null) {
+            //add the prefix if it's availble
+            prefix = ns.getPrefix();
+            namespaceName = ns.getName();
+            if (prefix != null)
+                writer.writeAttribute(prefix, namespaceName, attr.getLocalName(), attr.getValue());
+            else
+                writer.writeAttribute(namespaceName, attr.getLocalName(), attr.getValue());
+        } else {
+            writer.writeAttribute(attr.getLocalName(), attr.getValue());
+        }
+    }
+
+    protected boolean serializeNamespace(OMNamespace namespace, XMLStreamWriter writer) throws XMLStreamException {
+        boolean nsWritten = false;
+        if (namespace != null) {
+            String prefix = namespace.getPrefix();
+            if (!namespaceStack.contains(prefix)) {
+                writer.writeNamespace(prefix, namespace.getName());
+                namespaceStack.push(prefix);
+                nsWritten = true;
+            }
+        }
+
+        return nsWritten;
+    }
+
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java	Thu Dec 23 02:07:09 2004
@@ -4,6 +4,10 @@
 import org.apache.axis.om.OMException;
 import org.apache.axis.om.OMNode;
 
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import java.util.Stack;
+
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
  * <p/>
@@ -196,5 +200,12 @@
         this.previousSibling = (OMNodeImpl) previousSibling;
     }
 
+    public void serialize(XMLStreamWriter writer, boolean cache, Stack namespacePrefixStack) throws XMLStreamException {
+       //Do nothing. Relevant children will put relevant things here
+    }
+
+    public void serialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException {
+        serialize(writer,cache,null);
+    }
 
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMTextImpl.java	Thu Dec 23 02:07:09 2004
@@ -1,9 +1,11 @@
 package org.apache.axis.impl.llom;
 
-import org.apache.axis.om.OMElement;
-import org.apache.axis.om.OMException;
-import org.apache.axis.om.OMNode;
-import org.apache.axis.om.OMText;
+import org.apache.axis.om.*;
+import org.apache.axis.impl.llom.serialize.StreamingOMSerializer;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import java.util.Stack;
 
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -21,9 +23,9 @@
  * limitations under the License.
  * <p/>
  */
-public class OMTextImpl extends OMNodeImpl implements OMText {
+public class OMTextImpl extends OMNodeImpl implements OMText, OMConstants {
 
-    protected short textType;
+    protected short textType = TEXT_NODE;
 
     public OMTextImpl(OMElement parent, String text) {
         super(parent);
@@ -43,7 +45,10 @@
      * @param type
      */
     public void setTextType(short type) {
-        this.textType = type;
+        if (type == TEXT_NODE || type == COMMENT_NODE || type == CDATA_SECTION_NODE)
+            this.textType = type;
+        else
+            throw new UnsupportedOperationException("Attempt to set wrong type");
     }
 
     public short getTextType() {
@@ -59,14 +64,39 @@
     }
 
     /**
-     * This is to get the type of node, as this is the super class of all the nodes
-     *
      * @return
      * @throws org.apache.axis.om.OMException
      */
     public short getType() throws OMException {
-        return OMNode.TEXT_NODE;
+        return textType;
     }
 
-
+    /**
+     * @param writer
+     * @param cache
+     * @param namespacePrefixStack
+     * @throws XMLStreamException
+     */
+    public void serialize(XMLStreamWriter writer, boolean cache, Stack namespacePrefixStack) throws XMLStreamException {
+        boolean isFirst = false;
+        if (namespacePrefixStack == null) {
+            isFirst = true;
+        }
+        if (textType == TEXT_NODE)
+            writer.writeCharacters(this.value);
+        else if (textType == COMMENT_NODE)
+            writer.writeComment(this.value);
+        else if (textType == CDATA_SECTION_NODE) {
+            writer.writeCData(this.value);
+        }
+        //In this case we have to advance the parser (even when not cached) upto the
+        //next *element*. You cannot ask for a pull parser from the text node!!!
+        //by advancing the parser
+        if (!isFirst) {
+            OMNode nextSibling = this.getNextSibling();
+            if (nextSibling != null) {
+                nextSibling.serialize(writer, cache, namespacePrefixStack);
+            }
+        }
+    }
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/ObjectToOMBuilder.java	Thu Dec 23 02:07:09 2004
@@ -31,15 +31,11 @@
     private OMElement startElement;
     private OMFactory omFactory;
     private boolean buildStarted = false;
-    private boolean cache=true;
+    private boolean cache = true;
     private ContentHandler externalContentHandler = null;
 
     // ============= For content handler ============
     private OMNode lastNode = null;
-    private StringBuffer buffer = new StringBuffer();
-    private Stack textBufferStack = new Stack();
-    private OMNode currentNode;
-//    private OMElement parent = null;
     private Vector nameSpaces = new Vector();
     // ==============================================
 
@@ -53,9 +49,7 @@
         return externalContentHandler;
     }
 
-    public void setExternalContentHandler(ContentHandler externalContentHandler) {
-        this.externalContentHandler = externalContentHandler;
-    }
+
 
     /**
      * @param startElement - this refers to the element the object should come under.
@@ -81,9 +75,9 @@
             if (!buildStarted) {
                 buildStarted = true;
                 //if not to be cached then switch the contenthandler
-                if (!cache){
-                    if (externalContentHandler==null){
-                        throw new IllegalStateException("Cannot have a cache with an empty content handler");
+                if (!cache) {
+                    if (externalContentHandler == null) {
+                        throw new IllegalStateException("Cannot have no cache with an empty content handler");
                     }
                     outObject.setContentHandler(externalContentHandler);
                 }
@@ -112,10 +106,10 @@
      * @throws OMException
      */
     public void setCache(boolean b) throws OMException {
-        if (!cache && b){
+        if (!cache && b) {
             throw new UnsupportedOperationException("cache cannot be reset once set");
         }
-        cache=b;
+        cache = b;
     }
 
     public Object getParser() {
@@ -130,13 +124,7 @@
         throw new UnsupportedOperationException(); //TODO implement this
     }
 
-
-
     // ====================  ContentHandler Implementations ========================
-
-
-
-
     public void endDocument() throws SAXException {
         lastNode.setComplete(true);
     }
@@ -172,8 +160,6 @@
     }
 
     public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
-
-
         if (lastNode.isComplete()) {
             OMElement parent = lastNode.getParent();
             parent.setComplete(true);
@@ -181,9 +167,6 @@
         } else {
             lastNode.setComplete(true);
         }
-
-//        String elementText = buffer.toString();
-//        textBufferStack.pop();
     }
 
     public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
@@ -191,8 +174,6 @@
         if (localName.length() == 0)
             localName = qName;
 
-        // Out current parser (Piccolo) does not error when a
-        // namespace is used and not defined.  Check for these here
         //todo In-insert this if needed!!!!!!
 //        if (qName.indexOf(':') >= 0 && namespaceURI.length() == 0) {
 //            throw new SAXException("Use of undefined namespace prefix: " +
@@ -245,4 +226,14 @@
         }
     }
 
+    public short getBuilderType() {
+        return OMConstants.PUSH_TYPE_BUILDER;
+    }
+
+    public void registerExternalContentHandler(Object obj) {
+        if (obj instanceof ContentHandler)
+            this.externalContentHandler = (ContentHandler)obj;
+        else
+            throw new IllegalArgumentException("Attempt to register wrong type of content handler");
+    }
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/builder/StAXBuilder.java	Thu Dec 23 02:07:09 2004
@@ -29,6 +29,7 @@
  * or just an XML model. This class will give some common functionality of OM Building from StAX.
  */
 public abstract class StAXBuilder implements OMXMLParserWrapper {
+
     protected OMFactory ombuilderFactory;
     protected XMLStreamReader parser;
 
@@ -226,4 +227,16 @@
      * @throws OMException
      */
     public abstract int next() throws OMException;
+
+    /**
+     *
+     * @return
+     */
+    public short getBuilderType() {
+        return OMConstants.PULL_TYPE_BUILDER;
+    }
+
+    public void registerExternalContentHandler(Object obj) {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/factory/OMLinkedListImplFactory.java	Thu Dec 23 02:07:09 2004
@@ -22,6 +22,12 @@
 public class OMLinkedListImplFactory extends OMFactory {
 
 
+//    public OMElement createOMElement(OMElement parent, OutObject object) {
+//        ObjectToOMBuilder objectToOMBuilder = new ObjectToOMBuilder(parent, object);
+//        createOMElement(null, null, parent, objectToOMBuilder);
+//        return parent;
+//    }
+
     public OMElement createOMElement(OMElement parent) {
         return new OMElementImpl(parent);
     }

Deleted: /webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java?view=auto&rev=123181
==============================================================================

Deleted: /webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleObjectOMSerializer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleObjectOMSerializer.java?view=auto&rev=123181
==============================================================================

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java	Thu Dec 23 02:07:09 2004
@@ -1,10 +1,11 @@
 package org.apache.axis.impl.llom.serialize;
 
+import org.apache.axis.om.OMSerializer;
+
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
-import java.util.Vector;
 import java.util.Stack;
 
 
@@ -23,13 +24,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class StreamingOMSerializer implements XMLStreamConstants {
+public class StreamingOMSerializer implements XMLStreamConstants, OMSerializer {
 
-    private Stack prefixStack = new Stack();
-    private Stack nsCountStack = new Stack();
+    private Stack namespacePrefixStack = new Stack();
+    private Stack namespaceCountStack = new Stack();
 
-    public void serialize(Object obj, XMLStreamWriter writer) throws XMLStreamException {
+    public Stack getNamespacePrefixStack() {
+        return namespacePrefixStack;
+    }
+
+    public void setNamespacePrefixStack(Stack namespacePrefixStack) {
+        if (namespacePrefixStack != null)
+            this.namespacePrefixStack = namespacePrefixStack;
+    }
 
+    public void serialize(Object obj, XMLStreamWriter writer) throws XMLStreamException {
         if (!(obj instanceof XMLStreamReader)) {
             throw new UnsupportedOperationException("Unsupported input object. Must be of the the type XMLStreamReader");
         }
@@ -38,6 +47,7 @@
         serializeNode(node, writer);
     }
 
+
     protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
         while (reader.hasNext()) {
             int event = reader.next();
@@ -53,46 +63,56 @@
                 serializeCData(reader, writer);
             } else if (event == END_ELEMENT) {
                 serializeEndElement(writer);
+            } else if (event == END_DOCUMENT) {
+                try {
+                    serializeEndElement(writer);
+                } catch (Exception e) {
+                    //this is eaten
+                }
             }
             writer.flush();
         }
     }
 
     /**
-
+     
      */
     protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
-        int nsPushCount=0;
+
+        int nsPushCount = 0;
+
         String prefix = reader.getPrefix();
         String nameSpaceName = reader.getNamespaceURI();
+
         if (prefix != null) {
             writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName);
-            if (serializeNamespace(prefix, nameSpaceName,writer)) nsPushCount++;
+            if (serializeNamespace(prefix, nameSpaceName, writer)) nsPushCount++;
         } else {
             writer.writeStartElement(nameSpaceName, reader.getLocalName());
             //add the own namespace
-            writer.writeDefaultNamespace(nameSpaceName);
         }
-
+        
         //add attributes
         serializeAttributes(reader, writer);
         //add the namespaces
         int count = reader.getNamespaceCount();
         for (int i = 0; i < count; i++) {
-            if (serializeNamespace(reader.getNamespacePrefix(i) ,reader.getNamespaceURI(i), writer)) nsPushCount++;
+            if (serializeNamespace(reader.getNamespacePrefix(i), reader.getNamespaceURI(i), writer)) nsPushCount++;
         }
 
-        nsCountStack.push(new Integer(nsPushCount));
+        namespaceCountStack.push(new Integer(nsPushCount));
 
     }
 
     protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
-        Integer removeCount = (Integer)nsCountStack.pop();
-        int count = removeCount.intValue();
-        for (int i=0;i<count;i++)
-            prefixStack.pop();
-        
+        if (!namespaceCountStack.isEmpty()) {
+            Integer removeCount = (Integer) namespaceCountStack.pop();
+            int count = removeCount.intValue();
+            for (int i = 0; i < count; i++)
+                namespacePrefixStack.pop();
+        }
         writer.writeEndElement();
+       
     }
 
     /**
@@ -136,11 +156,11 @@
         }
     }
 
-    private boolean serializeNamespace(String prefix,String URI, XMLStreamWriter writer) throws XMLStreamException {
+    private boolean serializeNamespace(String prefix, String URI, XMLStreamWriter writer) throws XMLStreamException {
         boolean nsWritten = false;
-        if (!prefixStack.contains(prefix)) {
-            writer.writeNamespace(prefix,URI );
-            prefixStack.push(prefix);
+        if (!namespacePrefixStack.contains(prefix)) {
+            writer.writeNamespace(prefix, URI);
+            namespacePrefixStack.push(prefix);
             nsWritten = true;
         }
         return nsWritten;

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMConstants.java	Thu Dec 23 02:07:09 2004
@@ -39,4 +39,9 @@
     public static final String SOAPFAULT_LOCAL_NAME = "Fault";
     public static final String SOAPFAULT_NAMESPACE_URI = SOAP_ENVELOPE_NAMESPACE_URI;
     public static final String SOAPFAULT_NAMESPACE_PREFIX = SOAPENVELOPE_NAMESPACE_PREFIX;
+
+    //OMBuilder constants
+    public static final short PUSH_TYPE_BUILDER=0;
+    public static final short PULL_TYPE_BUILDER=1;
+
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMNode.java	Thu Dec 23 02:07:09 2004
@@ -1,5 +1,9 @@
 package org.apache.axis.om;
 
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import java.util.Stack;
+
 
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -119,7 +123,6 @@
 
     /**
      * This is to get the type of node, as this is the super class of all the nodes
-     *
      * @return
      * @throws OMException
      */
@@ -129,16 +132,30 @@
 
     /**
      * get the previous sibling
-     *
      * @return
      */
     public OMNode getPreviousSibling();
 
     /**
      * Set the previous sibling
-     *
      * @param previousSibling
      */
     public void setPreviousSibling(OMNode previousSibling);
+
+    /**
+     * Writes the necessary serialization to a XMLStreamWriter object
+     * @param writer
+     * @param cache
+     * @param namespacePrefixStack
+     */
+    public void serialize(XMLStreamWriter writer, boolean cache, Stack namespacePrefixStack) throws XMLStreamException ;
+
+    /**
+     * 
+     * @param writer
+     * @param cache
+     * @throws XMLStreamException
+     */
+    public void serialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException ;
 
 }

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMSerializer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMSerializer.java?view=auto&rev=123182
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMSerializer.java	Thu Dec 23 02:07:09 2004
@@ -0,0 +1,27 @@
+package org.apache.axis.om;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import java.util.Stack;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 interface OMSerializer {
+    void serialize(Object obj,XMLStreamWriter writer) throws XMLStreamException ;
+    Stack getNamespacePrefixStack();
+    void setNamespacePrefixStack(Stack namespacePrefixStack); 
+
+}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/om/OMXMLParserWrapper.java	Thu Dec 23 02:07:09 2004
@@ -57,7 +57,24 @@
     boolean isCompleted();
 
     /**
+     * @return the document element
+     */
+    OMElement getDocumentElement();
+
+    /**
+     * Returns the type of the builder.
+     * Can be either the
+     * PUSH_TYPE_BUILDER or PULL_TYPE_BUILDER
      * @return
      */
-    public OMElement getDocumentElement();
+    short getBuilderType();
+
+    /**
+     * Registers an external content handler. Especially useful for
+     * push type builders. will throw an unsupportedOperationExcveption if
+     * such handler registration is not supported     
+     * @param obj
+     */
+    void registerExternalContentHandler(Object obj);
+
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java	Thu Dec 23 02:07:09 2004
@@ -20,7 +20,6 @@
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.engine.TransportSender;
 import org.apache.axis.impl.handlers.AbstractHandler;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.om.SOAPEnvelope;
 import org.apache.axis.addressing.EndpointReferenceType;
 
@@ -55,9 +54,8 @@
         SOAPEnvelope envelope = msgContext.getEnvelope();
         if (envelope != null) {
             try {
-                SimpleOMSerializer serializer = new SimpleOMSerializer();
                 XMLStreamWriter outputWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
-                serializer.serialize(envelope, outputWriter);
+                envelope.serialize(outputWriter,true);
             } catch (XMLStreamException e) {
                 throw new AxisFault("Stream error",e);
             }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java	Thu Dec 23 02:07:09 2004
@@ -31,7 +31,6 @@
 import org.apache.axis.impl.description.ParameterImpl;
 import org.apache.axis.impl.description.SimpleAxisOperationImpl;
 import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.impl.providers.RawXMLProvider;
 import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
 import org.apache.axis.om.OMFactory;
@@ -94,10 +93,8 @@
         Call call = new Call();
         call.setTo(targetEPR);
         SOAPEnvelope responseEnv = call.sendReceive(envelope);
-
-        SimpleOMSerializer sOMSerializer = new SimpleOMSerializer();
-        sOMSerializer.serialize(responseEnv, XMLOutputFactory.newInstance().createXMLStreamWriter(
-                System.out));
+        responseEnv.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
+                System.out),true);
 
     }
 

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java	Thu Dec 23 02:07:09 2004
@@ -26,7 +26,6 @@
 import org.apache.axis.impl.description.AxisService;
 import org.apache.axis.impl.description.SimpleAxisOperationImpl;
 import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.impl.providers.RawXMLProvider;
 import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
 import org.apache.axis.om.OMFactory;
@@ -110,10 +109,10 @@
 
         Callback callback = new Callback(){
             public void onComplete(AsyncResult result){
-                SimpleOMSerializer sOMSerializer = new SimpleOMSerializer();
+
                 try {
-                    sOMSerializer.serialize(result.getResponseEnvelope(), XMLOutputFactory.newInstance()
-                            .createXMLStreamWriter(System.out));
+                   result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
+                            .createXMLStreamWriter(System.out),true);
                 } catch (XMLStreamException e) {
                     reportError(e);
 

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java	Thu Dec 23 02:07:09 2004
@@ -3,7 +3,6 @@
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.OMNavigator;
 import org.apache.axis.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -31,7 +30,6 @@
 public class OMNavigatorTest extends AbstractTestCase {
 
     private SOAPEnvelope envelope = null;
-    private SimpleOMSerializer serilizer;
     private OMXMLParserWrapper builder;
     private File tempFile;
     private XMLStreamWriter writer;
@@ -46,7 +44,6 @@
         OMFactory factory = OMFactory.newInstance();
         builder = new StAXSOAPModelBuilder(factory, xmlStreamReader);
         envelope = (SOAPEnvelope)builder.getDocumentElement();
-        serilizer = new SimpleOMSerializer();
         tempFile = File.createTempFile("temp", "xml");
         writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
 
@@ -58,7 +55,7 @@
 
         assertNotNull(envelope);
         //dump the out put to a  temporary file
-        serilizer.serialize(envelope,writer);
+        envelope.serialize(writer,true);
 
         //now the OM is fully created test the navigation
         OMNavigator navigator = new OMNavigator(envelope);

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/builder/ObjectToOMBuilderTest.java	Thu Dec 23 02:07:09 2004
@@ -2,13 +2,14 @@
 
 import junit.framework.TestCase;
 import org.apache.axis.impl.llom.builder.ObjectToOMBuilder;
-import org.apache.axis.impl.llom.serialize.SimpleObjectOMSerializer;
 import org.apache.axis.om.*;
 import org.apache.axis.om.builder.dummy.DummyOutObject;
 
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
 import java.util.Iterator;
+import java.io.File;
+import java.io.FileOutputStream;
 
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -32,43 +33,40 @@
 public class ObjectToOMBuilderTest extends TestCase {
 
     private OutObject outObject;
-    private ObjectToOMBuilder objectToOMBuilder;
-    private OMFactory omFactory;
+
+
     private OMElement element;
-    private SimpleObjectOMSerializer serializer;
+    private XMLStreamWriter writer;
+    private File tempFile;
 
     protected void setUp() throws Exception {
         super.setUp();
-        outObject = new DummyOutObject();
-        omFactory = OMFactory.newInstance();
-
+        OutObject outObject = new DummyOutObject();
+        OMFactory omFactory = OMFactory.newInstance();
         OMNamespace ns = omFactory.createOMNamespace(OMConstants.SOAP_ENVELOPE_NAMESPACE_URI, OMConstants.SOAPENVELOPE_NAMESPACE_PREFIX);
-
         element = omFactory.createOMElement("Body", ns);
-        objectToOMBuilder = new ObjectToOMBuilder(element, outObject);
-        omFactory.createOMElement(null, null, element, objectToOMBuilder);
-        serializer = new SimpleObjectOMSerializer();
+        new ObjectToOMBuilder(element,outObject);
+        tempFile = File.createTempFile("temp","xml");
+        writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
+
     }
 
     public void testBuilding() {
-        objectToOMBuilder.next();
         Iterator children = element.getChildren();
         while (children.hasNext()) {
             OMNode omNode = (OMNode) children.next();
             assertNotNull(omNode);
         }
-
-
     }
 
     public void testSerialization() throws Exception {
-        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
-        serializer.serialize(element, writer, true);
+        element.serialize(writer, true);
     }
 
-    public void testSerializationWithCacheOff() throws Exception {
-        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
-        serializer.serialize(element, writer, false);
+
+
+    protected void tearDown() throws Exception {
+        tempFile.delete();
     }
 
 }

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/ElementSerializerTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/ElementSerializerTest.java?view=auto&rev=123182
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/ElementSerializerTest.java	Thu Dec 23 02:07:09 2004
@@ -0,0 +1,131 @@
+package org.apache.axis.om.impl.seriliazer;
+
+import org.apache.axis.AbstractTestCase;
+import org.apache.axis.om.*;
+import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
+
+
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.FileReader;
+import java.io.FileOutputStream;
+import java.io.File;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 class ElementSerializerTest extends AbstractTestCase {
+    private XMLStreamReader reader;
+    private XMLStreamWriter writer;
+    private OMXMLParserWrapper builder;
+    private  File tempFile;
+    public ElementSerializerTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        reader = XMLInputFactory.newInstance().
+                createXMLStreamReader(new FileReader(getTestResourceFile("soap/soapmessage.xml")));
+        tempFile = File.createTempFile("temp","xml");
+        writer = XMLOutputFactory.newInstance().
+                createXMLStreamWriter(new FileOutputStream(tempFile));
+//        writer = XMLOutputFactory.newInstance().
+//                createXMLStreamWriter(System.out);
+        builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),reader);
+    }
+
+    public void testElementSerilization() throws Exception{
+        OMElement elt = builder.getDocumentElement();
+        elt.serialize(writer,true, null);
+
+    }
+
+    public void testElementSerilizationCacheOff() throws Exception{
+        OMElement elt = builder.getDocumentElement();
+        elt.serialize(writer,false);
+
+    }
+
+    public void testElementSerilizationChild() throws Exception{
+        OMElement elt = builder.getDocumentElement();
+        OMNode node = elt.getFirstChild().getNextSibling();
+        node.serialize(writer,true);
+
+    }
+
+    public void testElementSerilizationSOAPBodyCacheOff() throws Exception{
+        SOAPEnvelope env = (SOAPEnvelope)builder.getDocumentElement();
+        OMNode node = env.getBody();
+        node.serialize(writer,false);
+    }
+
+    public void testElement() throws Exception {
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
+                reader);
+        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
+        SOAPBody body = env.getBody();
+        body.serialize(writer,true);
+    }
+
+    public void testCompleteElement() throws Exception {
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
+                reader);
+        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
+        env.serialize(writer,true);
+    }
+
+    public void testDualNamespaces1() throws Exception {
+        OMFactory factory = OMFactory.newInstance();
+        OMNamespace ns1 = factory.createOMNamespace("bar","x");
+        OMNamespace ns2 = factory.createOMNamespace("bar","y");
+
+        OMElement root = factory.createOMElement("root",ns1);
+        OMElement elt11 = factory.createOMElement("foo1",ns1);
+        OMElement elt12 = factory.createOMElement("foo2",ns1);
+        OMElement elt21 = factory.createOMElement("yuck",ns2);
+        OMElement elt22 = factory.createOMElement("yuck",ns2);
+
+        elt11.addChild(elt21);
+        elt12.addChild(elt22);
+        root.addChild(elt11);
+        root.addChild(elt12);
+        root.serialize(writer,true);
+    }
+
+    public void testDualNamespaces2() throws Exception {
+        OMFactory factory = OMFactory.newInstance();
+
+        OMNamespace ns1 = factory.createOMNamespace("bar","x");
+        OMElement root = factory.createOMElement("root",ns1);
+        OMNamespace ns2 = root.declareNamespace("bar","y");
+        OMElement elt1 = factory.createOMElement("foo",ns1);
+        OMElement elt2 = factory.createOMElement("yuck",ns2);
+        OMText txt1 = factory.createText(elt2,"blah");
+
+        elt2.addChild(txt1);
+        elt1.addChild(elt2);
+        root.addChild(elt1);
+
+        root.serialize(writer,true);
+    }
+
+    protected void tearDown() throws Exception {
+        tempFile.delete();
+    }
+}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java	Thu Dec 23 02:07:09 2004
@@ -2,7 +2,6 @@
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.impl.llom.serialize.StreamingOMSerializer;
 import org.apache.axis.om.*;
 
@@ -11,8 +10,11 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.FileReader;
+import java.io.FileOutputStream;
+import java.util.Stack;
+
+
 
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -51,7 +53,9 @@
 
     public void testRawSerializer() throws Exception {
         StreamingOMSerializer serializer = new StreamingOMSerializer();
-        serializer.serialize(reader, writer);
+        serializer.setNamespacePrefixStack(new Stack());
+        serializer.serialize(reader,writer);
+
     }
 
     public void testElementPullStream1() throws Exception {
@@ -62,78 +66,25 @@
         serializer.serialize(env.getPullParser(false), writer);
     }
 
-    public void testElementPullStream2() throws Exception {
+     public void testElementPullStream1WithCacheOff() throws Exception {
         OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
                 reader);
         SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
-        SOAPBody body = env.getBody();
         StreamingOMSerializer serializer = new StreamingOMSerializer();
-
-        serializer.serialize(body.getPullParser(false), writer);
+        serializer.serialize(env.getPullParser(true), writer);
     }
 
-    public void testElement() throws Exception {
+    public void testElementPullStream2() throws Exception {
         OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
                 reader);
         SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
         SOAPBody body = env.getBody();
-        SimpleOMSerializer serializer = new SimpleOMSerializer();
-
-        serializer.serialize(body, writer);
-    }
-
-    public void testCompleteElement() throws Exception {
-        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
-                reader);
-        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
-        SimpleOMSerializer serializer = new SimpleOMSerializer();
-        serializer.serialize(env, writer);
-    }
-
-    public void testDualNamespaces1() throws Exception {
-        OMFactory factory = OMFactory.newInstance();
-        OMNamespace ns1 = factory.createOMNamespace("bar","x");
-        OMNamespace ns2 = factory.createOMNamespace("bar","y");
-
-        OMElement root = factory.createOMElement("root",ns1);
-        OMElement elt11 = factory.createOMElement("foo1",ns1);
-        OMElement elt12 = factory.createOMElement("foo2",ns1);
-        OMElement elt21 = factory.createOMElement("yuck",ns2);
-        OMElement elt22 = factory.createOMElement("yuck",ns2);
-
-//        OMText txt1 = factory.createText(elt2,"blah");
-
-        elt11.addChild(elt21);
-        elt12.addChild(elt22);
-        root.addChild(elt11);
-        root.addChild(elt12);
-
+        StreamingOMSerializer serializer = new StreamingOMSerializer();
 
-        SimpleOMSerializer serializer = new SimpleOMSerializer();
-        serializer.serialize(root, writer);
+        serializer.serialize(body.getPullParser(false), writer);
     }
 
-    public void testDualNamespaces2() throws Exception {
-        OMFactory factory = OMFactory.newInstance();
 
-        OMNamespace ns1 = factory.createOMNamespace("bar","x");
-        OMElement root = factory.createOMElement("root",ns1);
-
-        OMNamespace ns2 = root.declareNamespace("bar","y");
-
-        OMElement elt1 = factory.createOMElement("foo",ns1);
-        OMElement elt2 = factory.createOMElement("yuck",ns2);
-
-
-        OMText txt1 = factory.createText(elt2,"blah");
-
-        elt2.addChild(txt1);
-        elt1.addChild(elt2);
-        root.addChild(elt1);
-
-        SimpleOMSerializer serializer = new SimpleOMSerializer();
-        serializer.serialize(root, writer);
-    }
     protected void tearDown() throws Exception {
         tempFile.delete();
     }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java	Thu Dec 23 02:07:09 2004
@@ -2,7 +2,6 @@
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.om.OMFactory;
 import org.apache.axis.om.OMXMLParserWrapper;
 import org.apache.axis.om.SOAPEnvelope;
@@ -30,7 +29,6 @@
 public class OMStaxStreamingWrapperTest extends AbstractTestCase {
 
     private SOAPEnvelope envelope = null;
-    private SimpleOMSerializer serilizer;
     private File tempFile;
     private XMLStreamReader parser;
 
@@ -44,7 +42,7 @@
         OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(), xmlStreamReader);
 
         envelope = (SOAPEnvelope) builder.getDocumentElement();
-        serilizer = new SimpleOMSerializer();
+
         tempFile = File.createTempFile("temp", "xml");
 
     }
@@ -54,7 +52,7 @@
         assertNotNull(envelope);
         //this serializing will cause the OM to fully build!
         XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
-        serilizer.serialize(envelope,writer);
+        envelope.serialize(writer,true);
         parser = envelope.getPullParser(false);
         while (parser.hasNext()) {
             int event = parser.next();

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java?view=diff&rev=123182&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java&r1=123181&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java&r2=123182
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java	Thu Dec 23 02:07:09 2004
@@ -2,7 +2,6 @@
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.om.OMFactory;
 import org.apache.axis.om.OMXMLParserWrapper;
 import org.apache.axis.om.SOAPEnvelope;
@@ -35,7 +34,6 @@
 
     private OMFactory factory =null;
     private OMXMLParserWrapper builder;
-    private SimpleOMSerializer serilizer;
     private File tempFile;
 
     public OmStAXBuilderTest(String testName) {
@@ -47,8 +45,6 @@
         XMLStreamReader reader = XMLInputFactory.newInstance().
                 createXMLStreamReader(new FileReader(getTestResourceFile("soap/soapmessage.xml")));
         builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(factory,reader);
-        serilizer = new SimpleOMSerializer();
-
         tempFile = File.createTempFile("temp", "xml");
     }
 
@@ -58,7 +54,7 @@
         assertNotNull(envelope);
         XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
 //        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
-        serilizer.serialize(envelope,writer);
+        envelope.serialize(writer,true);
 
 
     }