View Javadoc

1   /*
2    * $Id: ModelNotification.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.BlockingServerEvent;
14  import org.mule.api.context.notification.ServerNotification;
15  import org.mule.api.model.Model;
16  
17  /**
18   * <code>ModelNotification</code> is fired when an event such as the model starting
19   * occurs. The payload of this event will always be a reference to the model.
20   * 
21   * @see org.mule.api.model.Model
22   */
23  public class ModelNotification extends ServerNotification implements BlockingServerEvent
24  {
25      /**
26       * Serial version
27       */
28      private static final long serialVersionUID = -1954880336427554435L;
29  
30      public static final int MODEL_INITIALISING = MODEL_EVENT_ACTION_START_RANGE + 1;
31      public static final int MODEL_INITIALISED = MODEL_EVENT_ACTION_START_RANGE + 2;
32      public static final int MODEL_INITIALISING_LISTENERS = MODEL_EVENT_ACTION_START_RANGE + 3;
33      public static final int MODEL_INITIALISED_LISTENERS = MODEL_EVENT_ACTION_START_RANGE + 4;
34      public static final int MODEL_STARTING = MODEL_EVENT_ACTION_START_RANGE + 5;
35      public static final int MODEL_STARTED = MODEL_EVENT_ACTION_START_RANGE + 6;
36      public static final int MODEL_STOPPING = MODEL_EVENT_ACTION_START_RANGE + 7;
37      public static final int MODEL_STOPPED = MODEL_EVENT_ACTION_START_RANGE + 8;
38      public static final int MODEL_DISPOSING = MODEL_EVENT_ACTION_START_RANGE + 9;
39      public static final int MODEL_DISPOSED = MODEL_EVENT_ACTION_START_RANGE + 10;
40  
41      static {
42          registerAction("model initialising", MODEL_INITIALISING);
43          registerAction("model initialised", MODEL_INITIALISED);
44          registerAction("model initialising listener", MODEL_INITIALISING_LISTENERS);
45          registerAction("model initialised listener", MODEL_INITIALISED_LISTENERS);
46          registerAction("model starting", MODEL_STARTING);
47          registerAction("model started", MODEL_STARTED);
48          registerAction("model stopping", MODEL_STOPPING);
49          registerAction("model stopped", MODEL_STOPPED);
50          registerAction("model disposing", MODEL_DISPOSING);
51          registerAction("model disposed", MODEL_DISPOSED);
52      }
53  
54      public ModelNotification(Model model, int action)
55      {
56          super(model, action);
57          resourceIdentifier = model.getName();
58      }
59  
60      protected String getPayloadToString()
61      {
62          return ((Model) source).getName();
63      }
64  }