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