cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/2] cxf git commit: Optimizations to keep RM Objects as objects instead of converting to DOM
Date Thu, 08 Jun 2017 15:29:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 7054ae68a -> 3d85f3179


Optimizations to keep RM Objects as objects instead of converting to DOM


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3d85f317
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3d85f317
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3d85f317

Branch: refs/heads/master
Commit: 3d85f3179ffae6eadd5174ace6df015494d995bc
Parents: 4fb0711
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Jun 8 11:27:58 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Jun 8 11:28:25 2017 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/binding/soap/SoapHeader.java |  9 +++
 rt/ws/rm/pom.xml                                | 12 +++
 .../org/apache/cxf/ws/rm/EncoderDecoder.java    | 82 ++++++++++----------
 .../apache/cxf/ws/rm/EncoderDecoder10AImpl.java | 28 ++++---
 .../apache/cxf/ws/rm/EncoderDecoder10Impl.java  | 29 ++++---
 .../apache/cxf/ws/rm/EncoderDecoder11Impl.java  | 24 ++++--
 .../cxf/ws/rm/soap/RMSoapOutInterceptor.java    | 41 ++--------
 .../apache/cxf/ws/rm/v200502/package-info.java  | 25 ++++++
 .../cxf/ws/rm/v200502wsa15/package-info.java    | 25 ++++++
 .../apache/cxf/ws/rm/v200702/package-info.java  | 25 ++++++
 .../ws/rm/soap/RMSoapOutInterceptorTest.java    | 54 +++++--------
 11 files changed, 220 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapHeader.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapHeader.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapHeader.java
