You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sc...@apache.org on 2007/10/12 18:03:42 UTC

svn commit: r584195 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/util/ axiom-api/src/main/java/org/apache/axiom/soap/ axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/ axiom-dom/src/main/java/...

Author: scheu
Date: Fri Oct 12 09:03:40 2007
New Revision: 584195

URL: http://svn.apache.org/viewvc?rev=584195&view=rev
Log:
WSCOMMONS-258
Contributor:Rich Scheuerle
Update SOAPHeaderBlock so that it implements OMSourcedElement.
Now you can source header elements with an OMDataSource.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPHeaderBlock.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-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/CopyUtilsTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java Fri Oct 12 09:03:40 2007
@@ -256,9 +256,45 @@
     private static void copySOAPHeaderBlock(SOAPFactory factory, 
                                             OMContainer targetParent,
                                             SOAPHeaderBlock sourceSHB) {
+        // If already expanded or this is not an OMDataSourceExt, then
+        // create a copy of the OM Tree
+        OMDataSource ds = sourceSHB.getDataSource();
+        if (ds == null || 
+            sourceSHB.isExpanded() || 
+            !(ds instanceof OMDataSourceExt)) {
+            copySOAPHeaderBlock_NoDataSource(factory, targetParent, sourceSHB);
+            return;
+        }
+        
+        // If copying is destructive, then copy the OM tree
+        OMDataSourceExt sourceDS = (OMDataSourceExt) ds;
+        if (sourceDS.isDestructiveRead() ||
+            sourceDS.isDestructiveWrite()) {
+            copySOAPHeaderBlock_NoDataSource(factory, targetParent, sourceSHB);
+            return;
+        }
+        
+        // Otherwise create a copy of the OMDataSource
+        OMDataSourceExt targetDS = ((OMDataSourceExt) ds).copy();
+        SOAPHeaderBlock targetSHB =
+            factory.createSOAPHeaderBlock(sourceSHB.getLocalName(), 
+                                          sourceSHB.getNamespace(), 
+                                          targetDS);
+        targetParent.addChild(targetSHB);
+        copySOAPHeaderBlockData(sourceSHB, targetSHB);
+    }
+    
+    /**
+     * Create a copy of the SOAPHeaderBlock
+     * @param factory
+     * @param targetParent
+     * @param sourceSHB
+     */
+    private static void copySOAPHeaderBlock_NoDataSource(SOAPFactory factory, 
+                                            OMContainer targetParent,
+                                            SOAPHeaderBlock sourceSHB) {
+        
         
-        // TODO We need to consider the case where the 
-        // the SOAPHeaderBlock is also an OMSourcedElement
         SOAPHeader header = (SOAPHeader) targetParent;
         String localName = sourceSHB.getLocalName();
         OMNamespace ns = sourceSHB.getNamespace();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPFactory.java Fri Oct 12 09:03:40 2007
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap;
 
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -72,6 +73,18 @@
 
     SOAPHeaderBlock createSOAPHeaderBlock(String localName,
                                                  OMNamespace ns) throws SOAPProcessingException;
+    
+    /**
+     * Create SOAPHeaderBlock that has an OMDataSource
+     * @param localName
+     * @param ns
+     * @param ds
+     * @return SOAPHeaderBlock
+     * @throws SOAPProcessingException
+     */
+    SOAPHeaderBlock createSOAPHeaderBlock(String localName,
+                                          OMNamespace ns,
+                                          OMDataSource ds) throws SOAPProcessingException;
 
     /**
      * @param localName

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPHeaderBlock.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPHeaderBlock.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPHeaderBlock.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPHeaderBlock.java Fri Oct 12 09:03:40 2007
@@ -19,7 +19,7 @@
 
 package org.apache.axiom.soap;
 
-import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMSourcedElement;
 
 /**
  * <P>An object representing the contents in the SOAP header part of the SOAP envelope. The
@@ -27,7 +27,7 @@
  * SOAPHeaderBlock</CODE> objects.</P> <P>B <CODE>SOAPHeaderBlock</CODE> object can have other
  * <CODE>OMElement</CODE> objects as its children.</P>
  */
-public interface SOAPHeaderBlock extends OMElement {
+public interface SOAPHeaderBlock extends OMSourcedElement {
     /**
      * Sets the actor associated with this <CODE> SOAPHeaderBlock</CODE> object to the specified
      * actor.

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=584195&r1=584194&r2=584195&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 Fri Oct 12 09:03:40 2007
@@ -20,6 +20,7 @@
 package org.apache.axiom.soap.impl.dom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -114,5 +115,17 @@
 
     public void setProcessed() {
         processed = true;
+    }
+
+    public OMDataSource getDataSource() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isExpanded() {
+        throw new UnsupportedOperationException();
+    }
+
+    public OMDataSource setDataSource(OMDataSource dataSource) {
+        throw new UnsupportedOperationException();
     }
 }

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=584195&r1=584194&r2=584195&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 Fri Oct 12 09:03:40 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.axiom.soap.impl.dom.factory;
 
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.dom.DocumentImpl;
@@ -289,6 +290,10 @@
 
     public OMNamespace getNamespace() {
         throw new UnsupportedOperationException();
+    }
+
+    public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMDataSource ds) throws SOAPProcessingException {
+        throw new UnsupportedOperationException("TODO");
     }
 
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java Fri Oct 12 09:03:40 2007
@@ -23,6 +23,7 @@
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
 
 /**
  * Refer to the test, org.apache.axiom.om.OMNavigatorTest, to find out how to use features like
@@ -137,7 +138,7 @@
      * @return first child or null
      */
     private OMNode _getFirstChild(OMElement node) {
-        if (node instanceof OMSourcedElementImpl) {
+        if (node instanceof OMSourcedElement) {
             OMNode first = node.getFirstOMChild();
             OMNode sibling = first;
             while (sibling != null) {
@@ -157,7 +158,7 @@
      * @return next sibling or null
      */
     private OMNode getNextSibling(OMNode node) {
-        if (node instanceof OMSourcedElementImpl) {
+        if (node instanceof OMSourcedElement) {
             return node.getNextOMSibling();
         } else {
             // Field access is used to prevent advancing the parser.

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Fri Oct 12 09:03:40 2007
@@ -20,6 +20,7 @@
 package org.apache.axiom.om.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMDataSourceExt;
 import org.apache.axiom.om.OMElement;
@@ -69,7 +70,7 @@
     private OMNamespace definedNamespace = null;
 
     /** Flag for parser provided to base element class. */
-    private boolean isParserSet;
+    private boolean isExpanded = false;
 
     private static Log log = LogFactory.getLog(OMSourcedElementImpl.class);
     private static final boolean isDebugEnabled = log.isDebugEnabled();
@@ -89,6 +90,7 @@
         super(localName, null, factory);
         dataSource = source;
         definedNamespace = ns;
+        isExpanded = (dataSource == null);
     }
 
     /**
@@ -103,6 +105,37 @@
         super(qName.getLocalPart(), null, factory);
         dataSource = source;
         definedNamespace = new OMNamespaceImpl(qName.getNamespaceURI(), qName.getPrefix());
+        isExpanded = (dataSource == null);
+    }
+
+    public OMSourcedElementImpl(String localName, OMNamespace ns, OMContainer parent, OMFactory factory) {
+        super(localName, null, parent, factory);
+        dataSource = null;
+        definedNamespace = ns;
+        isExpanded = true;
+        if (ns != null) {
+            this.setNamespace(ns);
+        }
+    }
+
+    public OMSourcedElementImpl(String localName, OMNamespace ns, OMContainer parent, OMXMLParserWrapper builder, OMFactory factory) {
+        super(localName, null, parent, builder, factory);
+        dataSource = null;
+        definedNamespace = ns;
+        isExpanded = true;
+        if (ns != null) {
+            this.setNamespace(ns);
+        }
+    }
+
+    public OMSourcedElementImpl(String localName, OMNamespace ns, OMFactory factory) {
+        super(localName, null, factory);
+        dataSource = null;
+        definedNamespace = ns;
+        isExpanded = true;
+        if (ns != null) {
+            this.setNamespace(ns);
+        }
     }
 
     /**
@@ -146,7 +179,7 @@
      * tree on demand, this first creates a builder
      */
     private void forceExpand() {
-        if (!isParserSet) {
+        if (!isExpanded) {
 
             if (isDebugEnabled) {
                 log.debug("forceExpand: expanding element " +
@@ -196,7 +229,7 @@
             String prefix = getNamespace().getPrefix();
             
             // Set the builder for this element
-            isParserSet = true;
+            isExpanded = true;
             super.setBuilder(new StAXOMBuilder(getOMFactory(), 
                                                readerFromDS, 
                                                this, 
@@ -223,7 +256,7 @@
      * @return <code>true</code> if expanded, <code>false</code> if not
      */
     public boolean isExpanded() {
-        return isParserSet;
+        return isExpanded;
     }
 
     /* (non-Javadoc)
@@ -384,7 +417,7 @@
         if (isDebugEnabled) {
             log.debug("getting XMLStreamReader for " + getPrintableName());
         }
-        if (isParserSet) {
+        if (isExpanded) {
             return super.getXMLStreamReader();
         } else {
             if (isDestructiveRead()) {
@@ -403,7 +436,7 @@
             log.debug("getting XMLStreamReader without caching for " +
                     getPrintableName());
         }
-        if (isParserSet) {
+        if (isExpanded) {
             return super.getXMLStreamReaderWithoutCaching();
         } else {
             return getDirectReader();
@@ -853,7 +886,7 @@
      * @see org.apache.axiom.om.impl.llom.OMElementImpl#isComplete()
      */
     public boolean isComplete() {
-        if (isParserSet) {
+        if (isExpanded) {
             return super.isComplete();
         } else {
             return true;
@@ -941,7 +974,7 @@
             }
             this.dataSource = dataSource;
             setComplete(false);
-            isParserSet = false;
+            isExpanded = false;
             return oldDS;
         }
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java Fri Oct 12 09:03:40 2007
@@ -20,12 +20,14 @@
 package org.apache.axiom.soap.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMNamespaceImpl;
 import org.apache.axiom.om.impl.llom.OMAttributeImpl;
 import org.apache.axiom.om.impl.llom.OMElementImpl;
+import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
@@ -35,7 +37,7 @@
 import javax.xml.namespace.QName;
 
 /** Class SOAPHeaderBlockImpl */
-public abstract class SOAPHeaderBlockImpl extends OMElementImpl
+public abstract class SOAPHeaderBlockImpl extends OMSourcedElementImpl
         implements SOAPHeaderBlock {
 
     private boolean processed = false;
@@ -43,6 +45,11 @@
 
     public SOAPHeaderBlockImpl(String localName, OMNamespace ns, SOAPFactory factory) {
         super(localName, ns, factory);
+    }
+    
+    public SOAPHeaderBlockImpl(String localName, OMNamespace ns, SOAPFactory factory, 
+                               OMDataSource ds) {
+        super(localName, ns, factory, ds);
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java Fri Oct 12 09:03:40 2007
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap.impl.llom.soap11;
 
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMNamespaceImpl;
@@ -100,6 +101,12 @@
         return new SOAP11HeaderBlockImpl(localName, ns, this);
     }
 
+    public SOAPHeaderBlock createSOAPHeaderBlock(String localName,
+                                                 OMNamespace ns,
+                                                 OMDataSource ds) 
+        throws SOAPProcessingException {
+        return new SOAP11HeaderBlockImpl(localName, ns, this, ds);
+    }
     public SOAPHeaderBlock createSOAPHeaderBlock(String localName,
                                                  OMNamespace ns,
                                                  SOAPHeader parent,

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11HeaderBlockImpl.java Fri Oct 12 09:03:40 2007
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap.impl.llom.soap11;
 
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -36,6 +37,12 @@
     public SOAP11HeaderBlockImpl(String localName, OMNamespace ns,
                                  SOAPFactory factory) {
         super(localName, ns, factory);
+    }
+    
+    public SOAP11HeaderBlockImpl(String localName, OMNamespace ns,
+                                 SOAPFactory factory, 
+                                 OMDataSource ds) {
+        super(localName, ns, factory, ds);
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java Fri Oct 12 09:03:40 2007
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap.impl.llom.soap12;
 
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMNamespaceImpl;
@@ -164,6 +165,13 @@
     public SOAPHeaderBlock createSOAPHeaderBlock(String localName,
                                                  OMNamespace ns) throws SOAPProcessingException {
         return new SOAP12HeaderBlockImpl(localName, ns, this);
+    }
+    
+    public SOAPHeaderBlock createSOAPHeaderBlock(String localName,
+                                                 OMNamespace ns,
+                                                 OMDataSource ds) 
+        throws SOAPProcessingException {
+        return new SOAP12HeaderBlockImpl(localName, ns, this, ds);
     }
 
     //added

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12HeaderBlockImpl.java Fri Oct 12 09:03:40 2007
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap.impl.llom.soap12;
 
+import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -37,6 +38,12 @@
                                  SOAPFactory factory) {
         super(localName, ns, factory);
     }
+    
+    public SOAP12HeaderBlockImpl(String localName, OMNamespace ns,
+                                 SOAPFactory factory, OMDataSource ds) {
+        super(localName, ns, factory, ds);
+    }
+    
     /**
      * Eran Chinthaka (chinthaka@apache.org)
      */

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/CopyUtilsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/CopyUtilsTest.java?rev=584195&r1=584194&r2=584195&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/CopyUtilsTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/CopyUtilsTest.java Fri Oct 12 09:03:40 2007
@@ -25,6 +25,9 @@
 import org.apache.axiom.om.ds.ByteArrayDataSource;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 
 import javax.xml.stream.XMLInputFactory;
@@ -93,6 +96,37 @@
         OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
         body.addChild(omse);
         copyAndCheck(sourceEnv, true);
+    }
+    
+    public void testOMSE2() throws Exception {
+        File file = getTestResourceFile(TestConstants.EMPTY_BODY_MESSAGE);
+        SOAPEnvelope sourceEnv = createEnvelope(file);
+        SOAPBody body = sourceEnv.getBody();
+        SOAPHeader header = sourceEnv.getHeader();
+        String encoding = "UTF-8";
+        
+        // Create a header OMSE
+        String hdrText = "<hdr:myheader xmlns:hdr=\"urn://test\">Hello World</hdr:myheader>";
+        ByteArrayDataSource badsHdr = 
+            new ByteArrayDataSource(hdrText.getBytes(encoding), encoding);
+        OMNamespace hdrNS = header.getOMFactory().createOMNamespace("urn://test", "hdr");
+        SOAPFactory sf = (SOAPFactory) header.getOMFactory();
+        SOAPHeaderBlock shb = sf.createSOAPHeaderBlock("myheader", hdrNS, badsHdr);
+        shb.setProcessed();  // test setting processing flag
+        header.addChild(shb);
+        
+        // Create a payload
+        String text = "<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>";
+        ByteArrayDataSource bads = new ByteArrayDataSource(text.getBytes(encoding), encoding);
+        OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
+        OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
+        body.addChild(omse);
+        
+        copyAndCheck(sourceEnv, true);
+        
+        // The source SOAPHeaderBlock should not be expanded in the process
+        assertTrue(shb.isExpanded() == false);
+        
     }
     
     /**



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