1 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 23 public class ConnectionNotification extends UMOServerNotification 24 { 25 28 private static final long serialVersionUID = -6455441938378523145L; 29 public static final int CONNECTION_CONNECTED = CONNECTION_EVENT_ACTION_START_RANGE + 1; 30 public static final int CONNECTION_FAILED = CONNECTION_EVENT_ACTION_START_RANGE + 2; 31 public static final int CONNECTION_DISCONNECTED = CONNECTION_EVENT_ACTION_START_RANGE + 3; 32 33 private static final transient String [] ACTIONS = new String []{"connected", "connect failed", 34 "disconnected"}; 35 36 public ConnectionNotification(UMOConnectable resource, String identifier, int action) 37 { 38 super(resource, action); 39 resourceIdentifier = identifier; 40 } 41 42 protected String getPayloadToString() 43 { 44 if (source instanceof UMOConnectable) 45 { 46 return ((UMOConnectable)source).getConnectionDescription(); 47 } 48 return source.toString(); 49 } 50 51 protected String getActionName(int action) 52 { 53 int i = action - CONNECTION_EVENT_ACTION_START_RANGE; 54 if (i - 1 > ACTIONS.length) 55 { 56 return String.valueOf(action); 57 } 58 return ACTIONS[i - 1]; 59 } 60 61 public String getType() 62 { 63 if (action == CONNECTION_DISCONNECTED) 64 { 65 return TYPE_WARNING; 66 } 67 if (action == CONNECTION_FAILED) 68 { 69 return TYPE_ERROR; 70 } 71 return TYPE_INFO; 72 } 73 74 } 75 | Popular Tags |