1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.routing.inbound; |
12 | |
|
13 | |
import org.mule.DefaultMuleEvent; |
14 | |
import org.mule.DefaultMuleSession; |
15 | |
import org.mule.NullSessionHandler; |
16 | |
import org.mule.RequestContext; |
17 | |
import org.mule.api.MessagingException; |
18 | |
import org.mule.api.MuleEvent; |
19 | |
import org.mule.api.MuleException; |
20 | |
import org.mule.api.MuleSession; |
21 | |
import org.mule.api.endpoint.OutboundEndpoint; |
22 | |
import org.mule.api.transport.DispatchException; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public class WireTap extends SelectiveConsumer |
31 | |
{ |
32 | |
private volatile OutboundEndpoint tap; |
33 | |
|
34 | |
public boolean isMatch(MuleEvent event) throws MessagingException |
35 | |
{ |
36 | 0 | if (tap != null) |
37 | |
{ |
38 | 0 | return super.isMatch(event); |
39 | |
} |
40 | |
else |
41 | |
{ |
42 | 0 | logger.warn("No endpoint identifier is set on this wire tap"); |
43 | 0 | return false; |
44 | |
} |
45 | |
} |
46 | |
|
47 | |
public MuleEvent[] process(MuleEvent event) throws MessagingException |
48 | |
{ |
49 | 0 | RequestContext.setEvent(null); |
50 | |
try |
51 | |
{ |
52 | |
|
53 | |
|
54 | 0 | MuleSession session = new DefaultMuleSession(event.getMessage(), new NullSessionHandler(), getMuleContext()); |
55 | 0 | tap.dispatch(new DefaultMuleEvent(event.getMessage(), tap, session, false)); |
56 | |
} |
57 | 0 | catch (MessagingException e) |
58 | |
{ |
59 | 0 | throw e; |
60 | |
} |
61 | 0 | catch (MuleException e) |
62 | |
{ |
63 | 0 | throw new DispatchException(event.getMessage(), tap, e); |
64 | 0 | } |
65 | 0 | return super.process(event); |
66 | |
} |
67 | |
|
68 | |
public OutboundEndpoint getEndpoint() |
69 | |
{ |
70 | 0 | return tap; |
71 | |
} |
72 | |
|
73 | |
public void setEndpoint(OutboundEndpoint endpoint) throws MuleException |
74 | |
{ |
75 | 0 | this.tap = endpoint; |
76 | 0 | } |
77 | |
} |