View Javadoc

    1   package org.codehaus.xfire.exchange;
    2
    3   import org.codehaus.xfire.MessageContext;
    4   import org.codehaus.xfire.service.OperationInfo;
    5   import org.codehaus.xfire.transport.Channel;
    6   import org.codehaus.xfire.transport.Transport;
    7   import org.codehaus.xfire.transport.TransportManager;
    8   import org.codehaus.xfire.transport.dead.DeadLetterTransport;
    9
    10  public abstract class AbstractMessageExchange
    11      implements MessageExchange
    12  {
    13      private OperationInfo operation;
    14
    15      private MessageContext context;
    16
    17      private InMessage inMessage;
    18      private OutMessage outMessage;
    19      private AbstractMessage faultMessage;
    20
    21      public AbstractMessageExchange(MessageContext context)
    22      {
    23          this.context = context;
    24      }
    25
    26      public MessageContext getContext()
    27      {
    28          return context;
    29      }
    30
    31      public OperationInfo getOperation()
    32      {
    33          return operation;
    34      }
    35
    36      public void setOperation(OperationInfo operation)
    37      {
    38          this.operation = operation;
    39      }
    40
    41      public InMessage getInMessage()
    42          throws UnsupportedOperationException
    43      {
    44          return inMessage;
    45      }
    46
    47      public OutMessage getOutMessage()
    48          throws UnsupportedOperationException
    49      {
    50          return outMessage;
    51      }
    52
    53      public AbstractMessage getFaultMessage()
    54          throws UnsupportedOperationException
    55      {
    56          return faultMessage;
    57      }
    58
    59      public void setFaultMessage(AbstractMessage faultMessage)
    60      {
    61          this.faultMessage = faultMessage;
    62      }
    63
    64      public void setInMessage(InMessage inMessage)
    65      {
    66          this.inMessage = inMessage;
    67      }
    68
    69      public void setOutMessage(OutMessage outMessage)
    70      {
    71          this.outMessage = outMessage;
    72      }
    73
    74      public AbstractMessage getMessage(String type)
    75          throws UnsupportedOperationException
    76      {
    77          throw new UnsupportedOperationException();
    78      }
    79
    80      public boolean hasFaultMessage()
    81      {
    82          return false;
    83      }
    84
    85      public boolean hasInMessage()
    86      {
    87          return false;
    88      }
    89
    90      public boolean hasMessage(String type)
    91      {
    92          return false;
    93      }
    94
    95      public boolean hasOutMessage()
    96      {
    97          return false;
    98      }
    99
    100     public void setMessage(String type, AbstractMessage faultMessage)
    101     {
    102         throw new UnsupportedOperationException();
    103     }
    104
    105     public Channel getInChannel()
    106     {
    107         return getDeadLetterChannel();
    108     }
    109
    110     public Channel getOutChannel()
    111     {
    112         return getDeadLetterChannel();
    113     }
    114
    115     public Channel getFaultChannel()
    116     {
    117         return getDeadLetterChannel();
    118     }
    119
    120     public Channel getDeadLetterChannel()
    121     {
    122         TransportManager tm = getContext().getXFire().getTransportManager();
    123         Transport transport = tm.getTransport(DeadLetterTransport.NAME);
    124
    125         try
    126         {
    127             return transport.createChannel();
    128         }
    129         catch (Exception e)
    130         {
    131             e.printStackTrace();
    132
    133             return null;
    134         }
    135     }
    136 }