1
2
3
4
5
6
7
8
9
10
11 package org.mule.context.notification;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.component.Component;
15 import org.mule.api.construct.FlowConstruct;
16 import org.mule.api.context.notification.ServerNotification;
17
18
19
20
21
22 public class ComponentMessageNotification extends ServerNotification
23 {
24
25 private static final long serialVersionUID = -6369685122731797646L;
26
27 public static final int COMPONENT_PRE_INVOKE = COMPONENT_EVENT_ACTION_START_RANGE + 1;
28 public static final int COMPONENT_POST_INVOKE = COMPONENT_EVENT_ACTION_START_RANGE + 2;
29
30 protected transient FlowConstruct flowConstruct;
31 protected transient Component component;
32
33 static
34 {
35 registerAction("component pre invoke", COMPONENT_PRE_INVOKE);
36 registerAction("component post invoke", COMPONENT_POST_INVOKE);
37 }
38
39
40
41
42
43 public ComponentMessageNotification(MuleMessage message,
44 Component component,
45 FlowConstruct flowConstruct,
46 int action)
47 {
48 super(cloneMessage(message), action);
49 this.flowConstruct = flowConstruct;
50 this.component = component;
51 resourceIdentifier = flowConstruct.getName();
52
53 }
54
55 @Override
56 protected String getPayloadToString()
57 {
58 return ((MuleMessage) source).getPayloadForLogging();
59 }
60
61
62
63
64 public String getServiceName()
65 {
66 return resourceIdentifier;
67 }
68
69 @Override
70 public String toString()
71 {
72 return EVENT_NAME + "{action=" + getActionName(action) + ", message: " + source + ", resourceId="
73 + resourceIdentifier + ", timestamp=" + timestamp + ", serverId=" + serverId + ", component: "
74 + "}";
75 }
76
77 @Override
78 public String getType()
79 {
80 return "trace";
81 }
82
83 @Override
84 public MuleMessage getSource()
85 {
86 return (MuleMessage) super.getSource();
87 }
88
89 public FlowConstruct getFlowConstruct()
90 {
91 return flowConstruct;
92 }
93
94 public Component getComponent()
95 {
96 return component;
97 }
98 }