Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ServerNotificationEmitter.java
40948 views
/*1* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package nsk.monitoring.share;2425import nsk.share.*;26import nsk.monitoring.share.*;27import javax.management.*;2829/**30* NotificationEmitter that delegates functionality to MBeanServer.31*/32public class ServerNotificationEmitter implements NotificationEmitter {33private MBeanServer mbeanServer;34private ObjectName name;3536public ServerNotificationEmitter(MBeanServer mbeanServer, ObjectName name) {37this.mbeanServer = mbeanServer;38this.name = name;39}4041public ServerNotificationEmitter(MBeanServer mbeanServer, String name) {42try {43this.mbeanServer = mbeanServer;44this.name = new ObjectName(name);45} catch (MalformedObjectNameException e) {46throw Monitoring.convertException(e);47}48}4950public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) {51try {52mbeanServer.addNotificationListener(name, listener, filter, handback);53} catch (InstanceNotFoundException e) {54throw Monitoring.convertException(e);55}56}5758public MBeanNotificationInfo[] getNotificationInfo() {59throw new TestBug("ServerNotificationEmitter.getNotificationInfo() not implemented.");60}6162public void removeNotificationListener(NotificationListener listener)63throws ListenerNotFoundException {64try {65mbeanServer.removeNotificationListener(name, listener);66} catch (InstanceNotFoundException e) {67throw Monitoring.convertException(e);68}69}7071public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)72throws ListenerNotFoundException {73try {74mbeanServer.removeNotificationListener(name, listener, filter, handback);75} catch (InstanceNotFoundException e) {76throw Monitoring.convertException(e);77}78}79}808182