Author: veithen
Date: Thu Apr 12 21:46:18 2012
New Revision: 1325537

URL: http://svn.apache.org/viewvc?rev=1325537&view=rev
Log:
AXIOM-412:
* Made OMDOMFactory stateless.
* Implemented rule (2).
* Partially implemented rule (4).
* Implemented rule (5). 

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestAddAttributeReplace.java
      - copied unchanged from r1325526, 
webservices/axiom/branches/AXIOM-412/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestAddAttributeReplace.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttribute.java
      - copied unchanged from r1325526, 
webservices/axiom/branches/AXIOM-412/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestRemoveAttribute.java
Modified:
    webservices/commons/trunk/modules/axiom/   (props changed)
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java

Propchange: webservices/commons/trunk/modules/axiom/
------------------------------------------------------------------------------
  Merged /webservices/axiom/branches/AXIOM-412:r1311325-1325526

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
 Thu Apr 12 21:46:18 2012
@@ -188,10 +188,14 @@ public class AttrImpl extends NodeImpl i
         return owner instanceof ElementImpl ? (Element)owner : null;
     }
 
-    void setOwnerElement(ElementImpl element) {
+    void setOwnerElement(ElementImpl element, boolean useDomSemantics) {
         if (element == null) {
             if (owner instanceof ElementImpl) {
-                owner = ((ElementImpl)owner).ownerDocument();
+                if (useDomSemantics) {
+                    owner = ((ElementImpl)owner).ownerDocument();
+                } else {
+                    owner = null;
+                }
             }
         } else {
             owner = element;

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
 Thu Apr 12 21:46:18 2012
@@ -140,7 +140,7 @@ public class AttributeMap implements Nam
             // same element
         }
 
-        attr.setOwnerElement((ElementImpl)this.ownerNode); // Set the owner 
node
+        attr.setOwnerElement((ElementImpl)this.ownerNode, true); // Set the 
owner node
         attr.setUsed(true); // Setting used to true
 
         int i = findNamePoint(attr.getNodeName(), 0);
@@ -149,7 +149,7 @@ public class AttributeMap implements Nam
         if (i >= 0) { // There's an attribute already with this attr's name
             previous = (AttrImpl) nodes.elementAt(i);
             nodes.setElementAt(attr, i);
-            previous.setOwnerElement(null);
+            previous.setOwnerElement(null, true);
 
             // make sure it won't be mistaken with defaults in case it's reused
             previous.isSpecified(true);
@@ -169,9 +169,13 @@ public class AttributeMap implements Nam
 
     }
 
-    /** Almost a copy of the Xerces impl. */
     public Node setNamedItemNS(Node attribute) throws DOMException {
         ownerNode.checkSameOwnerDocument(attribute);
+        return setAttribute(attribute, true);
+    }
+    
+    /** Almost a copy of the Xerces impl. */
+    Node setAttribute(Node attribute, boolean useDomSemantics) throws 
DOMException {
         if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
             String msg = DOMMessageFormatter.formatMessage(
                     DOMMessageFormatter.DOM_DOMAIN, 
DOMException.HIERARCHY_REQUEST_ERR,
@@ -192,7 +196,7 @@ public class AttributeMap implements Nam
             // same element
         }
         //Set the owner node
-        attr.setOwnerElement((ElementImpl)this.ownerNode);
+        attr.setOwnerElement((ElementImpl)this.ownerNode, useDomSemantics);
 
         int i = findNamePoint(attr.getNamespaceURI(), attr.getLocalName());
         AttrImpl previous = null;
@@ -200,7 +204,7 @@ public class AttributeMap implements Nam
         if (i >= 0) {
             previous = (AttrImpl) nodes.elementAt(i);
             nodes.setElementAt(attr, i);
-            previous.setOwnerElement(null);
+            previous.setOwnerElement(null, useDomSemantics);
             // make sure it won't be mistaken with defaults in case it's reused
             previous.isSpecified(true);
         } else {
@@ -249,7 +253,7 @@ public class AttributeMap implements Nam
                     AttrImpl clone = (AttrImpl) n.cloneNode(true);
                     clone.isSpecified(n.isSpecified());
                     nodes.setElementAt(clone, i);
-                    clone.setOwnerElement(ownerNode);
+                    clone.setOwnerElement(ownerNode, true);
                 }
             }
         }
@@ -428,9 +432,9 @@ public class AttributeMap implements Nam
         }
     }
     
