1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
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 | |
|
49 | |
} |
50 | 0 | catch (MuleException e) |
51 | |
{ |
52 | |
|
53 | 0 | throw new RuntimeException(e); |
54 | 0 | } |
55 | 0 | } |
56 | |
|
57 | |
} |
58 | |
|
59 | |
|