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 | 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 | |
|
45 | |
} |
46 | 0 | catch (MuleException e) |
47 | |
{ |
48 | |
|
49 | 0 | throw new RuntimeException(e); |
50 | 0 | } |
51 | 0 | } |
52 | |
|
53 | |
} |
54 | |
|
55 | |
|