1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.context.notification; |
12 | |
|
13 | |
import org.mule.api.context.notification.ServerNotification; |
14 | |
import org.mule.api.transport.Connectable; |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
public class ConnectionNotification extends ServerNotification |
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 | |
static { |
31 | 0 | registerAction("connected", CONNECTION_CONNECTED); |
32 | 0 | registerAction("connect failed", CONNECTION_FAILED); |
33 | 0 | registerAction("disconnected", CONNECTION_DISCONNECTED); |
34 | 0 | } |
35 | |
|
36 | |
public ConnectionNotification(Connectable resource, String identifier, int action) |
37 | |
{ |
38 | 0 | super((resource == null ? identifier : resource.getConnectionDescription()), action); |
39 | 0 | resourceIdentifier = identifier; |
40 | 0 | } |
41 | |
|
42 | |
@Override |
43 | |
protected String getPayloadToString() |
44 | |
{ |
45 | 0 | return source.toString(); |
46 | |
} |
47 | |
|
48 | |
@Override |
49 | |
public String getType() |
50 | |
{ |
51 | 0 | if (action == CONNECTION_DISCONNECTED) |
52 | |
{ |
53 | 0 | return TYPE_WARNING; |
54 | |
} |
55 | 0 | if (action == CONNECTION_FAILED) |
56 | |
{ |
57 | 0 | return TYPE_ERROR; |
58 | |
} |
59 | 0 | return TYPE_INFO; |
60 | |
} |
61 | |
|
62 | |
} |