-    void remove(AttrImpl attr) {
+    void remove(AttrImpl attr, boolean useDomSemantics) {
         if (nodes.remove(attr)) {
-            attr.setOwnerElement(null);
+            attr.setOwnerElement(null, useDomSemantics);
         }
     }
 }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
 Thu Apr 12 21:46:18 2012
@@ -67,7 +67,12 @@ public abstract class ChildNode extends 
      * @return the owner document
      */
     DocumentImpl ownerDocument() {
-        if (ownerNode instanceof DocumentImpl) {
+        if (ownerNode == null) {
+            // TODO: it is currently unspecified/untested if the factory 
should be inherited from the root node or if it should always be a plain 
OMFactory
+            DocumentImpl document = new DocumentImpl(factory);
+            ownerNode = document;
+            return document;
+        } else if (ownerNode instanceof DocumentImpl) {
             // Note: the value of the HAS_PARENT flag doesn't matter here. If 
the ownerNode is of
             // type Document, it must be the owner document.
             return (DocumentImpl)ownerNode;

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
 Thu Apr 12 21:46:18 2012
@@ -40,7 +40,6 @@ public class DOMImplementationImpl imple
         // TODO Handle docType stuff
         OMDOMFactory fac = new OMDOMFactory();
         DocumentImpl doc = new DocumentImpl(fac);
-        fac.setDocument(doc);
 
         new ElementImpl(doc, DOMUtil.getLocalName(qualifiedName),
                         new OMNamespaceImpl(namespaceURI, DOMUtil

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
 Thu Apr 12 21:46:18 2012
@@ -33,7 +33,6 @@ import org.apache.axiom.om.impl.MTOMXMLS
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.common.OMDocumentImplUtil;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
@@ -78,19 +77,16 @@ public class DocumentImpl extends Parent
     /** @param ownerDocument  */
     public DocumentImpl(DocumentImpl ownerDocument, OMFactory factory) {
         super(ownerDocument, factory);
-        ((OMDOMFactory) factory).setDocument(this);
         this.done = true;
     }
 
     public DocumentImpl(OMXMLParserWrapper parserWrapper, OMFactory factory) {
         super(factory);
         this.builder = parserWrapper;
-        ((OMDOMFactory) factory).setDocument(this);
     }
 
     public DocumentImpl(OMFactory factory) {
         super(factory);
-        ((OMDOMFactory) factory).setDocument(this);
         this.done = true;
     }
 

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 Thu Apr 12 21:46:18 2012
@@ -33,7 +33,6 @@ import org.apache.axiom.om.impl.common.N
 import org.apache.axiom.om.impl.common.OMChildElementIterator;
 import org.apache.axiom.om.impl.common.OMElementImplUtil;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.apache.axiom.om.impl.traverse.OMQNameFilterIterator;
 import org.apache.axiom.om.impl.traverse.OMQualifiedNameFilterIterator;
 import org.apache.axiom.om.impl.util.EmptyIterator;
@@ -140,7 +139,7 @@ public class ElementImpl extends ParentN
 
     public ElementImpl(ParentNode parentNode, String tagName, OMNamespaceImpl 
ns,
                        OMFactory factory) {
-        this((DocumentImpl) parentNode.getOwnerDocument(), tagName, null, 
factory);
+        this(null, tagName, null, factory);
         parentNode.addChild(this);
         this.done = true;
         namespace = handleNamespace(ns);
@@ -168,7 +167,6 @@ public class ElementImpl extends ParentN
 
     public ElementImpl(OMFactory factory) {
         super(factory);
-        setOwnerDocument(((OMDOMFactory) factory).getDocument());
     }
 
     private OMNamespace handleNamespace(OMNamespace ns) {
@@ -339,7 +337,7 @@ public class ElementImpl extends ParentN
                     DOMMessageFormatter.DOM_DOMAIN, 
DOMException.NOT_FOUND_ERR, null);
             throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
         }
-        attributes.remove((AttrImpl)oldAttr);
+        attributes.remove((AttrImpl)oldAttr, true);
         return oldAttr;
     }
 
@@ -486,12 +484,11 @@ public class ElementImpl extends ParentN
 
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
-     */
     public Attr setAttributeNodeNS(Attr attr) throws DOMException {
+        return setAttributeNodeNS(attr, true);
+    }
+    
+    private Attr setAttributeNodeNS(Attr attr, boolean useDomSemantics) throws 
DOMException {
 
         // Check whether the attr is a namespace declaration
         // if so add a namespace NOT an attribute
@@ -502,7 +499,9 @@ public class ElementImpl extends ParentN
         } else {
             AttrImpl attrImpl = (AttrImpl) attr;
 
-            checkSameOwnerDocument(attr);
+            if (useDomSemantics) {
+                checkSameOwnerDocument(attr);
+            }
 
             // check whether the attr is in use
             if (attrImpl.isUsed()) {
@@ -526,7 +525,7 @@ public class ElementImpl extends ParentN
                                                         attr.getPrefix()));
             }
 
-            return (Attr) this.attributes.setNamedItemNS(attr);
+            return (Attr) this.attributes.setAttribute(attr, useDomSemantics);
         }
     }
 
@@ -671,7 +670,8 @@ public class ElementImpl extends ParentN
             if (owner == this) {
                 return attr;
             }
-            attr = (OMAttribute)((AttrImpl)attr).cloneNode(false);
+            attr = new AttrImpl(null, attr.getLocalName(), attr.getNamespace(),
+                    attr.getAttributeValue(), attr.getOMFactory());
         }
         
         OMNamespace namespace = attr.getNamespace();
