Coverage Report - org.mule.impl.internal.notifications.ConnectionNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectionNotification
25%
4/16
0%
0/8
3
 
 1  
 /*
 2  
  * $Id: ConnectionNotification.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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  
  * Is fired by a connector when a connection is made, or disconnected of the
 18  
  * connection fails.
 19  
  */
 20  
 public class ConnectionNotification extends UMOServerNotification
 21  
 {
 22  
     /**
 23  
      * Serial version
 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  
 }