You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by sc...@apache.org on 2007/08/21 14:15:34 UTC
svn commit: r568090 -
/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
Author: scheu
Date: Tue Aug 21 05:15:33 2007
New Revision: 568090
URL: http://svn.apache.org/viewvc?rev=568090&view=rev
Log:
WSCOMMONS-236
Contributor:Rich Scheuerle
Changed SandeshaUtil to use the new Axiom fast CopyUtils utility to copy
the SOAPEnvelope
Modified:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java?rev=568090&r1=568089&r2=568090&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java Tue Aug 21 05:15:33 2007
@@ -32,6 +32,7 @@
import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.CopyUtils;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPEnvelope;
@@ -98,7 +99,14 @@
private static AxisModule axisModule = null;
- public static AxisModule getAxisModule() {
+
+ /**
+ * Private Constructor.
+ * All utility methods are static.
+ */
+ private SandeshaUtil() {}
+
+ public static AxisModule getAxisModule() {
return axisModule;
}
@@ -922,31 +930,23 @@
return phases;
}
- public static MessageContext cloneMessageContext (MessageContext oldMsg) throws AxisFault {
+ /**
+ * Clone the MessageContext
+ * @param oldMsg
+ * @return
+ * @throws AxisFault
+ */
+ public static MessageContext cloneMessageContext (MessageContext oldMsg) throws AxisFault {
MessageContext newMsg = new MessageContext ();
newMsg.setOptions(new Options (oldMsg.getOptions()));
-
- //TODO hd to use following hack since a 'clone' method was not available for SOAPEnvelopes.
- //Do it the correct way when that becomes available.
- OMElement newElement = oldMsg.getEnvelope().cloneOMElement();
- String elementString = newElement.toString();
-
- try {
- ByteArrayInputStream stream = new ByteArrayInputStream(
- elementString.getBytes("UTF8"));
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(
- XMLInputFactory.newInstance().createXMLStreamReader(stream),
- null);
- SOAPEnvelope envelope = builder.getSOAPEnvelope();
-
- newMsg.setEnvelope(envelope);
- } catch (XMLStreamException e) {
- throw AxisFault.makeFault(e);
- } catch (UnsupportedEncodingException e) {
- throw AxisFault.makeFault(e);
- }
-
+ // Create a copy of the envelope
+ SOAPEnvelope oldEnvelope = oldMsg.getEnvelope();
+ if (oldEnvelope != null) {
+ SOAPEnvelope newEnvelope = copySOAPEnvelope(oldMsg.getEnvelope());
+ newMsg.setEnvelope(newEnvelope);
+ }
+
newMsg.setConfigurationContext(oldMsg.getConfigurationContext());
newMsg.setAxisService(oldMsg.getAxisService());
newMsg.setTransportOut(oldMsg.getTransportOut());
@@ -959,6 +959,22 @@
}
+ /**
+ * Create a copy of the SOAPEnvelope
+ * @param sourceEnv
+ * @return targetEnv
+ */
+ private static SOAPEnvelope copySOAPEnvelope(SOAPEnvelope sourceEnv) {
+ if (log.isDebugEnabled()) {
+ log.debug("Start Create in-memory copy of the SOAPEnvelope");
+ }
+ // Delegate to the CopuUtils provided by Axiom
+ SOAPEnvelope targetEnv = CopyUtils.copy(sourceEnv);
+ if (log.isDebugEnabled()) {
+ log.debug("End Create in-memory copy of the SOAPEnvelope");
+ }
+ return targetEnv;
+ }
/**
* Remove the MustUnderstand header blocks.
* @param envelope
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org