@@ -686,7 +686,7 @@ public class ElementImpl extends ParentN
             }
         }
 
-        this.setAttributeNodeNS((Attr) attr);
+        this.setAttributeNodeNS((Attr) attr, false);
         return attr;
     }
 
@@ -702,7 +702,7 @@ public class ElementImpl extends ParentN
                 }
             }
         }
-        return addAttribute(new AttrImpl(ownerDocument(), localName, ns, 
value, factory));
+        return addAttribute(new AttrImpl(null, localName, ns, value, factory));
     }
 
     public OMNamespace addNamespaceDeclaration(String uri, String prefix) {
@@ -976,7 +976,7 @@ public class ElementImpl extends ParentN
         if (attr.getOwner() != this) {
             throw new OMException("The attribute is not owned by this 
element");
         }
-        attributes.remove((AttrImpl)attr);
+        attributes.remove((AttrImpl)attr, false);
     }
 
     /**

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
 Thu Apr 12 21:46:18 2012
@@ -56,29 +56,10 @@ import javax.xml.namespace.QName;
 /**
  * OM factory implementation for DOOM. It creates nodes that implement
  * DOM as defined by the interfaces in {@link org.w3c.dom}.
- * <p>
- * Since DOM requires every node to have an owner document even if it has not 
yet
- * been added to a tree, this factory internally maintains a reference to a
- * {@link DocumentImpl} instance. The document can be set explicitly using the
- * {@link #OMDOMFactory(DocumentImpl)} constructor or the {@link 
#setDocument(DocumentImpl)}
- * method. If none is set, it will be implicitly created when the first node 
is created.
- * All nodes created by this factory will have this {@link DocumentImpl} 
instance as owner
- * document.
- * <p>
- * This has several important consequences:
- * <ul>
- *   <li>The same instance of this class should not be used to parse or 
construct
- *       multiple documents unless {@link #setDocument(DocumentImpl)} is used
- *       to reset the {@link DocumentImpl} instance before processing the next 
document.</li>
- *   <li>Instances of this class are not thread safe and using a single 
instance concurrently
- *       will lead to undefined results.</li>
- * </ul>
  */
 public class OMDOMFactory implements OMFactory {
     private final OMDOMMetaFactory metaFactory;
 
-    protected DocumentImpl document;
-
     public OMDOMFactory(OMDOMMetaFactory metaFactory) {
         this.metaFactory = metaFactory;
     }
@@ -87,41 +68,23 @@ public class OMDOMFactory implements OMF
         this(new OMDOMMetaFactory());
     }
 
-    public OMDOMFactory(DocumentImpl doc) {
-        this(new OMDOMMetaFactory());
-        this.document = doc;
-    }
-
     public OMMetaFactory getMetaFactory() {
         return metaFactory;
     }
 
     public OMDocument createOMDocument() {
-        if (this.document == null)
-            this.document = new DocumentImpl(this);
-
-        return this.document;
-    }
-
-    /**
-     * Configure this factory to use the given document. Use with care.
-     *
-     * @param document
-     */
-    public void setDocument(DocumentImpl document) {
-        this.document = document;
+        return new DocumentImpl(this);
     }
 
     public OMElement createOMElement(String localName, OMNamespace ns) {
-        return new ElementImpl((DocumentImpl) this.createOMDocument(),
+        return new ElementImpl(null,
                                localName, (OMNamespaceImpl) ns, this);
     }
 
     public OMElement createOMElement(String localName, OMNamespace ns,
                                      OMContainer parent) throws OMDOMException 
{
         if (parent == null) {
-            return new ElementImpl((DocumentImpl) this.createOMDocument(),
-                               localName, (OMNamespaceImpl) ns, this);
+            return createOMElement(localName, ns);
         } else {
             return new ElementImpl((ParentNode) parent, localName, 
(OMNamespaceImpl) ns, this);
         }
@@ -234,12 +197,11 @@ public class OMDOMFactory implements OMF
             throw new OMHierarchyException(
                     "DOM doesn't support text nodes as children of a 
document");
         } else {
-            DocumentImpl ownerDocument = 
(DocumentImpl)((ElementImpl)parent).getOwnerDocument(); 
             TextNodeImpl txt;
             if (type == OMNode.CDATA_SECTION_NODE) {
-                txt = new CDATASectionImpl(ownerDocument, text, this);
+                txt = new CDATASectionImpl(null, text, this);
             } else {
-                txt = new TextImpl(ownerDocument, text, type, this);
+                txt = new TextImpl(null, text, type, this);
             }
             parent.addChild(txt);
             return txt;
@@ -252,10 +214,8 @@ public class OMDOMFactory implements OMF
     }
 
     public OMText createOMText(OMContainer parent, char[] charArary, int type) 
{
-        ElementImpl parentElem = (ElementImpl) parent;
-        TextImpl txt = new TextImpl((DocumentImpl) parentElem
-                .getOwnerDocument(), charArary, this);
-        parentElem.addChild(txt);
+        TextImpl txt = new TextImpl(null, charArary, this);
+        parent.addChild(txt);
         return txt;
     }
 
@@ -265,7 +225,7 @@ public class OMDOMFactory implements OMF
      * @see org.apache.axiom.om.OMFactory#createOMText(String)
      */
     public OMText createOMText(String s) {
-        return new TextImpl(this.document, s, this);
+        return new TextImpl(null, s, this);
     }
 
     /**
@@ -275,9 +235,9 @@ public class OMDOMFactory implements OMF
      */
     public OMText createOMText(String text, int type) {
         if (type == OMNode.CDATA_SECTION_NODE) {
-            return new CDATASectionImpl(document, text, this);
+            return new CDATASectionImpl(null, text, this);
         } else {
-            return new TextImpl(document, text, this);
+            return new TextImpl(null, text, this);
         }
     }
 
@@ -288,7 +248,7 @@ public class OMDOMFactory implements OMF
      * @see org.apache.axiom.om.OMFactory#createOMText(String, String, boolean)
      */
     public OMText createOMText(String text, String mimeType, boolean optimize) 
{
-        return new TextImpl(this.document, text, mimeType, optimize, this);
+        return new TextImpl(null, text, mimeType, optimize, this);
     }
 
     /**
@@ -298,12 +258,12 @@ public class OMDOMFactory implements OMF
      * @see org.apache.axiom.om.OMFactory#createOMText(Object, boolean)
      */
     public OMText createOMText(Object dataHandler, boolean optimize) {
-        return new TextImpl(this.document, dataHandler, optimize, this);
+        return new TextImpl(null, dataHandler, optimize, this);
     }
 
     public OMText createOMText(String contentID, DataHandlerProvider 
dataHandlerProvider,
             boolean optimize) {
-        return new TextImpl(this.document, contentID, dataHandlerProvider, 
optimize, this);
+        return new TextImpl(null, contentID, dataHandlerProvider, optimize, 
this);
     }
 
     /**
@@ -314,8 +274,7 @@ public class OMDOMFactory implements OMF
      */
     public OMText createOMText(OMContainer parent, String s, String mimeType,
                                boolean optimize) {
-        TextImpl text = new TextImpl((DocumentImpl) ((ElementImpl) parent)
-                .getOwnerDocument(), s, mimeType, optimize, this);
+        TextImpl text = new TextImpl(null, s, mimeType, optimize, this);
         parent.addChild(text);
         return text;
     }
@@ -337,11 +296,11 @@ public class OMDOMFactory implements OMF
                 ns = new OMNamespaceImpl(namespaceURI, 
OMSerializerUtil.getNextNSPrefix());
             }
         }
-        return new AttrImpl(this.getDocument(), localName, ns, value, this);
+        return new AttrImpl(null, localName, ns, value, this);
     }
 
     public OMDocType createOMDocType(OMContainer parent, String content) {
-        DocumentTypeImpl docType = new DocumentTypeImpl(this.getDocument(), 
this);
+        DocumentTypeImpl docType = new DocumentTypeImpl(null, this);
         docType.setValue(content);
         parent.addChild(docType);
         return docType;
@@ -350,7 +309,7 @@ public class OMDOMFactory implements OMF
     public OMProcessingInstruction createOMProcessingInstruction(
             OMContainer parent, String piTarget, String piData) {
         ProcessingInstructionImpl pi =
-            new ProcessingInstructionImpl(getDocumentFromParent(parent), 
piTarget, piData, this);
+            new ProcessingInstructionImpl(null, piTarget, piData, this);
         if (parent != null) {
             parent.addChild(pi);
         }
@@ -358,30 +317,14 @@ public class OMDOMFactory implements OMF
     }
 
     public OMComment createOMComment(OMContainer parent, String content) {
-        CommentImpl comment = new CommentImpl(getDocumentFromParent(parent), 
content, this);
+        CommentImpl comment = new CommentImpl(null, content, this);
         if (parent != null) {
             parent.addChild(comment);
         }
         return comment;
     }
 
-    public DocumentImpl getDocument() {
-        return (DocumentImpl) this.createOMDocument();
-    }
-
     public OMDocument createOMDocument(OMXMLParserWrapper builder) {
-        this.document = new DocumentImpl(builder, this);
-        return this.document;
-    }
-
-    private DocumentImpl getDocumentFromParent(OMContainer parent) {
-        if (parent == null) {
-            // TODO: this is really a hack; we should make OMDOMFactory 
stateless
-            return (DocumentImpl)createOMDocument();
-        } else if (parent instanceof DocumentImpl) {
-            return (DocumentImpl) parent;
-        } else {
-            return (DocumentImpl) ((ParentNode) parent).getOwnerDocument();
-        }
+        return new DocumentImpl(builder, this);
     }
 }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
 Thu Apr 12 21:46:18 2012
