1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl.internal.notifications;
12
13 import org.mule.umo.manager.UMOServerNotification;
14 import org.mule.umo.provider.UMOConnectable;
15
16
17
18
19
20 public class ConnectionNotification extends UMOServerNotification
21 {
22
23
24
25 private static final long serialVersionUID = -6455441938378523145L;
26 public static final int CONNECTION_CONNECTED = CONNECTION_EVENT_ACTION_START_RANGE + 1;
27 public static final int CONNECTION_FAILED = CONNECTION_EVENT_ACTION_START_RANGE + 2;
28 public static final int CONNECTION_DISCONNECTED = CONNECTION_EVENT_ACTION_START_RANGE + 3;
29
30 private static final transient String[] ACTIONS = new String[]{"connected", "connect failed",
31 "disconnected"};
32
33 public ConnectionNotification(UMOConnectable resource, String identifier, int action)
34 {
35 super(resource, action);
36 resourceIdentifier = identifier;
37 }
38
39 protected String getPayloadToString()
40 {
41 if (source instanceof UMOConnectable)
42 {
43 return ((UMOConnectable) source).getConnectionDescription();
44 }
45 return source.toString();
46 }
47
48 protected String getActionName(int action)
49 {
50 int i = action - CONNECTION_EVENT_ACTION_START_RANGE;
51 if (i - 1 > ACTIONS.length)
52 {
53 return String.valueOf(action);
54 }
55 return ACTIONS[i - 1];
56 }
57
58 public String getType()
59 {
60 if (action == CONNECTION_DISCONNECTED)
61 {
62 return TYPE_WARNING;
63 }
64 if (action == CONNECTION_FAILED)
65 {
66 return TYPE_ERROR;
67 }
68 return TYPE_INFO;
69 }
70
71 }