Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CustomNotification |
|
| 2.3333333333333335;2.333 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.context.notification; | |
8 | ||
9 | import org.mule.api.context.notification.CustomNotificationListener; | |
10 | import org.mule.api.context.notification.ServerNotification; | |
11 | ||
12 | /** | |
13 | * <code>CustomNotification</code> Custom notifications can be used by components | |
14 | * and other objects such as routers, transformers, agents, etc to communicate a | |
15 | * change of state to each other. The Action value for the event is abitary. However | |
16 | * care should be taken not to set the action code to an existing action code. To | |
17 | * ensure this doesn't happen always set the action code greater than the | |
18 | * CUSTOM_ACTION_START_RANGE. | |
19 | * | |
20 | * @see CustomNotificationListener | |
21 | */ | |
22 | public class CustomNotification extends ServerNotification | |
23 | { | |
24 | /** | |
25 | * Serial version | |
26 | */ | |
27 | private static final long serialVersionUID = 762448139858484536L; | |
28 | ||
29 | /** | |
30 | * Creates a custom action event | |
31 | * | |
32 | * @param message the message to associate with the event | |
33 | * @param action the action code for the event | |
34 | * @throws IllegalArgumentException if the action value is less than | |
35 | * CUSTOM_ACTION_START_RANGE | |
36 | */ | |
37 | public CustomNotification(Object message, int action) | |
38 | { | |
39 | 0 | super(message, action); |
40 | 0 | if (action < CUSTOM_EVENT_ACTION_START_RANGE && action > 0) |
41 | { | |
42 | 0 | throw new IllegalArgumentException( |
43 | "Action range must be greater than CUSTOM_ACTION_START_RANGE (" | |
44 | + CUSTOM_EVENT_ACTION_START_RANGE + ")"); | |
45 | } | |
46 | 0 | } |
47 | ||
48 | public CustomNotification(Object message, int action, String resourceId) | |
49 | { | |
50 | 0 | super(message, action, resourceId); |
51 | 0 | if (action < CUSTOM_EVENT_ACTION_START_RANGE && action > 0) |
52 | { | |
53 | 0 | throw new IllegalArgumentException( |
54 | "Action range must be greater than CUSTOM_ACTION_START_RANGE (" | |
55 | + CUSTOM_EVENT_ACTION_START_RANGE + ")"); | |
56 | } | |
57 | 0 | } |
58 | ||
59 | protected String[] getActionNames() | |
60 | { | |
61 | 0 | return new String[]{}; |
62 | } | |
63 | } |