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