org.apache.synapse.util
Class MessageHelper

java.lang.Object
  extended by org.apache.synapse.util.MessageHelper

public class MessageHelper
extends Object


Constructor Summary
MessageHelper()
           
 
Method Summary
static MessageContext cloneAxis2MessageContext(MessageContext mc)
          This method will simulate cloning the message context and creating an exact copy of the passed message.
static MessageContext cloneMessageContext(MessageContext synCtx)
          This method will simulate cloning the message context and creating an exact copy of the passed message.
static Options cloneOptions(Options options)
          Clones the given Options object.
static MessageContext clonePartially(MessageContext ori)
           
static SOAPEnvelope cloneSOAPEnvelope(SOAPEnvelope envelope)
          This method will clone the provided SOAPEnvelope and returns the cloned envelope as an exact copy of the provided envelope
static SOAPFault cloneSOAPFault(SOAPFault fault)
          Clones the SOAPFault, fault cloning is not the same as cloning the OMElement because if the Fault is accessed through the SOAPEnvelope.getBody().getFault() method it will lead to a class cast because the cloned element is just an OMElement but not a Fault.
static Map getClonedTransportHeaders(MessageContext msgCtx)
           
static org.apache.neethi.Policy getPolicy(MessageContext synCtx, String propertyKey)
          Get the Policy object for the given name from the Synapse configuration at runtime
static SOAPEnvelope removeAddressingHeaders(MessageContext axisMsgCtx)
          Removes Submission and Final WS-Addressing headers and return the SOAPEnvelope from the given message context
static void removeProcessedHeaders(MessageContext axisMsgCtx, boolean preserveAddressing)
          Remove the headers that are marked as processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageHelper

public MessageHelper()
Method Detail

cloneMessageContext

public static MessageContext cloneMessageContext(MessageContext synCtx)
                                          throws AxisFault
This method will simulate cloning the message context and creating an exact copy of the passed message. One should use this method with care; that is because, inside the new MC, most of the attributes of the MC like opCtx and so on are still kept as references inside the axis2 MessageContext for performance improvements. (Note: U dont have to worrie about the SOAPEnvelope, it is a cloned copy and not a reference from any other MC)

Parameters:
synCtx - - this will be cloned
Returns:
cloned Synapse MessageContext
Throws:
AxisFault - if there is a failure in creating the new Synapse MC or in a failure in clonning the underlying axis2 MessageContext
See Also:
cloneAxis2MessageContext(org.apache.axis2.context.MessageContext)

cloneAxis2MessageContext

public static MessageContext cloneAxis2MessageContext(MessageContext mc)
                                               throws AxisFault
This method will simulate cloning the message context and creating an exact copy of the passed message. One should use this method with care; that is because, inside the new MC, most of the attributes of the MC like opCtx and so on are still kept as references. Otherwise there will be perf issues. But ..... this may reveal in some conflicts in the cloned message if you try to do advanced mediations with the cloned message, in which case you should manually get a clone of the changing part of the MC and set that cloned part to your MC. Changing the MC after doing that will solve most of the issues. (Note: You don't have to worry about the SOAPEnvelope, it is a cloned copy and not a reference from any other MC)

Parameters:
mc - - this will be cloned for getting an exact copy
Returns:
cloned MessageContext from the given mc
Throws:
AxisFault - if there is a failure in copying the certain attributes of the provided message context

getClonedTransportHeaders

public static Map getClonedTransportHeaders(MessageContext msgCtx)

clonePartially

public static MessageContext clonePartially(MessageContext ori)
                                     throws AxisFault
Throws:
AxisFault

cloneSOAPEnvelope

public static SOAPEnvelope cloneSOAPEnvelope(SOAPEnvelope envelope)
This method will clone the provided SOAPEnvelope and returns the cloned envelope as an exact copy of the provided envelope

Parameters:
envelope - - this will be cloned to get the new envelope
Returns:
cloned SOAPEnvelope from the provided one

cloneOptions

public static Options cloneOptions(Options options)
Clones the given Options object. This is not a deep copy because this will be called for each and every message going out from synapse. The parent of the cloning options object is kept as a reference.

Parameters:
options - cloning object
Returns:
cloned Options object

removeAddressingHeaders

public static SOAPEnvelope removeAddressingHeaders(MessageContext axisMsgCtx)
Removes Submission and Final WS-Addressing headers and return the SOAPEnvelope from the given message context

Parameters:
axisMsgCtx - the Axis2 Message context
Returns:
the resulting SOAPEnvelope

getPolicy

public static org.apache.neethi.Policy getPolicy(MessageContext synCtx,
                                                 String propertyKey)
Get the Policy object for the given name from the Synapse configuration at runtime

Parameters:
synCtx - the current synapse configuration to get to the synapse configuration
propertyKey - the name of the property which holds the Policy required
Returns:
the Policy object with the given name, from the configuration

cloneSOAPFault

public static SOAPFault cloneSOAPFault(SOAPFault fault)
Clones the SOAPFault, fault cloning is not the same as cloning the OMElement because if the Fault is accessed through the SOAPEnvelope.getBody().getFault() method it will lead to a class cast because the cloned element is just an OMElement but not a Fault.

Parameters:
fault - that needs to be cloned
Returns:
the cloned fault

removeProcessedHeaders

public static void removeProcessedHeaders(MessageContext axisMsgCtx,
                                          boolean preserveAddressing)
Remove the headers that are marked as processed.

Parameters:
axisMsgCtx - the Axis2 Message context
preserveAddressing - if true preserve the addressing headers


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.