1
2
3
4
5
6
7
8
9
10
11 package org.mule.context.notification;
12
13 import org.mule.api.MuleContext;
14 import org.mule.api.context.notification.BlockingServerEvent;
15 import org.mule.api.context.notification.ServerNotification;
16
17
18
19
20
21
22 public class MuleContextNotification extends ServerNotification implements BlockingServerEvent
23 {
24
25
26
27 private static final long serialVersionUID = -3246036188011581121L;
28
29 public static final int CONTEXT_INITIALISING = CONTEXT_EVENT_ACTION_START_RANGE + 1;
30 public static final int CONTEXT_INITIALISED = CONTEXT_EVENT_ACTION_START_RANGE + 2;
31 public static final int CONTEXT_STARTING = CONTEXT_EVENT_ACTION_START_RANGE + 3;
32 public static final int CONTEXT_STARTED = CONTEXT_EVENT_ACTION_START_RANGE + 4;
33 public static final int CONTEXT_STOPPING = CONTEXT_EVENT_ACTION_START_RANGE + 5;
34 public static final int CONTEXT_STOPPED = CONTEXT_EVENT_ACTION_START_RANGE + 6;
35 public static final int CONTEXT_DISPOSING = CONTEXT_EVENT_ACTION_START_RANGE + 7;
36 public static final int CONTEXT_DISPOSED = CONTEXT_EVENT_ACTION_START_RANGE + 8;
37
38
39
40 public static final int CONTEXT_DISPOSING_CONNECTORS = CONTEXT_EVENT_ACTION_START_RANGE + 9;
41 public static final int CONTEXT_DISPOSED_CONNECTORS = CONTEXT_EVENT_ACTION_START_RANGE + 10;
42 public static final int CONTEXT_STARTING_MODELS = CONTEXT_EVENT_ACTION_START_RANGE + 11;
43 public static final int CONTEXT_STARTED_MODELS = CONTEXT_EVENT_ACTION_START_RANGE + 12;
44 public static final int CONTEXT_STOPPING_MODELS = CONTEXT_EVENT_ACTION_START_RANGE + 13;
45 public static final int CONTEXT_STOPPED_MODELS = CONTEXT_EVENT_ACTION_START_RANGE + 14;
46
47 static {
48 registerAction("mule context initialising", CONTEXT_INITIALISING);
49 registerAction("mule context initialised", CONTEXT_INITIALISED);
50 registerAction("mule context starting", CONTEXT_STARTING);
51 registerAction("mule context started", CONTEXT_STARTED);
52 registerAction("mule context stopping", CONTEXT_STOPPING);
53 registerAction("mule context stopped", CONTEXT_STOPPED);
54 registerAction("mule context disposing", CONTEXT_DISPOSING);
55 registerAction("mule context disposed", CONTEXT_DISPOSED);
56 registerAction("disposing connectors", CONTEXT_DISPOSING_CONNECTORS);
57 registerAction("disposed connectors", CONTEXT_DISPOSED_CONNECTORS);
58 registerAction("starting models", CONTEXT_STARTING_MODELS);
59 registerAction("started models", CONTEXT_STARTED_MODELS);
60 registerAction("stopping models", CONTEXT_STOPPING_MODELS);
61 registerAction("stopped models", CONTEXT_STOPPED_MODELS);
62 }
63
64 private String clusterId;
65 private String domain;
66
67
68 public MuleContextNotification(MuleContext context, String action)
69 {
70 this(context, getActionId(action));
71 }
72
73 public MuleContextNotification(MuleContext context, int action)
74 {
75 super(getId(context), action);
76 resourceIdentifier = getId(context);
77 this.clusterId = context.getConfiguration().getClusterId();
78 this.domain = context.getConfiguration().getDomainId();
79 }
80
81 private static String getId(MuleContext context)
82 {
83 return context.getConfiguration().getDomainId() + "." + context.getConfiguration().getClusterId() + "." + context.getConfiguration().getId();
84 }
85
86 public String getClusterId()
87 {
88 return clusterId;
89 }
90
91 public String getDomain()
92 {
93 return domain;
94 }
95
96 protected String getPayloadToString()
97 {
98 return ((MuleContext) source).getConfiguration().getId();
99 }
100
101 public String toString()
102 {
103 return EVENT_NAME + "{" + "action=" + getActionName(action) + ", resourceId=" + resourceIdentifier
104 + ", timestamp=" + timestamp + "}";
105 }
106
107 }