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 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 if (endpoint != null)
34 {
35 return super.isMatch(event);
36 }
37 else
38 {
39 logger.warn("No endpoint identifier is set on this wire tap");
40 return false;
41 }
42 }
43
44 public UMOEvent[] process(UMOEvent event) throws MessagingException
45 {
46 try
47 {
48 event.getSession().dispatchEvent(event.getMessage(), tap);
49 }
50 catch (UMOException e)
51 {
52
53 logger.error(e.getMessage(), e);
54 }
55 return super.process(event);
56 }
57
58 public String getEndpoint()
59 {
60 return endpoint;
61 }
62
63 public void setEndpoint(String endpoint) throws UMOException
64 {
65 this.endpoint = endpoint;
66 if (this.endpoint != null)
67 {
68 tap = MuleManager.getInstance().lookupEndpoint(this.endpoint);
69 if (tap == null)
70 {
71 tap = new ImmutableMuleEndpoint(this.endpoint, false);
72 }
73 }
74 }
75
76 }