1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.endpoint.outbound; |
12 | |
|
13 | |
import org.mule.api.MuleEvent; |
14 | |
import org.mule.api.MuleException; |
15 | |
import org.mule.api.endpoint.OutboundEndpoint; |
16 | |
import org.mule.api.processor.MessageProcessor; |
17 | |
import org.mule.context.notification.EndpointMessageNotification; |
18 | |
import org.mule.transport.AbstractConnector; |
19 | |
import org.mule.util.ObjectUtils; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class OutboundNotificationMessageProcessor implements MessageProcessor |
27 | |
{ |
28 | |
|
29 | |
private OutboundEndpoint endpoint; |
30 | |
|
31 | |
public OutboundNotificationMessageProcessor(OutboundEndpoint endpoint) |
32 | 0 | { |
33 | 0 | this.endpoint = endpoint; |
34 | 0 | } |
35 | |
|
36 | |
public MuleEvent process(MuleEvent event) throws MuleException |
37 | |
{ |
38 | 0 | AbstractConnector connector = (AbstractConnector) endpoint.getConnector(); |
39 | 0 | if (connector.isEnableMessageEvents()) |
40 | |
{ |
41 | 0 | String component = null; |
42 | 0 | if (event.getFlowConstruct() != null) |
43 | |
{ |
44 | 0 | component = event.getFlowConstruct().getName(); |
45 | |
} |
46 | |
|
47 | |
int notificationAction; |
48 | 0 | if (event.getEndpoint().getExchangePattern().hasResponse()) |
49 | |
{ |
50 | 0 | notificationAction = EndpointMessageNotification.MESSAGE_SENT; |
51 | |
} |
52 | |
else |
53 | |
{ |
54 | 0 | notificationAction = EndpointMessageNotification.MESSAGE_DISPATCHED; |
55 | |
} |
56 | 0 | connector.fireNotification(new EndpointMessageNotification(event.getMessage(), |
57 | |
event.getEndpoint(), component, notificationAction)); |
58 | |
} |
59 | |
|
60 | 0 | return event; |
61 | |
} |
62 | |
|
63 | |
@Override |
64 | |
public String toString() |
65 | |
{ |
66 | 0 | return ObjectUtils.toString(this); |
67 | |
} |
68 | |
} |