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