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