Coverage Report - org.mule.module.sxc.FilterEventHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
FilterEventHandler
0%
0/13
0%
0/2
0
 
 1  
 /*
 2  
  * $Id: FilterEventHandler.java 19739 2010-09-27 14:28:40Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.module.sxc;
 12  
 
 13  
 import org.mule.api.MuleException;
 14  
 import org.mule.api.MuleMessage;
 15  
 
 16  
 import com.envoisolutions.sxc.xpath.XPathEvent;
 17  
 import com.envoisolutions.sxc.xpath.XPathEventHandler;
 18  
 
 19  
 import javax.xml.stream.XMLStreamException;
 20  
 
 21  
 public class FilterEventHandler extends XPathEventHandler
 22  
 {
 23  
     SxcFilteringOutboundRouter router;
 24  
     SxcFilter filter;
 25  
     
 26  
     public FilterEventHandler(SxcFilteringOutboundRouter router, SxcFilter filter)
 27  
     {
 28  0
         super();
 29  0
         this.router = router;
 30  0
         this.filter = filter;
 31  0
     }
 32  
     
 33  
     @Override
 34  
     public void onMatch(XPathEvent event) throws XMLStreamException
 35  
     {
 36  
         try 
 37  
         {
 38  0
             MuleMessage msg = SxcFilteringOutboundRouter.getCurrentMessage();
 39  0
             msg.setInvocationProperty(filter.toString(), true);
 40  
             
 41  0
             if (router.testMatch(msg))
 42  
             {
 43  0
                 throw new StopProcessingException();
 44  
             }
 45  
         }
 46  0
         catch (UndefinedMatchException e) 
 47  
         {
 48  
             // ignore
 49  
         }
 50  0
         catch (MuleException e)
 51  
         {
 52  
             // This shouldn't happen
 53  0
             throw new RuntimeException(e);
 54  0
         }
 55  0
     }
 56  
 
 57  
 }
 58  
 
 59