index ecf88fb..356d0f9 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapHeader.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapHeader.java
@@ -33,6 +33,15 @@ public class SoapHeader extends Header {
     public SoapHeader(QName q, Object o, DataBinding b) {
         super(q, o, b);
     }
+    public SoapHeader(QName q, Object o, DataBinding b, boolean mustUnderstand, String actor)
{
+        super(q, o, b);
+        this.mustUnderstand = mustUnderstand;
+        this.actor = actor;
+    }
+    public SoapHeader(QName q, Object o, DataBinding b, boolean mustUnderstand) {
+        super(q, o, b);
+        this.mustUnderstand = mustUnderstand;
+    }
 
     public String getActor() {
         return actor;

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/rm/pom.xml b/rt/ws/rm/pom.xml
index 1e05711..3b0b7c0 100644
--- a/rt/ws/rm/pom.xml
+++ b/rt/ws/rm/pom.xml
@@ -170,6 +170,9 @@
                                     <deleteDirs>
                                         <deleteDir>${basedir}/target/generated/src/main/java/org/apache/cxf/ws/addressing</deleteDir>
                                     </deleteDirs>
+                                    <extensionArgs>
+                                        <extensionArg>-npa</extensionArg>
+                                    </extensionArgs>
                                 </xsdOption>
                                 <xsdOption>
                                     <xsd>${basedir}/src/main/resources/schemas/wsdl/wsrm-1.0-wsa15.xsd</xsd>
@@ -178,6 +181,9 @@
                                     <deleteDirs>
                                         <deleteDir>${basedir}/target/generated/src/main/java/org/apache/cxf/ws/addressing</deleteDir>
                                     </deleteDirs>
+                                    <extensionArgs>
+                                        <extensionArg>-npa</extensionArg>
+                                    </extensionArgs>
                                 </xsdOption>
                                 <xsdOption>
                                     <xsd>${basedir}/src/main/resources/schemas/wsdl/wsrm-1.1.xsd</xsd>
@@ -186,6 +192,9 @@
                                     <deleteDirs>
                                         <deleteDir>${basedir}/target/generated/src/main/java/org/apache/cxf/ws/addressing</deleteDir>
                                     </deleteDirs>
+                                    <extensionArgs>
+                                        <extensionArg>-npa</extensionArg>
+                                    </extensionArgs>
                                 </xsdOption>
                                 <xsdOption>
                                     <xsd>${basedir}/src/main/resources/schemas/wsdl/wsmc-1.1.xsd</xsd>
@@ -194,6 +203,9 @@
                                     <deleteDirs>
                                         <deleteDir>${basedir}/target/generated/src/main/java/org/apache/cxf/ws/addressing</deleteDir>
                                     </deleteDirs>
+                                    <extensionArgs>
+                                        <extensionArg>-npa</extensionArg>
+                                    </extensionArgs>
                                 </xsdOption>
                                 <xsdOption>
                                     <xsd>${basedir}/src/main/resources/schemas/configuration/wsrm-manager-types.xsd</xsd>

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder.java
index 68c42ea..3717a18 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder.java
@@ -20,17 +20,18 @@
 package org.apache.cxf.ws.rm;
 
 import java.util.Collection;
+import java.util.List;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.ws.rm.v200702.AckRequestedType;
 import org.apache.cxf.ws.rm.v200702.CloseSequenceType;
 import org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType;
@@ -45,7 +46,8 @@ import org.apache.cxf.ws.rm.v200702.TerminateSequenceType;
  * encoding and decoding.
  */
 public abstract class EncoderDecoder {
-
+    protected volatile DataBinding databinding;
+    
     /**
      * Get context for JAXB marshalling/unmarshalling.
      *
@@ -53,6 +55,7 @@ public abstract class EncoderDecoder {
      * @throws JAXBException
      */
     protected abstract JAXBContext getContext() throws JAXBException;
+        
 
     /**
      * Get the WS-ReliableMessaging namespace used by this encoder/decoder.
@@ -103,6 +106,26 @@ public abstract class EncoderDecoder {
      */
     public abstract Class<?> getTerminateSequenceResponseType();
 
+    
+    /**
+     * Get the databinding used for the header objects
+     * @return databinding
+     */
+    protected DataBinding getDataBinding() throws JAXBException {
+        DataBinding result = databinding;
+        if (result == null) {
+            synchronized (this) {
+                result = databinding;
+                if (result == null) {
+                    result = new JAXBDataBinding(getContext());
+                    databinding = result;
+                }
+            }
+        }
+        return result;
+    }
+
+    
     /**
      * Builds an element containing WS-RM headers. This adds the appropriate WS-RM namespace
declaration to the element,
      * and then adds any WS-RM headers set in the supplied properties as child elements.
@@ -111,38 +134,20 @@ public abstract class EncoderDecoder {
      * @param qname constructed element name
      * @return element (<code>null</code> if none)
      */
-    public Element buildHeaders(RMProperties rmps, QName qname) throws JAXBException {
+    public void buildHeaders(RMProperties rmps, List<Header> headers) throws JAXBException
{
 
         // check if there's anything to insert
         SequenceType seq = rmps.getSequence();
         Collection<SequenceAcknowledgement> acks = rmps.getAcks();
         Collection<AckRequestedType> reqs = rmps.getAcksRequested();
         if (seq == null && acks == null && reqs == null) {
-            return null;
+            return;
         }
 
-        // create element with namespace declaration included
-        Document doc = DOMUtils.createDocument();
-        Element header = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
-        addNamespaceDecl(header);
-
         // build individual headers
         Marshaller marshaller = getContext().createMarshaller();
         marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
-        buildHeaders(seq, acks, reqs, rmps.isLastMessage(), header, marshaller);
-        return header;
-    }
-
-    /**
-     * Add WS-RM namespace declaration to element.
-     *
-     * @param element
-     */
-    protected void addNamespaceDecl(Element element) {
-        Attr attr = element.getOwnerDocument().createAttributeNS("http://www.w3.org/2000/xmlns/",
-            "xmlns:" + RMConstants.NAMESPACE_PREFIX);
-        attr.setValue(getWSRMNamespace());
-        element.setAttributeNodeNS(attr);
+        buildHeaders(seq, acks, reqs, rmps.isLastMessage(), headers);
     }
 
     /**
@@ -153,18 +158,12 @@ public abstract class EncoderDecoder {
      * @param qname constructed element name
      * @return element
      */
-    public Element buildHeaderFault(SequenceFault sf, QName qname) throws JAXBException {
-
-        // create element with namespace declaration included
-        Document doc = DOMUtils.createDocument();
-        Element header = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
-        addNamespaceDecl(header);
-
-        // insert the actual fault
-        Marshaller marshaller = getContext().createMarshaller();
-        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
-        buildHeaderFault(sf, header, marshaller);
-        return header;
+    public Header buildHeaderFault(SequenceFault sf) throws JAXBException {
+        Object o = buildHeaderFaultObject(sf);
+        
+        return new Header(new QName(getConstants().getWSRMNamespace(),
+                                    RMConstants.SEQUENCE_FAULT_NAME),
+                          o, getDataBinding());
     }
 
     /**
@@ -179,18 +178,15 @@ public abstract class EncoderDecoder {
      * @throws JAXBException
      */
     protected abstract void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement>
acks,
-        Collection<AckRequestedType> reqs, boolean last, Element header, Marshaller
marshaller) throws JAXBException;
+        Collection<AckRequestedType> reqs, boolean last, List<Header> headers)
throws JAXBException;
 
     /**
      * Build a header fault, using the correct protocol variation.
      *
      * @param sf
-     * @param header
-     * @param marshaller
-     * @throws JAXBException
+     * @return the object marshallable with the JAXContext 
      */
-    protected abstract void buildHeaderFault(SequenceFault sf, Element header, Marshaller
marshaller)
-        throws JAXBException;
+    protected abstract Object buildHeaderFaultObject(SequenceFault sf);
 
     /**
      * Marshals a SequenceAcknowledgement to the appropriate external form.

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10AImpl.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10AImpl.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10AImpl.java
index 084e9db..16ff41b 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10AImpl.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10AImpl.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.rm;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -29,12 +30,15 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.headers.Header;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.ws.addressing.Names;
 import org.apache.cxf.ws.rm.v200702.AckRequestedType;
@@ -105,8 +109,10 @@ public final class EncoderDecoder10AImpl extends EncoderDecoder {
         return jaxbContext;
     }
 
+    @Override
     protected void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement>
acks,
-        Collection<AckRequestedType> reqs, boolean last, Element header, Marshaller
marshaller) throws JAXBException {
+        Collection<AckRequestedType> reqs, boolean last, List<Header> headers)
throws JAXBException {
+       
         if (null != seq) {
             LOG.log(Level.FINE, "encoding sequence into RM header");
             org.apache.cxf.ws.rm.v200502wsa15.SequenceType toseq = VersionTransformer.convert200502wsa15(seq);
@@ -115,24 +121,30 @@ public final class EncoderDecoder10AImpl extends EncoderDecoder {
             }
             JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceType> element
                 = RMUtils.getWSRM200502WSA200508Factory().createSequence(toseq);
-            marshaller.marshal(element, header);
+            headers.add(new SoapHeader(element.getName(), element, getDataBinding(), true));
         }
         if (null != acks) {
             LOG.log(Level.FINE, "encoding sequence acknowledgement(s) into RM header");
             for (SequenceAcknowledgement ack : acks) {
-                marshaller.marshal(VersionTransformer.convert200502wsa15(ack), header);
+                headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), 
+                                                     RMConstants.SEQUENCE_ACK_NAME),
+                                           VersionTransformer.convert200502wsa15(ack), getDataBinding()));
             }
         }
         if (null != reqs) {
             LOG.log(Level.FINE, "encoding acknowledgement request(s) into RM header");
             for (AckRequestedType req : reqs) {
-                marshaller.marshal(RMUtils.getWSRM200502WSA200508Factory()
-                    .createAckRequested(VersionTransformer.convert200502wsa15(req)), header);
+                headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), 
+                                                     RMConstants.ACK_REQUESTED_NAME),
+                                           RMUtils.getWSRM200502WSA200508Factory()
+                                               .createAckRequested(VersionTransformer.convert200502wsa15(req)),
+                                           getDataBinding()));
             }
         }
     }
 
-    public void buildHeaderFault(SequenceFault sf, Element header, Marshaller marshaller)
throws JAXBException {
+    @Override
+    protected Object buildHeaderFaultObject(SequenceFault sf) {
         org.apache.cxf.ws.rm.v200502wsa15.SequenceFaultType flt =
             new org.apache.cxf.ws.rm.v200502wsa15.SequenceFaultType();
         flt.setFaultCode(sf.getFaultCode());
@@ -148,9 +160,7 @@ public final class EncoderDecoder10AImpl extends EncoderDecoder {
         if (data != null) {
             flt.getAny().add(data);
         }
-        marshaller.marshal(new JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceFaultType>(
-            RM10Constants.SEQUENCE_FAULT_QNAME,
-            org.apache.cxf.ws.rm.v200502wsa15.SequenceFaultType.class, flt), header);
+        return flt;
     }
 
     public Element encodeSequenceAcknowledgement(SequenceAcknowledgement ack) throws JAXBException
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10Impl.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10Impl.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10Impl.java
index 35ec94c..55658a1 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10Impl.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder10Impl.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.rm;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -29,12 +30,15 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.headers.Header;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.ws.addressing.VersionTransformer.Names200408;
 import org.apache.cxf.ws.rm.v200702.AckRequestedType;
@@ -105,8 +109,9 @@ public final class EncoderDecoder10Impl extends EncoderDecoder {
         return jaxbContext;
     }
 
+    @Override
     protected void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement>
acks,
-        Collection<AckRequestedType> reqs, boolean last, Element header, Marshaller
marshaller) throws JAXBException {
+        Collection<AckRequestedType> reqs, boolean last, List<Header> headers)
throws JAXBException {       
         if (null != seq) {
             LOG.log(Level.FINE, "encoding sequence into RM header");
             org.apache.cxf.ws.rm.v200502.SequenceType toseq = VersionTransformer.convert200502(seq);
@@ -114,24 +119,32 @@ public final class EncoderDecoder10Impl extends EncoderDecoder {
                 toseq.setLastMessage(new org.apache.cxf.ws.rm.v200502.SequenceType.LastMessage());
             }
             JAXBElement<?> element = RMUtils.getWSRM200502Factory().createSequence(toseq);
-            marshaller.marshal(element, header);
+            headers.add(new SoapHeader(element.getName(), element, getDataBinding(), true));
         }
         if (null != acks) {
             LOG.log(Level.FINE, "encoding sequence acknowledgement(s) into RM header");
             for (SequenceAcknowledgement ack : acks) {
-                marshaller.marshal(VersionTransformer.convert200502(ack), header);
+                headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), 
+                                                     RMConstants.SEQUENCE_ACK_NAME),
+                                           VersionTransformer.convert200502(ack),
+                                           getDataBinding()));
             }
         }
         if (null != reqs) {
             LOG.log(Level.FINE, "encoding acknowledgement request(s) into RM header");
             for (AckRequestedType req : reqs) {
-                marshaller.marshal(RMUtils.getWSRM200502Factory()
-                    .createAckRequested(VersionTransformer.convert200502(req)), header);
+                headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), 
+                                                     RMConstants.ACK_REQUESTED_NAME),
+                                           RMUtils.getWSRM200502Factory()
+                                               .createAckRequested(VersionTransformer.convert200502(req)),
+                                           getDataBinding()));
             }
         }
+        
     }
 
-    public void buildHeaderFault(SequenceFault sf, Element header, Marshaller marshaller)
throws JAXBException {
+    @Override
+    protected Object buildHeaderFaultObject(SequenceFault sf) {
         org.apache.cxf.ws.rm.v200502.SequenceFaultType flt = new org.apache.cxf.ws.rm.v200502.SequenceFaultType();
         flt.setFaultCode(sf.getFaultCode());
         Object detail = sf.getDetail();
@@ -146,9 +159,7 @@ public final class EncoderDecoder10Impl extends EncoderDecoder {
         if (data != null) {
             flt.getAny().add(data);
         }
-        marshaller.marshal(new JAXBElement<org.apache.cxf.ws.rm.v200502.SequenceFaultType>(
-            RM10Constants.SEQUENCE_FAULT_QNAME,
-            org.apache.cxf.ws.rm.v200502.SequenceFaultType.class, flt), header);
+        return flt;
     }
 
     public Element encodeSequenceAcknowledgement(SequenceAcknowledgement ack) throws JAXBException
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder11Impl.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder11Impl.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder11Impl.java
index 72153ad..b896272 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder11Impl.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/EncoderDecoder11Impl.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.rm;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -29,12 +30,15 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.headers.Header;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.ws.addressing.Names;
 import org.apache.cxf.ws.rm.v200702.AckRequestedType;
@@ -107,29 +111,36 @@ public final class EncoderDecoder11Impl extends EncoderDecoder {
         return jaxbContext;
     }
 
+    @Override
     protected void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement>
acks,
-        Collection<AckRequestedType> reqs, boolean last, Element header, Marshaller
marshaller) throws JAXBException {
+        Collection<AckRequestedType> reqs, boolean last, List<Header> headers)
throws JAXBException {
 
         if (null != seq) {
             LOG.log(Level.FINE, "encoding sequence into RM header");
             JAXBElement<SequenceType> element = RMUtils.getWSRMFactory().createSequence(seq);
-            marshaller.marshal(element, header);
+            headers.add(new SoapHeader(element.getName(), element, getDataBinding(), true));
         }
         if (null != acks) {
             LOG.log(Level.FINE, "encoding sequence acknowledgement(s) into RM header");
             for (SequenceAcknowledgement ack : acks) {
-                marshaller.marshal(ack, header);
+                headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), 
+                                                     RMConstants.SEQUENCE_ACK_NAME),
+                                           ack, getDataBinding()));
             }
         }
         if (null != reqs) {
             LOG.log(Level.FINE, "encoding acknowledgement request(s) into RM header");
             for (AckRequestedType req : reqs) {
-                marshaller.marshal(RMUtils.getWSRMFactory().createAckRequested(req), header);
+                headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), 
+                                                     RMConstants.ACK_REQUESTED_NAME),
+                                           RMUtils.getWSRMFactory().createAckRequested(req),
+                                           getDataBinding()));
             }
         }
     }
 
-    public void buildHeaderFault(SequenceFault sf, Element header, Marshaller marshaller)
throws JAXBException {
+    @Override
+    protected Object buildHeaderFaultObject(SequenceFault sf) {
         SequenceFaultType flt = new SequenceFaultType();
         flt.setFaultCode(sf.getFaultCode());
         Object detail = sf.getDetail();
@@ -138,8 +149,7 @@ public final class EncoderDecoder11Impl extends EncoderDecoder {
         if (data != null) {
             addDetail(flt, data);
         }
-        marshaller.marshal(new JAXBElement<SequenceFaultType>(RM11Constants.SEQUENCE_FAULT_QNAME,
-            SequenceFaultType.class, flt), header);
+        return flt;
     }
 
     private static void addDetail(SequenceFaultType sft, Element data) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptor.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptor.java
index 070c098..1a5eccf 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptor.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptor.java
@@ -30,12 +30,8 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
 import org.apache.cxf.binding.soap.SoapFault;
-import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.common.logging.LogUtils;
@@ -49,7 +45,6 @@ import org.apache.cxf.ws.addressing.soap.MAPCodec;
 import org.apache.cxf.ws.rm.ProtocolVariation;
 import org.apache.cxf.ws.rm.RM10Constants;
 import org.apache.cxf.ws.rm.RM11Constants;
-import org.apache.cxf.ws.rm.RMConstants;
 import org.apache.cxf.ws.rm.RMContextUtils;
 import org.apache.cxf.ws.rm.RMProperties;
 import org.apache.cxf.ws.rm.SequenceFault;
@@ -132,26 +127,13 @@ public class RMSoapOutInterceptor extends AbstractSoapInterceptor {
 
             AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, true);
             ProtocolVariation protocol = ProtocolVariation.findVariant(rmps.getNamespaceURI(),
maps.getNamespaceURI());
-            Element header = protocol.getCodec().buildHeaders(rmps, message.getVersion().getHeader());
-            if (header != null) {
-                Node node = header.getFirstChild();
-                if (node != null && MessageUtils.isPartialResponse(message)) {
-                    // make sure the response is returned as HTTP 200 and not 202
-                    message.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK);
-                }
-                while (node != null) {
-                    Header holder = null;
-                    if (node.getLocalName().equals("Sequence")) {
-                        holder = new SoapHeader(new QName(node.getNamespaceURI(), node.getLocalName()),
node);
-                        ((SoapHeader)holder).setMustUnderstand(true);
-                    } else {
-                        holder = new Header(new QName(node.getNamespaceURI(), node.getLocalName()),
node);
-                    }
-                    message.getHeaders().add(holder);
-                    node = node.getNextSibling();
-                }
+            List<Header> headers = message.getHeaders();
+            int startSize = headers.size();
+            protocol.getCodec().buildHeaders(rmps, headers);
+            if (startSize != headers.size() && MessageUtils.isPartialResponse(message))
{
+                // make sure the response is returned as HTTP 200 and not 202
+                message.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK);
             }
-
         } catch (JAXBException je) {
             LOG.log(Level.WARNING, "SOAP_HEADER_ENCODE_FAILURE_MSG", je);
         }
@@ -171,16 +153,9 @@ public class RMSoapOutInterceptor extends AbstractSoapInterceptor {
             AddressingProperties maps = RMContextUtils.retrieveMAPs(inmsg, false, false);
             ProtocolVariation protocol = ProtocolVariation.findVariant(rmps.getNamespaceURI(),
                 maps.getNamespaceURI());
-            Element header = protocol.getCodec().buildHeaderFault(sf, message.getVersion().getHeader());
-            Node node = header.getFirstChild();
-            if (node instanceof Element) {
-                Attr attr = header.getOwnerDocument().createAttributeNS("http://www.w3.org/2000/xmlns/",
-                    "xmlns:" + RMConstants.NAMESPACE_PREFIX);
-                attr.setValue(rmps.getNamespaceURI());
-                ((Element)node).setAttributeNodeNS(attr);
-            }
+            Header header = protocol.getCodec().buildHeaderFault(sf);
             List<Header> headers = message.getHeaders();
-            headers.add(new Header(new QName(node.getNamespaceURI(), node.getLocalName()),
node));
+            headers.add(header);
         } catch (JAXBException je) {
             LOG.log(Level.WARNING, "SOAP_HEADER_ENCODE_FAILURE_MSG", je);
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502/package-info.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502/package-info.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502/package-info.java
new file mode 100644
index 0000000..b891c8e
--- /dev/null
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502/package-info.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+@javax.xml.bind.annotation.XmlSchema(
+    namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm",
+    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+    xmlns = { @javax.xml.bind.annotation.XmlNs(namespaceURI = "http://schemas.xmlsoap.org/ws/2005/02/rm",
+                                               prefix = "wsrm") })
+package org.apache.cxf.ws.rm.v200502;
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502wsa15/package-info.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502wsa15/package-info.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502wsa15/package-info.java
new file mode 100644
index 0000000..b115768
--- /dev/null
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200502wsa15/package-info.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+@javax.xml.bind.annotation.XmlSchema(
+    namespace = "http://schemas.xmlsoap.org/ws/2005/02/rm",
+    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+    xmlns = { @javax.xml.bind.annotation.XmlNs(namespaceURI = "http://schemas.xmlsoap.org/ws/2005/02/rm",
+                                               prefix = "wsrm") })
+package org.apache.cxf.ws.rm.v200502wsa15;
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200702/package-info.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200702/package-info.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200702/package-info.java
new file mode 100644
index 0000000..1862fbf
--- /dev/null
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/v200702/package-info.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+@javax.xml.bind.annotation.XmlSchema(
+    namespace = "http://docs.oasis-open.org/ws-rx/wsrm/200702",
+    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+    xmlns = { @javax.xml.bind.annotation.XmlNs(namespaceURI = "http://docs.oasis-open.org/ws-rx/wsrm/200702",
+                                               prefix = "wsrm") })
+package org.apache.cxf.ws.rm.v200702;
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/3d85f317/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptorTest.java
b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptorTest.java
index 846af6b..62399ce 100644
--- a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptorTest.java
+++ b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapOutInterceptorTest.java
@@ -257,53 +257,41 @@ public class RMSoapOutInterceptorTest extends Assert {
     }
 
     private void verifyHeaders(SoapMessage message, String... names) {
-        List<Header> header = message.getHeaders();
+        List<Header> headers = new ArrayList<Header>(message.getHeaders());
 
         // check all expected headers are present
 
         for (String name : names) {
             boolean found = false;
-            Iterator<Header> iter = header.iterator();
+            Iterator<Header> iter = headers.iterator();
             while (iter.hasNext()) {
-                Object obj = iter.next().getObject();
+                Header header = iter.next();
+                Object obj = header.getObject();
+                String namespace = header.getName().getNamespaceURI();
+                String localName = header.getName().getLocalPart();
                 if (obj instanceof Element) {
                     Element elem = (Element) obj;
-                    String namespace = elem.getNamespaceURI();
-                    String localName = elem.getLocalName();
-                    if (RM10Constants.NAMESPACE_URI.equals(namespace)
-                        && localName.equals(name)) {
-                        found = true;
-                        break;
-                    } else if (Names.WSA_NAMESPACE_NAME.equals(namespace)
-                        && localName.equals(name)) {
-                        found = true;
-                        break;
-                    }
+                    namespace = elem.getNamespaceURI();
+                    localName = elem.getLocalName();
+                }
+                if (RM10Constants.NAMESPACE_URI.equals(namespace)
+                    && localName.equals(name)) {
+                    found = true;
+                    iter.remove();
+                    break;
+                } else if (Names.WSA_NAMESPACE_NAME.equals(namespace)
+                    && localName.equals(name)) {
+                    found = true;
+                    iter.remove();
+                    break;
                 }
             }
             assertTrue("Could not find header element " + name, found);
         }
 
         // no other headers should be present
-
-        Iterator<Header> iter1 = header.iterator();
-        while (iter1.hasNext()) {
-            Object obj = iter1.next().getObject();
-            if (obj instanceof Element) {
-                Element elem = (Element) obj;
-                String namespace = elem.getNamespaceURI();
-                String localName = elem.getLocalName();
-                assertTrue(RM10Constants.NAMESPACE_URI.equals(namespace)
-                    || Names.WSA_NAMESPACE_NAME.equals(namespace));
-                boolean found = false;
-                for (String name : names) {
-                    if (localName.equals(name)) {
-                        found = true;
-                        break;
-                    }
-                }
-                assertTrue("Unexpected header element " + localName, found);
-            }
+        if (!headers.isEmpty()) {
+            assertTrue("Unexpected header element " + headers.get(0).getName(), false);
         }
     }
 }


Mime
View raw message