Coverage Report - org.mule.context.notification.ConnectionNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectionNotification
47%
7/15
0%
0/6
3
 
 1  
 /*
 2  
  * $Id: ConnectionNotification.java 10489 2008-01-23 17:53:38Z dfeist $
 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.context.notification;
 12  
 
 13  
 import org.mule.api.context.notification.ServerNotification;
 14  
 import org.mule.api.transport.Connectable;
 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 ServerNotification
 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  
     static {
 31  2
         registerAction("connected", CONNECTION_CONNECTED);
 32  2
         registerAction("connect failed", CONNECTION_FAILED);
 33  2
         registerAction("disconnected", CONNECTION_DISCONNECTED);
 34  2
     }
 35  
 
 36  
     public ConnectionNotification(Connectable resource, String identifier, int action)
 37  
     {
 38  28
         super(resource, action);
 39  28
         resourceIdentifier = identifier;
 40  28
     }
 41  
 
 42  
     protected String getPayloadToString()
 43  
     {
 44  0
         if (source instanceof Connectable)
 45  
         {
 46  0
             return ((Connectable) source).getConnectionDescription();
 47  
         }
 48  0
         return source.toString();
 49  
     }
 50  
 
 51  
     public String getType()
 52  
     {
 53  0
         if (action == CONNECTION_DISCONNECTED)
 54  
         {
 55  0
             return TYPE_WARNING;
 56  
         }
 57  0
         if (action == CONNECTION_FAILED)
 58  
         {
 59  0
             return TYPE_ERROR;
 60  
         }
 61  0
         return TYPE_INFO;
 62  
     }
 63  
 
 64  
 }