View Javadoc

1   /*
2    * $Id: ServiceNotification.java 10787 2008-02-12 18:51:50Z 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.ServerNotification;
14  import org.mule.api.service.Service;
15  
16  /**
17   * <code>ServiceNotification</code> is fired when an event such as the service
18   * starting occurs. The payload of this event will always be a reference to the
19   * service.
20   */
21  public class ServiceNotification extends ServerNotification
22  {
23      /**
24       * Serial version
25       */
26      private static final long serialVersionUID = -8575741816897936674L;
27      public static final int SERVICE_INITIALISED = SERVICE_EVENT_ACTION_START_RANGE + 1;
28      public static final int SERVICE_STARTED = SERVICE_EVENT_ACTION_START_RANGE + 2;
29      public static final int SERVICE_STOPPED = SERVICE_EVENT_ACTION_START_RANGE + 3;
30      public static final int SERVICE_PAUSED = SERVICE_EVENT_ACTION_START_RANGE + 4;
31      public static final int SERVICE_RESUMED = SERVICE_EVENT_ACTION_START_RANGE + 5;
32      public static final int SERVICE_DISPOSED = SERVICE_EVENT_ACTION_START_RANGE + 6;
33      public static final int SERVICE_STOPPING = SERVICE_EVENT_ACTION_START_RANGE + 7;
34  
35      static {
36          registerAction("service initialised", SERVICE_INITIALISED);
37          registerAction("service started", SERVICE_STARTED);
38          registerAction("service stopping", SERVICE_STOPPING);
39          registerAction("service stopped", SERVICE_STOPPED);
40          registerAction("service paused", SERVICE_PAUSED);
41          registerAction("service resumed", SERVICE_RESUMED);
42          registerAction("service disposed", SERVICE_DISPOSED);
43      }
44  
45      public ServiceNotification(Service message, int action)
46      {
47          super(message, action);
48          resourceIdentifier = message.getName();
49      }
50  
51      protected String getPayloadToString()
52      {
53          return ((Service) source).getName();
54      }
55  }