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 | 2 | 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 | 90 | super(resource, action); |
36 | 90 | resourceIdentifier = identifier; |
37 | 90 | } |
38 | |
|
39 | |
protected String getPayloadToString() |
40 | |
{ |
41 | 0 | if (source instanceof UMOConnectable) |
42 | |
{ |
43 | 0 | return ((UMOConnectable) source).getConnectionDescription(); |
44 | |
} |
45 | 0 | return source.toString(); |
46 | |
} |
47 | |
|
48 | |
protected String getActionName(int action) |
49 | |
{ |
50 | 0 | int i = action - CONNECTION_EVENT_ACTION_START_RANGE; |
51 | 0 | if (i - 1 > ACTIONS.length) |
52 | |
{ |
53 | 0 | return String.valueOf(action); |
54 | |
} |
55 | 0 | return ACTIONS[i - 1]; |
56 | |
} |
57 | |
|
58 | |
public String getType() |
59 | |
{ |
60 | 0 | if (action == CONNECTION_DISCONNECTED) |
61 | |
{ |
62 | 0 | return TYPE_WARNING; |
63 | |
} |
64 | 0 | if (action == CONNECTION_FAILED) |
65 | |
{ |
66 | 0 | return TYPE_ERROR; |
67 | |
} |
68 | 0 | return TYPE_INFO; |
69 | |
} |
70 | |
|
71 | |
} |