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