View Javadoc

1   /*
2    * $Id: ManagerNotification.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.UMOManager;
14  import org.mule.umo.manager.UMOServerNotification;
15  
16  /**
17   * <code>ManagerNotification</code> is fired when an event such as the manager
18   * starting occurs. The payload of this event will always be a reference to the
19   * manager.
20   * 
21   * @see org.mule.MuleManager
22   * @see org.mule.umo.manager.UMOManager
23   */
24  public class ManagerNotification extends UMOServerNotification implements BlockingServerEvent
25  {
26      /**
27       * Serial version
28       */
29      private static final long serialVersionUID = -3246036188011581121L;
30      public static final int MANAGER_INITIALISNG = MANAGER_EVENT_ACTION_START_RANGE + 1;
31      public static final int MANAGER_INITIALISED = MANAGER_EVENT_ACTION_START_RANGE + 2;
32      public static final int MANAGER_STARTING = MANAGER_EVENT_ACTION_START_RANGE + 3;
33      public static final int MANAGER_STARTED = MANAGER_EVENT_ACTION_START_RANGE + 4;
34      public static final int MANAGER_STOPPING = MANAGER_EVENT_ACTION_START_RANGE + 5;
35      public static final int MANAGER_STOPPED = MANAGER_EVENT_ACTION_START_RANGE + 6;
36      public static final int MANAGER_DISPOSING = MANAGER_EVENT_ACTION_START_RANGE + 7;
37      public static final int MANAGER_DISPOSED = MANAGER_EVENT_ACTION_START_RANGE + 8;
38      public static final int MANAGER_DISPOSING_CONNECTORS = MANAGER_EVENT_ACTION_START_RANGE + 9;
39      public static final int MANAGER_DISPOSED_CONNECTORS = MANAGER_EVENT_ACTION_START_RANGE + 10;
40      public static final int MANAGER_STARTING_MODELS = MANAGER_EVENT_ACTION_START_RANGE + 11;
41      public static final int MANAGER_STARTED_MODELS = MANAGER_EVENT_ACTION_START_RANGE + 12;
42      public static final int MANAGER_STOPPING_MODELS = MANAGER_EVENT_ACTION_START_RANGE + 13;
43      public static final int MANAGER_STOPPED_MODELS = MANAGER_EVENT_ACTION_START_RANGE + 14;
44  
45      private static final transient String[] ACTIONS = new String[]{"initialising", "initialised", "starting",
46          "started", "stopping", "stopped", "disposing", "disposed", "disposing connectors",
47          "disposed connectors", "starting models", "started models", "stopping models", "stopped models"};
48  
49      public ManagerNotification(UMOManager message, int action)
50      {
51          super(message, action);
52          resourceIdentifier = message.getId();
53      }
54  
55      protected String getPayloadToString()
56      {
57          return ((UMOManager) source).getId();
58      }
59  
60      protected String getActionName(int action)
61      {
62          int i = action - MANAGER_EVENT_ACTION_START_RANGE;
63          if (i - 1 > ACTIONS.length)
64          {
65              return String.valueOf(action);
66          }
67          return ACTIONS[i - 1];
68      }
69  
70      public String toString()
71      {
72          return EVENT_NAME + "{" + "action=" + getActionName(action) + ", resourceId=" + resourceIdentifier
73                 + ", timestamp=" + timestamp + "}";
74      }
75  }