View Javadoc

    1   package org.codehaus.xfire.exchange;
    2
    3   import org.apache.commons.logging.Log;
    4   import org.apache.commons.logging.LogFactory;
    5   import org.codehaus.xfire.MessageContext;
    6   import org.codehaus.xfire.transport.Channel;
    7
    8   /***
    9    * A robust in-out MEP. A reply is always sent back. If a fault occurs
    10   * it is also sent back.
    11   *
    12   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    13   */
    14  public class RobustInOutExchange
    15      extends AbstractMessageExchange
    16  {
    17      private static final Log logger = LogFactory.getLog(RobustInOutExchange.class);
    18
    19      public RobustInOutExchange(MessageContext context)
    20      {
    21          super(context);
    22
    23          if (context.getExchange() != null)
    24          {
    25              setInMessage(context.getExchange().getInMessage());
    26          }
    27
    28          context.setExchange(this);
    29      }
    30
    31      public OutMessage getOutMessage()
    32      {
    33          if (super.getOutMessage() == null)
    34          {
    35              OutMessage outMessage = new OutMessage(Channel.BACKCHANNEL_URI);
    36              outMessage.setChannel(getOutChannel());
    37              outMessage.setSoapVersion(getInMessage().getSoapVersion());
    38
    39              setOutMessage(outMessage);
    40          }
    41          return super.getOutMessage();
    42      }
    43
    44      public AbstractMessage getFaultMessage()
    45          throws UnsupportedOperationException
    46      {
    47          if (super.getFaultMessage() == null)
    48          {
    49              OutMessage outMessage = new OutMessage(Channel.BACKCHANNEL_URI);
    50              outMessage.setChannel(getFaultChannel());
    51              outMessage.setSoapVersion(getInMessage().getSoapVersion());
    52
    53              setFaultMessage(outMessage);
    54          }
    55          return super.getFaultMessage();
    56      }
    57
    58      public boolean hasFaultMessage()
    59      {
    60          return true;
    61      }
    62
    63      public boolean hasInMessage()
    64      {
    65          return true;
    66      }
    67
    68      public boolean hasOutMessage()
    69      {
    70          return true;
    71      }
    72
    73      public Channel getFaultChannel()
    74      {
    75          return getInChannel();
    76      }
    77
    78      public Channel getInChannel()
    79      {
    80          return getContext().getInMessage().getChannel();
    81      }
    82
    83      public Channel getOutChannel()
    84      {
    85          return getInChannel();
    86      }
    87  }