01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management;
10:
11: /**
12: * The notification emitted by the {@link MBeanServerDelegate delegate MBean}
13: * when an MBean is registered or unregistered.
14: *
15: * @version $Revision: 1.9 $
16: */
17: public class MBeanServerNotification extends Notification {
18: private static final long serialVersionUID = 2876477500475969677L;
19:
20: /**
21: * The type of the notification when an MBean is registered
22: */
23: public static final String REGISTRATION_NOTIFICATION = "JMX.mbean.registered";
24: /**
25: * The type of the notification when an MBean is unregistered
26: */
27: public static final String UNREGISTRATION_NOTIFICATION = "JMX.mbean.unregistered";
28:
29: /**
30: * @serial The ObjectName of the MBean that is registered or unregistered
31: */
32: private ObjectName objectName;
33:
34: /**
35: * Creates a new MBeanServerNotification.
36: *
37: * @param type Either REGISTRATION_NOTIFICATION or UNREGISTRATION_NOTIFICATION
38: * @param source The MBeanServerDelegate's ObjectName
39: * @param sequenceNumber A sequence number
40: * @param objectName The ObjectName of the MBean registered or unregistered
41: */
42: public MBeanServerNotification(String type, Object source,
43: long sequenceNumber, ObjectName objectName) {
44: super (type, source, sequenceNumber, "");
45: if (!type.equals(REGISTRATION_NOTIFICATION)
46: && !type.equals(UNREGISTRATION_NOTIFICATION)) {
47: throw new RuntimeOperationsException(
48: new IllegalArgumentException(
49: "Bad notification type for MBeanServerNotification"));
50: }
51: this .objectName = objectName;
52: }
53:
54: /**
55: * Returns the ObjectName of the MBean that was registered or unregistered
56: */
57: public ObjectName getMBeanName() {
58: return objectName;
59: }
60:
61: public String toString() {
62: StringBuffer b = new StringBuffer(super .toString());
63: b.append("[");
64: b.append(getMBeanName());
65: b.append("]");
66: return b.toString();
67: }
68: }
|