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  
  * $Id: HeartbeatNotification.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.example.notifications;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.context.notification.BlockingServerEvent;
 15  
 import org.mule.context.notification.CustomNotification;
 16  
 
 17  
 import java.net.InetAddress;
 18  
 import java.net.UnknownHostException;
 19  
 
 20  
 /**
 21  
  * A simple notification that fires repeatedly to notify tha the Mule server is alive
 22  
  * and well.
 23  
  */
 24  
 public class HeartbeatNotification extends CustomNotification implements BlockingServerEvent
 25  
 {
 26  
     private static final long serialVersionUID = -3246036188011581121L;
 27  
 
 28  
     public static final int HEARTBEAT = CUSTOM_EVENT_ACTION_START_RANGE + 1300;
 29  
 
 30  
     static
 31  
     {
 32  0
         registerAction("mule heartbeat", HEARTBEAT);
 33  0
     }
 34  
 
 35  
     public HeartbeatNotification(MuleContext context)
 36  
     {
 37  0
         super(getHostInfo(), HEARTBEAT, context.getConfiguration().getId());
 38  0
     }
 39  
 
 40  
     protected static String getHostInfo()
 41  
     {
 42  
         try
 43  
         {
 44  0
             InetAddress host = InetAddress.getLocalHost();
 45  0
             return host.getHostName() + " (" + host.getHostAddress() + ")";
 46  
         }
 47  0
         catch (UnknownHostException e)
 48  
         {
 49  0
             return "unknown";
 50  
         }
 51  
     }
 52  
 
 53  
     @Override
 54  
     public String toString()
 55  
     {
 56  0
         return EVENT_NAME + "{" + "action=" + getActionName(action) + ", resourceId=" + resourceIdentifier
 57  
                + ", timestamp=" + timestamp + "}";
 58  
     }
 59  
 }