01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.server.management;
22
23 import javax.management.ListenerNotFoundException;
24 import javax.management.MBeanInfo;
25 import javax.management.MBeanNotificationInfo;
26 import javax.management.NotCompliantMBeanException;
27 import javax.management.NotificationBroadcaster;
28 import javax.management.NotificationBroadcasterSupport;
29 import javax.management.NotificationFilter;
30 import javax.management.NotificationListener;
31
32 /**
33 * This class provides additinal feature of Notification Broadcaster to the
34 * DefaultManagedObject.
35 * @author Bhupendra Bhardwaj
36 * @version 0.1
37 */
38 public abstract class AMQManagedObject extends DefaultManagedObject
39 implements NotificationBroadcaster
40 {
41 /**
42 * broadcaster support class
43 */
44 protected NotificationBroadcasterSupport _broadcaster = new NotificationBroadcasterSupport();
45
46 /**
47 * sequence number for notifications
48 */
49 protected long _notificationSequenceNumber = 0;
50
51 protected MBeanInfo _mbeanInfo;
52
53 protected AMQManagedObject(Class<?> managementInterface, String typeName)
54 throws NotCompliantMBeanException
55 {
56 super(managementInterface, typeName);
57 buildMBeanInfo();
58 }
59
60 @Override
61 public MBeanInfo getMBeanInfo()
62 {
63 return _mbeanInfo;
64 }
65
66 private void buildMBeanInfo() throws NotCompliantMBeanException
67 {
68 _mbeanInfo = new MBeanInfo(this.getClass().getName(),
69 MBeanIntrospector.getMBeanDescription(this.getClass()),
70 MBeanIntrospector.getMBeanAttributesInfo(getManagementInterface()),
71 MBeanIntrospector.getMBeanConstructorsInfo(this.getClass()),
72 MBeanIntrospector.getMBeanOperationsInfo(getManagementInterface()),
73 this.getNotificationInfo());
74 }
75
76
77
78 // notification broadcaster implementation
79
80 public void addNotificationListener(NotificationListener listener,
81 NotificationFilter filter,
82 Object handback)
83 {
84 _broadcaster.addNotificationListener(listener, filter, handback);
85 }
86
87 public void removeNotificationListener(NotificationListener listener)
88 throws ListenerNotFoundException
89 {
90 _broadcaster.removeNotificationListener(listener);
91 }
92
93 public MBeanNotificationInfo[] getNotificationInfo()
94 {
95 return null;
96 }
97 }
|