Coverage Report - org.mule.example.notifications.HeartbeatNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
HeartbeatNotification
0%
0/9
N/A
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.example.notifications;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.context.notification.BlockingServerEvent;
 11  
 import org.mule.context.notification.CustomNotification;
 12  
 
 13  
 import java.net.InetAddress;
 14  
 import java.net.UnknownHostException;
 15  
 
 16  
 /**
 17  
  * A simple notification that fires repeatedly to notify tha the Mule server is alive
 18  
  * and well.
 19  
  */
 20  
 public class HeartbeatNotification extends CustomNotification implements BlockingServerEvent
 21  
 {
 22  
     private static final long serialVersionUID = -3246036188011581121L;
 23  
 
 24  
     public static final int HEARTBEAT = CUSTOM_EVENT_ACTION_START_RANGE + 1300;
 25  
 
 26  
     static
 27  
     {
 28  0
         registerAction("mule heartbeat", HEARTBEAT);
 29  0
     }
 30  
 
 31  
     public HeartbeatNotification(MuleContext context)
 32  
     {
 33  0
         super(getHostInfo(), HEARTBEAT, context.getConfiguration().getId());
 34  0
     }
 35  
 
 36  
     protected static String getHostInfo()
 37  
     {
 38  
         try
 39  
         {
 40  0
             InetAddress host = InetAddress.getLocalHost();
 41  0
             return host.getHostName() + " (" + host.getHostAddress() + ")";
 42  
         }
 43  0
         catch (UnknownHostException e)
 44  
         {
 45  0
             return "unknown";
 46  
         }
 47  
     }
 48  
 
 49  
     @Override
 50  
     public String toString()
 51  
     {
 52  0
         return EVENT_NAME + "{" + "action=" + getActionName(action) + ", resourceId=" + resourceIdentifier
 53  
                + ", timestamp=" + timestamp + "}";
 54  
     }
 55  
 }