1
2
3
4
5
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 super();
25 this.router = router;
26 this.filter = filter;
27 }
28
29 @Override
30 public void onMatch(XPathEvent event) throws XMLStreamException
31 {
32 try
33 {
34 MuleMessage msg = SxcFilteringOutboundRouter.getCurrentMessage();
35 msg.setInvocationProperty(filter.toString(), true);
36
37 if (router.testMatch(msg))
38 {
39 throw new StopProcessingException();
40 }
41 }
42 catch (UndefinedMatchException e)
43 {
44
45 }
46 catch (MuleException e)
47 {
48
49 throw new RuntimeException(e);
50 }
51 }
52
53 }
54
55