KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > internal > notifications > ComponentNotification


1 /*
2  * $Id: ComponentNotification.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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.impl.MuleDescriptor;
14 import org.mule.umo.UMODescriptor;
15 import org.mule.umo.manager.UMOServerNotification;
16
17 /**
18  * <code>ComponentNotification</code> is fired when an event such as the component
19  * starting occurs. The payload of this event will always be a reference to the
20  * component Descriptor.
21  *
22  * @see org.mule.impl.MuleDescriptor
23  * @see org.mule.umo.UMODescriptor
24  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
25  * @version $Revision: 3798 $
26  */

27 public class ComponentNotification extends UMOServerNotification
28 {
29     /**
30      * Serial version
31      */

32     private static final long serialVersionUID = -8575741816897936674L;
33     public static final int COMPONENT_INITIALISED = COMPONENT_EVENT_ACTION_START_RANGE + 1;
34     public static final int COMPONENT_STARTED = COMPONENT_EVENT_ACTION_START_RANGE + 2;
35     public static final int COMPONENT_STOPPED = COMPONENT_EVENT_ACTION_START_RANGE + 3;
36     public static final int COMPONENT_PAUSED = COMPONENT_EVENT_ACTION_START_RANGE + 4;
37     public static final int COMPONENT_RESUMED = COMPONENT_EVENT_ACTION_START_RANGE + 5;
38     public static final int COMPONENT_DISPOSED = COMPONENT_EVENT_ACTION_START_RANGE + 6;
39     public static final int COMPONENT_STOPPING = COMPONENT_EVENT_ACTION_START_RANGE + 7;
40
41     private static final transient String JavaDoc[] ACTIONS = new String JavaDoc[]{"initialised", "started", "stopped",
42         "paused", "resumed", "disposed", "stopping"};
43
44     public ComponentNotification(UMODescriptor message, int action)
45     {
46         super(message, action);
47         resourceIdentifier = message.getName();
48     }
49
50     protected String JavaDoc getPayloadToString()
51     {
52         return ((MuleDescriptor)source).getName();
53     }
54
55     protected String JavaDoc getActionName(int action)
56     {
57         int i = action - COMPONENT_EVENT_ACTION_START_RANGE;
58         if (i - 1 > ACTIONS.length)
59         {
60             return String.valueOf(action);
61         }
62         return ACTIONS[i - 1];
63     }
64 }
65
Popular Tags