@@ -41,7 +41,6 @@ import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.SOAPVersion;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axiom.soap.impl.dom.factory.DOMSOAPFactory;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
 
@@ -69,8 +68,7 @@ public class SOAPEnvelopeImpl extends SO
 
     /** @param ns  */
     public SOAPEnvelopeImpl(OMNamespace ns, SOAPFactory factory) {
-        super(((DOMSOAPFactory) factory).getDocument(),
-              SOAPConstants.SOAPENVELOPE_LOCAL_NAME, ns, factory);
+        super(null, SOAPConstants.SOAPENVELOPE_LOCAL_NAME, ns, factory);
     }
 
     public SOAPVersion getVersion() {

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
 Thu Apr 12 21:46:18 2012
@@ -29,7 +29,6 @@ import org.apache.axiom.om.impl.dom.Attr
 import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.ElementImpl;
 import org.apache.axiom.om.impl.dom.ParentNode;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
@@ -56,7 +55,7 @@ public abstract class SOAPHeaderBlockImp
 
     public SOAPHeaderBlockImpl(String localName, OMNamespace ns,
                                SOAPFactory factory) throws 
SOAPProcessingException {
-        super(((OMDOMFactory) factory).getDocument(), localName, 
(OMNamespaceImpl) ns, factory);
+        super(null, localName, (OMNamespaceImpl) ns, factory);
         this.setNamespace(ns);
     }
 

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
 Thu Apr 12 21:46:18 2012
@@ -52,20 +52,12 @@ public abstract class DOMSOAPFactory ext
     public DOMSOAPFactory() {
     }
 
-    public DOMSOAPFactory(DocumentImpl doc) {
-        super(doc);
-    }
-
     public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
-        SOAPMessageImpl messageImpl = new SOAPMessageImpl(builder, this);
-        this.document = messageImpl;
-        return messageImpl;
+        return new SOAPMessageImpl(builder, this);
     }
 
     public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, 
