1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.sxc;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.routing.RoutingException;
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 super();
29 this.router = router;
30 this.filter = filter;
31 }
32
33 @Override
34 public void onMatch(XPathEvent event) throws XMLStreamException
35 {
36 try
37 {
38 MuleMessage msg = SxcFilteringOutboundRouter.getCurrentMessage();
39 msg.setProperty(filter.toString(), true);
40
41 if (router.testMatch(msg))
42 {
43 throw new StopProcessingException();
44 }
45 }
46 catch (UndefinedMatchException e)
47 {
48 }
49 catch (RoutingException e)
50 {
51
52 throw new RuntimeException(e);
53 }
54 }
55
56 }
57
58