1
2
3
4
5
6
7 package org.mule.context.notification;
8
9 import org.mule.api.context.notification.ServerNotification;
10 import org.mule.api.transport.Connectable;
11
12
13
14
15
16 public class ConnectionNotification extends ServerNotification
17 {
18
19
20
21 private static final long serialVersionUID = -6455441938378523145L;
22 public static final int CONNECTION_CONNECTED = CONNECTION_EVENT_ACTION_START_RANGE + 1;
23 public static final int CONNECTION_FAILED = CONNECTION_EVENT_ACTION_START_RANGE + 2;
24 public static final int CONNECTION_DISCONNECTED = CONNECTION_EVENT_ACTION_START_RANGE + 3;
25
26 static {
27 registerAction("connected", CONNECTION_CONNECTED);
28 registerAction("connect failed", CONNECTION_FAILED);
29 registerAction("disconnected", CONNECTION_DISCONNECTED);
30 }
31
32 public ConnectionNotification(Connectable resource, String identifier, int action)
33 {
34 super((resource == null ? identifier : resource.getConnectionDescription()), action);
35 resourceIdentifier = identifier;
36 }
37
38 @Override
39 protected String getPayloadToString()
40 {
41 return source.toString();
42 }
43
44 @Override
45 public String getType()
46 {
47 if (action == CONNECTION_DISCONNECTED)
48 {
49 return TYPE_WARNING;
50 }
51 if (action == CONNECTION_FAILED)
52 {
53 return TYPE_ERROR;
54 }
55 return TYPE_INFO;
56 }
57
58 }