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 | 0 | registerAction("connected", CONNECTION_CONNECTED); |
28 | 0 | registerAction("connect failed", CONNECTION_FAILED); |
29 | 0 | registerAction("disconnected", CONNECTION_DISCONNECTED); |
30 | 0 | } |
31 | |
|
32 | |
public ConnectionNotification(Connectable resource, String identifier, int action) |
33 | |
{ |
34 | 0 | super((resource == null ? identifier : resource.getConnectionDescription()), action); |
35 | 0 | resourceIdentifier = identifier; |
36 | 0 | } |
37 | |
|
38 | |
@Override |
39 | |
protected String getPayloadToString() |
40 | |
{ |
41 | 0 | return source.toString(); |
42 | |
} |
43 | |
|
44 | |
@Override |
45 | |
public String getType() |
46 | |
{ |
47 | 0 | if (action == CONNECTION_DISCONNECTED) |
48 | |
{ |
49 | 0 | return TYPE_WARNING; |
50 | |
} |
51 | 0 | if (action == CONNECTION_FAILED) |
52 | |
{ |
53 | 0 | return TYPE_ERROR; |
54 | |
} |
55 | 0 | return TYPE_INFO; |
56 | |
} |
57 | |
|
58 | |
} |