OMXMLParserWrapper parserWrapper) {
-        SOAPMessageImpl messageImpl = new SOAPMessageImpl(envelope, 
parserWrapper, this);
-        this.document = messageImpl;
-        return messageImpl;
+        return new SOAPMessageImpl(envelope, parserWrapper, this);
     }
 
     public SOAPEnvelope createSOAPEnvelope(OMXMLParserWrapper builder) {

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java
 Thu Apr 12 21:46:18 2012
@@ -22,7 +22,6 @@ package org.apache.axiom.soap.impl.dom.s
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAPBody;
@@ -55,10 +54,6 @@ public class SOAP11Factory extends DOMSO
     public SOAP11Factory() {
     }
 
-    public SOAP11Factory(DocumentImpl doc) {
-        super(doc);
-    }
-
     public String getSoapVersionURI() {
         return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
     }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java
 Thu Apr 12 21:46:18 2012
@@ -22,7 +22,6 @@ package org.apache.axiom.soap.impl.dom.s
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPBody;
@@ -54,10 +53,6 @@ public class SOAP12Factory extends DOMSO
     public SOAP12Factory() {
     }
 
-    public SOAP12Factory(DocumentImpl doc) {
-        super(doc);
-    }
-
     public String getSoapVersionURI() {
         return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
     }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1325537&r1=1325536&r2=1325537&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
 Thu Apr 12 21:46:18 2012
@@ -37,8 +37,10 @@ public class OMDOMTestSuiteBuilder exten
     protected void addTests() {
         addTest(new 
org.apache.axiom.ts.omdom.attr.TestGetNamespaceNormalized(metaFactory));
         addTest(new 
org.apache.axiom.ts.omdom.document.TestImportNode(metaFactory));
+        addTest(new 
org.apache.axiom.ts.omdom.element.TestAddAttributeReplace(metaFactory));
         addTest(new 
org.apache.axiom.ts.omdom.element.TestAddChildFromForeignDocument(metaFactory));
         addTest(new 
org.apache.axiom.ts.omdom.element.TestGetNamespaceNormalized(metaFactory));
+        addTest(new 
org.apache.axiom.ts.omdom.element.TestRemoveAttribute(metaFactory));
         addTest(new 
org.apache.axiom.ts.omdom.element.TestRemoveChildIncomplete(metaFactory));
         addTest(new 
org.apache.axiom.ts.omdom.factory.TestCreateOMTextCDATASection(metaFactory));
         addTest(new 
org.apache.axiom.ts.omdom.factory.TestCreateOMTextCDATASectionWithParent(metaFactory));


Reply via email to