KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > space > SpaceMonitorNotification


1 /*
2  * $Id: SpaceMonitorNotification.java 3865 2006-11-09 17:11:08Z Lajos $
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.space;
12
13 import org.mule.umo.manager.UMOServerNotification;
14 import org.mule.umo.space.UMOSpace;
15
16 /**
17  * Events that occur in UMOSpaces
18  */

19 public class SpaceMonitorNotification extends UMOServerNotification
20 {
21     /**
22      * Serial version
23      */

24     private static final long serialVersionUID = -8723048757928555644L;
25
26     public static final int SPACE_CREATED = SPACE_EVENT_ACTION_START_RANGE + 1;
27     public static final int SPACE_ITEM_ADDED = SPACE_EVENT_ACTION_START_RANGE + 2;
28     public static final int SPACE_ITEM_REMOVED = SPACE_EVENT_ACTION_START_RANGE + 3;
29     public static final int SPACE_ITEM_EXPIRED = SPACE_EVENT_ACTION_START_RANGE + 4;
30     public static final int SPACE_ITEM_MISS = SPACE_EVENT_ACTION_START_RANGE + 5;
31     public static final int SPACE_DISPOSED = SPACE_EVENT_ACTION_START_RANGE + 6;
32     public static final int SPACE_LISTENER_ADDED = SPACE_EVENT_ACTION_START_RANGE + 7;
33     public static final int SPACE_LISTENER_REMOVED = SPACE_EVENT_ACTION_START_RANGE + 8;
34
35     private static final String JavaDoc[] ACTIONS = new String JavaDoc[]{"created", "item added", "item removed",
36         "item expired", "item miss", "disposed", "listener added", "listener removed"};
37
38     private final Object JavaDoc item;
39
40     public SpaceMonitorNotification(UMOSpace space, int action, Object JavaDoc item)
41     {
42         super(space, action);
43         resourceIdentifier = space.getName();
44         this.item = item;
45     }
46
47     public Object JavaDoc getItem()
48     {
49         return item;
50     }
51
52     protected String JavaDoc getPayloadToString()
53     {
54         return ((UMOSpace)source).getName();
55     }
56
57     protected String JavaDoc getActionName(int action)
58     {
59         int i = action - SPACE_EVENT_ACTION_START_RANGE;
60         if (i - 1 > ACTIONS.length)
61         {
62             return String.valueOf(action);
63         }
64         return ACTIONS[i - 1];
65     }
66
67 }
68
Popular Tags