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          StaxBuilder builder = new StaxBuilder();
    21          try
    22          {
    23              Element root = builder.buildElement(null, msg.getXMLStreamReader());
    24              if (root != null)
    25              {
    26                  message = new Document(root);
    27              }
    28              else
    29              {
    30                  message = null;
    31              }
    32          }
    33          catch (XMLStreamException e)
    34          {
    35              e.printStackTrace();
    36          }
    37          count++;
    38      }
    39
    40      public int getCount()
    41      {
    42          return count;
    43      }
    44
    45      public Document getMessage()
    46      {
    47          return message;
    48      }
    49  }