View Javadoc

1   /*
2    * $Id: AdminNotification.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.UMOMessage;
14  import org.mule.umo.manager.UMOServerNotification;
15  
16  import java.util.HashMap;
17  import java.util.Map;
18  
19  /**
20   * <code>AdminNotification</code> is used to invoke actions on a remote mule server
21   */
22  
23  public class AdminNotification extends UMOServerNotification
24  {
25      /**
26       * Serial version
27       */
28      private static final long serialVersionUID = -53091546441476249L;
29      public static final int ACTION_RECEIVE = ADMIN_EVENT_ACTION_START_RANGE + 1;
30      public static final int ACTION_DISPATCH = ADMIN_EVENT_ACTION_START_RANGE + 2;
31      public static final int ACTION_SEND = ADMIN_EVENT_ACTION_START_RANGE + 3;
32      public static final int ACTION_INVOKE = ADMIN_EVENT_ACTION_START_RANGE + 4;
33  
34      private static final transient String[] ACTIONS = new String[]{"receive event", "dispatch event",
35          "send event", "invoke component"};
36  
37      private Map properties = new HashMap();
38      private UMOMessage message;
39  
40      public AdminNotification(UMOMessage message, int action, String resourceIdentifier)
41      {
42          super(message, action, resourceIdentifier);
43          this.message = message;
44      }
45  
46      public UMOMessage getMessage()
47      {
48          return message;
49      }
50  
51      public void setProperty(Object key, Object value)
52      {
53          properties.put(key, value);
54      }
55  
56      public Object getProperty(Object key)
57      {
58          return properties.get(key);
59      }
60  
61      public Map getProperties()
62      {
63          return properties;
64      }
65  
66      protected String getActionName(int action)
67      {
68          int i = action - ADMIN_EVENT_ACTION_START_RANGE;
69          if (i - 1 > ACTIONS.length)
70          {
71              return String.valueOf(action);
72          }
73          return ACTIONS[i - 1];
74      }
75  }