View Javadoc

    1   package org.codehaus.xfire.util;
    2
    3   import javax.xml.stream.XMLStreamException;
    4
    5   import org.codehaus.xfire.MessageContext;
    6   import org.codehaus.xfire.exchange.InMessage;
    7   import org.codehaus.xfire.transport.ChannelEndpoint;
    8   import org.codehaus.yom.Document;
    9   import org.codehaus.yom.Element;
    10  import org.codehaus.yom.stax.StaxBuilder;
    11
    12  public class YOMEndpoint
    13      implements ChannelEndpoint
    14  {
    15      private int count = 0;
    16      private Document message;
    17
    18      public void onReceive(MessageContext context, InMessage msg)
    19      {
    20          count++;
    21          StaxBuilder builder = new StaxBuilder();
    22          try
    23          {
    24              Element root = builder.buildElement(null, msg.getXMLStreamReader());
    25              if (root != null)
    26              {
    27                  message = new Document(root);
    28              }
    29              else
    30              {
    31                  message = null;
    32              }
    33          }
    34          catch (XMLStreamException e)
    35          {
    36              e.printStackTrace();
    37          }
    38      }
    39
    40      public int getCount()
    41      {
    42          return count;
    43      }
    44
    45      public Document getMessage()
    46      {
    47          return message;
    48      }
    49  }