/* * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ package javax.management.remote; import java.io.ObjectInputStream; import java.util.Set; import javax.management.Attribute; import javax.management.AttributeList; import javax.management.AttributeNotFoundException; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.InvalidAttributeValueException; import javax.management.ListenerNotFoundException; import javax.management.MBeanException; import javax.management.MBeanInfo; import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; import javax.management.NotCompliantMBeanException; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.OperationsException; import javax.management.QueryExp; import javax.management.ReflectionException; import javax.management.loading.ClassLoaderRepository; /** * An {@link MBeanServerForwarder} that forwards all {@link MBeanServer} * operations unchanged to the next {@code MBeanServer} in the chain. * This class is typically subclassed to override some but not all methods. */ public class IdentityMBeanServerForwarder implements MBeanServerForwarder { private MBeanServer next; /** *
Construct a forwarder that has no next {@code MBeanServer}. * The resulting object will be unusable until {@link #setMBeanServer * setMBeanServer} is called to establish the next item in the chain.
*/ public IdentityMBeanServerForwarder() { } /** *Construct a forwarder that forwards to the given {@code MBeanServer}. * It is not an error for {@code next} to be null, but the resulting object * will be unusable until {@link #setMBeanServer setMBeanServer} is called * to establish the next item in the chain.
*/ public IdentityMBeanServerForwarder(MBeanServer next) { this.next = next; } public synchronized MBeanServer getMBeanServer() { return next; } public synchronized void setMBeanServer(MBeanServer mbs) { next = mbs; } private synchronized MBeanServer next() { return next; } public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException { next().unregisterMBean(name); } public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException { return next().setAttributes(name, attributes); } public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { next().setAttribute(name, attribute); } public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { next().removeNotificationListener(name, listener, filter, handback); } public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException { next().removeNotificationListener(name, listener); } public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { next().removeNotificationListener(name, listener, filter, handback); } public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException { next().removeNotificationListener(name, listener); } public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { return next().registerMBean(object, name); } public Set