Coverage Report - org.mule.context.notification.CustomNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
CustomNotification
33%
3/9
25%
2/8
2.333
 
 1  
 /*
 2  
  * $Id: CustomNotification.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.CustomNotificationListener;
 14  
 import org.mule.api.context.notification.ServerNotification;
 15  
 
 16  
 /**
 17  
  * <code>CustomNotification</code> Custom notifications can be used by components
 18  
  * and other objects such as routers, transformers, agents, etc to communicate a
 19  
  * change of state to each other. The Action value for the event is abitary. However
 20  
  * care should be taken not to set the action code to an existing action code. To
 21  
  * ensure this doesn't happen always set the action code greater than the
 22  
  * CUSTOM_ACTION_START_RANGE.
 23  
  * 
 24  
  * @see CustomNotificationListener
 25  
  */
 26  
 public class CustomNotification extends ServerNotification
 27  
 {
 28  
     /**
 29  
      * Serial version
 30  
      */
 31  
     private static final long serialVersionUID = 762448139858484536L;
 32  
 
 33  
     /**
 34  
      * Creates a custom action event
 35  
      * 
 36  
      * @param message the message to associate with the event
 37  
      * @param action the action code for the event
 38  
      * @throws IllegalArgumentException if the action value is less than
 39  
      *             CUSTOM_ACTION_START_RANGE
 40  
      */
 41  
     public CustomNotification(Object message, int action)
 42  
     {
 43  10
         super(message, action);
 44  10
         if (action < CUSTOM_EVENT_ACTION_START_RANGE && action > 0)
 45  
         {
 46  0
             throw new IllegalArgumentException(
 47  
                 "Action range must be greater than CUSTOM_ACTION_START_RANGE ("
 48  
                                 + CUSTOM_EVENT_ACTION_START_RANGE + ")");
 49  
         }
 50  10
     }
 51  
 
 52  
     public CustomNotification(Object message, int action, String resourceId)
 53  
     {
 54  0
         super(message, action, resourceId);
 55  0
         if (action < CUSTOM_EVENT_ACTION_START_RANGE && action > 0)
 56  
         {
 57  0
             throw new IllegalArgumentException(
 58  
                 "Action range must be greater than CUSTOM_ACTION_START_RANGE ("
 59  
                                 + CUSTOM_EVENT_ACTION_START_RANGE + ")");
 60  
         }
 61  0
     }
 62  
 
 63  
     protected String[] getActionNames()
 64  
     {
 65  0
         return new String[]{};
 66  
     }
 67  
 }