715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * This code is free software; you can redistribute it and/or modify it
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * under the terms of the GNU General Public License version 2 only, as
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * published by the Free Software Foundation. Oracle designates this
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * particular file as subject to the "Classpath" exception as provided
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * by Oracle in the LICENSE file that accompanied this code.
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * This code is distributed in the hope that it will be useful, but WITHOUT
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c0b6af690ad705bddfa87c643b89770a7a0aaf5avboxsync * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * version 2 for more details (a copy is included in the LICENSE file that
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * accompanied this code).
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * You should have received a copy of the GNU General Public License version
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * 2 along with this work; if not, write to the Free Software Foundation,
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * or visit www.oracle.com if you need additional information or have any
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync * questions.
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport static com.sun.jmx.defaults.JmxProperties.MISC_LOGGER;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport com.sun.jmx.mbeanserver.StandardMBeanSupport;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanAttributeInfo;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanAttributeInfoSupport;
7674ee2f976dc48f8777b0e4aa1e0894e4b48a87vboxsyncimport javax.management.openmbean.OpenMBeanConstructorInfo;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanConstructorInfoSupport;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanOperationInfo;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanOperationInfoSupport;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanParameterInfo;
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncimport javax.management.openmbean.OpenMBeanParameterInfoSupport;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>An MBean whose management interface is determined by reflection
0e9bee76f5b28d974b91a2a66c61a36751d4a2c7vboxsync * on a Java interface.</p>
0e9bee76f5b28d974b91a2a66c61a36751d4a2c7vboxsync * <p>This class brings more flexibility to the notion of Management
34edf41b7b7cb5219f0ce1b172e131ae7520ae83vboxsync * Interface in the use of Standard MBeans. Straightforward use of
34edf41b7b7cb5219f0ce1b172e131ae7520ae83vboxsync * the patterns for Standard MBeans described in the JMX Specification
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * means that there is a fixed relationship between the implementation
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * class of an MBean and its management interface (i.e., if the
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * implementation class is Thing, the management interface must be
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * ThingMBean). This class makes it possible to keep the convenience
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * of specifying the management interface with a Java interface,
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * without requiring that there be any naming relationship between the
34edf41b7b7cb5219f0ce1b172e131ae7520ae83vboxsync * implementation and interface classes.</p>
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * <p>By making a DynamicMBean out of an MBean, this class makes
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * it possible to select any interface implemented by the MBean as its
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * management interface, provided that it complies with JMX patterns
eda35f91dbe2b4e221daaab631ef5eb225224185vboxsync * (i.e., attributes defined by getter/setter etc...).</p>
0e9bee76f5b28d974b91a2a66c61a36751d4a2c7vboxsync * <p> This class also provides hooks that make it possible to supply
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync * custom descriptions and names for the {@link MBeanInfo} returned by
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync * the DynamicMBean interface.</p>
9454ea53d45685cd1eab5d21376ae7921b93242avboxsync * <p>Using this class, an MBean can be created with any
af204635b63db99d98ba8dfcf4b952708bfe2ac5vboxsync * implementation class name <i>Impl</i> and with a management
af204635b63db99d98ba8dfcf4b952708bfe2ac5vboxsync * interface defined (as for current Standard MBeans) by any interface
9454ea53d45685cd1eab5d21376ae7921b93242avboxsync * <i>Intf</i>, in one of two general ways:</p>
dda81d519b6d284ba60a7544bc74b850c8ff0d7avboxsync * <li>Using the public constructor
dda81d519b6d284ba60a7544bc74b850c8ff0d7avboxsync * {@link #StandardMBean(java.lang.Object, java.lang.Class, boolean)
dda81d519b6d284ba60a7544bc74b850c8ff0d7avboxsync * StandardMBean(impl,interface)}:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBeanServer mbs;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Impl impl = new Impl(...);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * StandardMBean mbean = new StandardMBean(impl, Intf.class, false);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * mbs.registerMBean(mbean, objectName);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * </pre></li>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <li>Subclassing StandardMBean:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * public class Impl extends StandardMBean implements Intf {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * public Impl() {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * super(Intf.class, false);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * // implement methods of Intf
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBeanServer mbs;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Impl impl = new Impl();
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * mbs.registerMBean(impl, objectName);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * </pre></li>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>In either case, the class <i>Impl</i> must implement the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * interface <i>Intf</i>.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Standard MBeans based on the naming relationship between
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation and interface classes are of course still
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * available.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>This class may also be used to construct MXBeans. The usage
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * is exactly the same as for Standard MBeans except that in the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * examples above, the {@code false} parameter to the constructor or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@code super(...)} invocation is instead {@code true}.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @since 1.5
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsyncpublic class StandardMBean implements DynamicMBean, MBeanRegistration {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * The DynamicMBean that wraps the MXBean or Standard MBean implementation.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * The cached MBeanInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Make a DynamicMBean out of <var>implementation</var>, using the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * specified <var>mbeanInterface</var> class.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param implementation The implementation of this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * If <code>null</code>, and null implementation is allowed,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * then the implementation is assumed to be <var>this</var>.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param mbeanInterface The Management Interface exported by this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBean's implementation. If <code>null</code>, then this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * object will use standard JMX design pattern to determine
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * the management interface associated with the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param nullImplementationAllowed <code>true</code> if a null
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation is allowed. If null implementation is allowed,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * and a null implementation is passed, then the implementation
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * is assumed to be <var>this</var>.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception IllegalArgumentException if the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var> is null, and null is not allowed.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync private <T> void construct(T implementation, Class<T> mbeanInterface,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // Have to use (T)this rather than mbeanInterface.cast(this)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // because mbeanInterface might be null.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync else throw new IllegalArgumentException("implementation is null");
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync mbeanInterface = Util.cast(Introspector.getMXBeanInterface(
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync this.mbean = new MXBeanSupport(implementation, mbeanInterface);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync mbeanInterface = Util.cast(Introspector.getStandardMBeanInterface(
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync new StandardMBeanSupport(implementation, mbeanInterface);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Make a DynamicMBean out of the object
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var>, using the specified
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>mbeanInterface</var> class.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param implementation The implementation of this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param mbeanInterface The Management Interface exported by this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBean's implementation. If <code>null</code>, then this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * object will use standard JMX design pattern to determine
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * the management interface associated with the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param <T> Allows the compiler to check
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * that {@code implementation} does indeed implement the class
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * described by {@code mbeanInterface}. The compiler can only
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * check this if {@code mbeanInterface} is a class literal such
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * as {@code MyMBean.class}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception IllegalArgumentException if the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var> is null.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception NotCompliantMBeanException if the <var>mbeanInterface</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * does not follow JMX design patterns for Management Interfaces, or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * if the given <var>implementation</var> does not implement the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * specified interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public <T> StandardMBean(T implementation, Class<T> mbeanInterface)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync construct(implementation, mbeanInterface, false, false);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Make a DynamicMBean out of <var>this</var>, using the specified
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>mbeanInterface</var> class.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Calls {@link #StandardMBean(java.lang.Object, java.lang.Class)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * this(this,mbeanInterface)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * This constructor is reserved to subclasses.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param mbeanInterface The Management Interface exported by this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception NotCompliantMBeanException if the <var>mbeanInterface</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * does not follow JMX design patterns for Management Interfaces, or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * if <var>this</var> does not implement the specified interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Make a DynamicMBean out of the object
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var>, using the specified
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>mbeanInterface</var> class, and choosing whether the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * resultant MBean is an MXBean. This constructor can be used
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * to make either Standard MBeans or MXBeans. Unlike the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * constructor {@link #StandardMBean(Object, Class)}, it
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * does not throw NotCompliantMBeanException.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param implementation The implementation of this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param mbeanInterface The Management Interface exported by this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBean's implementation. If <code>null</code>, then this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * object will use standard JMX design pattern to determine
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * the management interface associated with the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param isMXBean If true, the {@code mbeanInterface} parameter
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * names an MXBean interface and the resultant MBean is an MXBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param <T> Allows the compiler to check
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * that {@code implementation} does indeed implement the class
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * described by {@code mbeanInterface}. The compiler can only
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * check this if {@code mbeanInterface} is a class literal such
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * as {@code MyMBean.class}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception IllegalArgumentException if the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var> is null, or if the <var>mbeanInterface</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * does not follow JMX design patterns for Management Interfaces, or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * if the given <var>implementation</var> does not implement the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * specified interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @since 1.6
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public <T> StandardMBean(T implementation, Class<T> mbeanInterface,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync construct(implementation, mbeanInterface, false, isMXBean);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Make a DynamicMBean out of <var>this</var>, using the specified
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>mbeanInterface</var> class, and choosing whether the resulting
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBean is an MXBean. This constructor can be used
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * to make either Standard MBeans or MXBeans. Unlike the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * constructor {@link #StandardMBean(Object, Class)}, it
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * does not throw NotCompliantMBeanException.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Calls {@link #StandardMBean(java.lang.Object, java.lang.Class, boolean)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * this(this, mbeanInterface, isMXBean)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * This constructor is reserved to subclasses.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param mbeanInterface The Management Interface exported by this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param isMXBean If true, the {@code mbeanInterface} parameter
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * names an MXBean interface and the resultant MBean is an MXBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception IllegalArgumentException if the <var>mbeanInterface</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * does not follow JMX design patterns for Management Interfaces, or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * if <var>this</var> does not implement the specified interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @since 1.6
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected StandardMBean(Class<?> mbeanInterface, boolean isMXBean) {
f2cc35c5affd2fc618b3fd5379f67d5e424b5d04vboxsync * <p>Replace the implementation object wrapped in this object.</p>
f2cc35c5affd2fc618b3fd5379f67d5e424b5d04vboxsync * @param implementation The new implementation of this Standard MBean
f2cc35c5affd2fc618b3fd5379f67d5e424b5d04vboxsync * (or MXBean). The <code>implementation</code> object must implement
f2cc35c5affd2fc618b3fd5379f67d5e424b5d04vboxsync * the Standard MBean (or MXBean) interface that was supplied when this
f2cc35c5affd2fc618b3fd5379f67d5e424b5d04vboxsync * <code>StandardMBean</code> was constructed.
f2cc35c5affd2fc618b3fd5379f67d5e424b5d04vboxsync * @exception IllegalArgumentException if the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var> is null.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @exception NotCompliantMBeanException if the given
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>implementation</var> does not implement the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Standard MBean (or MXBean) interface that was
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * supplied at construction.
4e4a8e041182dff5c52892bee58a5d8f58f4bdadvboxsync * @see #getImplementation
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public void setImplementation(Object implementation)
7fa1e4735b385f437dc86c75f13ef1b9a1e19e86vboxsync throw new IllegalArgumentException("implementation is null");
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync this.mbean = new StandardMBeanSupport(implementation,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the implementation of this Standard MBean (or MXBean).
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return The implementation of this Standard MBean (or MXBean).
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @see #setImplementation
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the Management Interface of this Standard MBean (or MXBean).
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return The management interface of this Standard MBean (or MXBean).
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the class of the implementation of this Standard MBean (or MXBean).
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync * @return The class of the implementation of this Standard MBean (or MXBean).
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync // ------------------------------------------------------------------
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync // From the DynamicMBean interface.
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync // ------------------------------------------------------------------
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync // ------------------------------------------------------------------
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync // From the DynamicMBean interface.
db1b3939027d4f297c8ca7a4e5da3168baefea2avboxsync // ------------------------------------------------------------------
31771163041e3661403a806eb3382d2a165c003bvboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // From the DynamicMBean interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public AttributeList getAttributes(String[] attributes) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // From the DynamicMBean interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public AttributeList setAttributes(AttributeList attributes) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // From the DynamicMBean interface.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public Object invoke(String actionName, Object params[], String signature[])
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return mbean.invoke(actionName, params, signature);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Get the {@link MBeanInfo} for this MBean.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * This method implements
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * {@link javax.management.DynamicMBean#getMBeanInfo()
cc4aab23dd31c9fb50c17bb4f3e90b401160c1b5vboxsync * DynamicMBean.getMBeanInfo()}.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * This method first calls {@link #getCachedMBeanInfo()} in order to
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * retrieve the cached MBeanInfo for this MBean, if any. If the
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * MBeanInfo returned by {@link #getCachedMBeanInfo()} is not null,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * then it is returned.<br>
9d091bd19338b94d7dae910bf5767923ef6d4562vboxsync * Otherwise, this method builds a default MBeanInfo for this MBean,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * using the Management Interface specified for this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * While building the MBeanInfo, this method calls the customization
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * hooks that make it possible for subclasses to supply their custom
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * descriptions, parameter names, etc...<br>
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Finally, it calls {@link #cacheMBeanInfo(javax.management.MBeanInfo)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * cacheMBeanInfo()} in order to cache the new MBeanInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return The cached MBeanInfo for that MBean, if not null, or a
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * newly built MBeanInfo if none was cached.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync MBeanServerFactory.class.getName(), "getMBeanInfo",
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync "Failed to get cached MBeanInfo", x);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync MBeanServerFactory.class.getName(), "getMBeanInfo",
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync "Building MBeanInfo for " +
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final boolean immutableInfo = immutableInfo(this.getClass());
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanConstructorInfo[] ctors = getConstructors(bi,impl);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanAttributeInfo[] attrs = getAttributes(bi);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanOperationInfo[] ops = getOperations(bi);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanNotificationInfo[] ntfs = getNotifications(bi);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final Descriptor desc = getDescriptor(bi, immutableInfo);
f455158a85f95b4886cbe7154b067144b815c125vboxsync MBeanServerFactory.class.getName(), "getMBeanInfo",
96ae72f2a0b572599ee8b3f95907beeb66bfbf72vboxsync "Failed to cache MBeanInfo", x);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
cb13d6af84f80841e712dd344158f2e2bdb1a8b2vboxsync * Get the className that will be used in the MBeanInfo returned by
cb13d6af84f80841e712dd344158f2e2bdb1a8b2vboxsync * this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom class name. The default implementation returns
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link MBeanInfo#getClassName() info.getClassName()}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the class name for the new MBeanInfo.
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync if (info == null) return getImplementationClass().getName();
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * Customization hook:
2a0a20dee7f474c26cc8f6f9d7aa12c345c2b73bvboxsync * Get the description that will be used in the MBeanInfo returned by
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * this MBean.
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * Subclasses may redefine this method in order to supply their
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * custom MBean description. The default implementation returns
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * {@link MBeanInfo#getDescription() info.getDescription()}.
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * @param info The default MBeanInfo derived by reflection.
e52b0dfe3d9ead70e24f2ce4ed3faa6c79c00618vboxsync * @return the description for the new MBeanInfo.
7757e065b2ef522ec99a434fbeeae8665a36543avboxsync * <p>Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the description that will be used in the MBeanFeatureInfo
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * returned by this MBean.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Subclasses may redefine this method in order to supply
dbc6ecd6a6e372b8dcdf31d68bdab2d5b5e604d2vboxsync * their custom description. The default implementation returns
dbc6ecd6a6e372b8dcdf31d68bdab2d5b5e604d2vboxsync * {@link MBeanFeatureInfo#getDescription()
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * info.getDescription()}.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>This method is called by
dbc6ecd6a6e372b8dcdf31d68bdab2d5b5e604d2vboxsync * {@link #getDescription(MBeanAttributeInfo)},
7757e065b2ef522ec99a434fbeeae8665a36543avboxsync * {@link #getDescription(MBeanOperationInfo)},
dbc6ecd6a6e372b8dcdf31d68bdab2d5b5e604d2vboxsync * {@link #getDescription(MBeanConstructorInfo)}.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanFeatureInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the description for the given MBeanFeatureInfo.
dbc6ecd6a6e372b8dcdf31d68bdab2d5b5e604d2vboxsync protected String getDescription(MBeanFeatureInfo info) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the description that will be used in the MBeanAttributeInfo
dbc6ecd6a6e372b8dcdf31d68bdab2d5b5e604d2vboxsync * returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom description. The default implementation returns {@link
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * #getDescription(MBeanFeatureInfo)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * getDescription((MBeanFeatureInfo) info)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanAttributeInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the description for the given MBeanAttributeInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getDescription(MBeanAttributeInfo info) {
036edb9371a19903dd703cdb959348a2726d7a38vboxsync * Customization hook:
ab455939477d81b7bb500586f88029d3a3c0b34cvboxsync * Get the description that will be used in the MBeanConstructorInfo
036edb9371a19903dd703cdb959348a2726d7a38vboxsync * returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom description.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * The default implementation returns {@link
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * #getDescription(MBeanFeatureInfo)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * getDescription((MBeanFeatureInfo) info)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanConstructorInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the description for the given MBeanConstructorInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getDescription(MBeanConstructorInfo info) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the description that will be used for the <var>sequence</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
2a2b173b54c259e34320ce0acf26f18e9382ce2avboxsync * Subclasses may redefine this method in order to supply their
2a2b173b54c259e34320ce0acf26f18e9382ce2avboxsync * custom description. The default implementation returns
2a2b173b54c259e34320ce0acf26f18e9382ce2avboxsync * {@link MBeanParameterInfo#getDescription() param.getDescription()}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param ctor The default MBeanConstructorInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param param The default MBeanParameterInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param sequence The sequence number of the parameter considered
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * ("0" for the first parameter, "1" for the second parameter,
f455158a85f95b4886cbe7154b067144b815c125vboxsync * @return the description for the given MBeanParameterInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getDescription(MBeanConstructorInfo ctor,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
97a22e235416469499b353dfec11fc90c79df178vboxsync * Get the name that will be used for the <var>sequence</var>
97a22e235416469499b353dfec11fc90c79df178vboxsync * MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom parameter name. The default implementation returns
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link MBeanParameterInfo#getName() param.getName()}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param ctor The default MBeanConstructorInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param param The default MBeanParameterInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param sequence The sequence number of the parameter considered
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * ("0" for the first parameter, "1" for the second parameter,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the name for the given MBeanParameterInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getParameterName(MBeanConstructorInfo ctor,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the description that will be used in the MBeanOperationInfo
a2e54e22e7687863f9b4020659bcb6436d5a9963vboxsync * returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom description. The default implementation returns
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link #getDescription(MBeanFeatureInfo)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * getDescription((MBeanFeatureInfo) info)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanOperationInfo derived by reflection.
54d2d2606d7c83a456819cd038a73e0f9a600ca4vboxsync * @return the description for the given MBeanOperationInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getDescription(MBeanOperationInfo info) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the <var>impact</var> flag of the operation that will be used in
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * the MBeanOperationInfo returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom impact flag. The default implementation returns
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link MBeanOperationInfo#getImpact() info.getImpact()}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanOperationInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the impact flag for the given MBeanOperationInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync if (info == null) return MBeanOperationInfo.UNKNOWN;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the name that will be used for the <var>sequence</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom parameter name. The default implementation returns
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link MBeanParameterInfo#getName() param.getName()}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param op The default MBeanOperationInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param param The default MBeanParameterInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param sequence The sequence number of the parameter considered
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * ("0" for the first parameter, "1" for the second parameter,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the name to use for the given MBeanParameterInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getParameterName(MBeanOperationInfo op,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the description that will be used for the <var>sequence</var>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom description. The default implementation returns
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link MBeanParameterInfo#getDescription() param.getDescription()}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param op The default MBeanOperationInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param param The default MBeanParameterInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param sequence The sequence number of the parameter considered
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * ("0" for the first parameter, "1" for the second parameter,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the description for the given MBeanParameterInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync protected String getDescription(MBeanOperationInfo op,
71955773a7f477f9a159a491f765ba97e1f00e1avboxsync * Customization hook:
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync * Get the MBeanConstructorInfo[] that will be used in the MBeanInfo
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * returned by this MBean.
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * By default, this method returns <code>null</code> if the wrapped
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation is not <var>this</var>. Indeed, if the wrapped
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * implementation is not this object itself, it will not be possible
69e691ae98ad8d1b3c697e22704da6f73fa1dbedvboxsync * to recreate a wrapped implementation by calling the implementation
71955773a7f477f9a159a491f765ba97e1f00e1avboxsync * constructors through <code>MBeanServer.createMBean(...)</code>.<br>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Otherwise, if the wrapped implementation is <var>this</var>,
d462687a4bb8aa43108a06b1cdfde02c49037b1bvboxsync * <var>ctors</var> is returned.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to modify this
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * behavior, if needed.
0c8e85263a357c44964520942cb5816ab1c2e69dvboxsync * @param ctors The default MBeanConstructorInfo[] derived by reflection.
d1bb48754376874c3cc6b1091a6abec549663c0cvboxsync * @param impl The wrapped implementation. If <code>null</code> is
4bf996d915405be92dc4394b2db1395e00e14d58vboxsync * passed, the wrapped implementation is ignored and
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <var>ctors</var> is returned.
800f04f116f4749015385fac39c12ba0166813c1vboxsync * @return the MBeanConstructorInfo[] for the new MBeanInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync getConstructors(MBeanConstructorInfo[] ctors, Object impl) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Get the MBeanNotificationInfo[] that will be used in the MBeanInfo
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * returned by this MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Subclasses may redefine this method in order to supply their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * custom notifications.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the MBeanNotificationInfo[] for the new MBeanInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync MBeanNotificationInfo[] getNotifications(MBeanInfo info) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Get the Descriptor that will be used in the MBeanInfo
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * returned by this MBean.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Subclasses may redefine this method in order to supply
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * their custom descriptor.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>The default implementation of this method returns a Descriptor
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * that contains at least the field {@code interfaceClassName}, with
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * value {@link #getMBeanInterface()}.getName(). It may also contain
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * the field {@code immutableInfo}, with a value that is the string
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@code "true"} if the implementation can determine that the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@code MBeanInfo} returned by {@link #getMBeanInfo()} will always
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * be the same. It may contain other fields: fields defined by the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * JMX specification must have appropriate values, and other fields
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * must follow the conventions for non-standard field names.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info The default MBeanInfo derived by reflection.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return the Descriptor for the new MBeanInfo.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync Descriptor getDescriptor(MBeanInfo info, boolean immutableInfo) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync info.getDescriptor().getFieldNames().length == 0) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync "interfaceClassName=" + getMBeanInterface().getName();
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync desc = new ImmutableDescriptor(interfaceClassNameS, immutableInfoS);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync Map<String,Object> fields = new HashMap<String,Object>();
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // Replace immutableInfo as the underlying MBean/MXBean
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // could already implement NotificationBroadcaster and
6a11a038ef83aba6a5e744e92acb8ce1a48db2b7vboxsync // return immutableInfo=true in its MBeanInfo.
6a11a038ef83aba6a5e744e92acb8ce1a48db2b7vboxsync fields.put(fieldName, Boolean.toString(immutableInfo));
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Return the MBeanInfo cached for this object.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Subclasses may redefine this method in order to implement their
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * own caching policy. The default implementation stores one
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@link MBeanInfo} object per instance.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return The cached MBeanInfo, or null if no MBeanInfo is cached.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @see #cacheMBeanInfo(MBeanInfo)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Customization hook:
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * cache the MBeanInfo built for this object.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Subclasses may redefine this method in order to implement
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * their own caching policy. The default implementation stores
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <code>info</code> in this instance. A subclass can define
65169cfba1adfc4c86c2b6b99a0b8e67ed216a23vboxsync * other policies, such as not saving <code>info</code> (so it is
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * reconstructed every time {@link #getMBeanInfo()} is called) or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * sharing a unique {@link MBeanInfo} object when several
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <code>StandardMBean</code> instances have equal {@link
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBeanInfo} values.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @param info the new <code>MBeanInfo</code> to cache. Any
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * previously cached value is discarded. This parameter may be
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * null, in which case there is no new cached value.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync private static <T> boolean identicalArrays(T[] a, T[] b) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync if (a == b)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return true;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync if (a == null || b == null || a.length != b.length)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return false;
78617101552bfc0ac15031a25353d67fe049fd8evboxsync if (a[i] != b[i])
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return false;
78617101552bfc0ac15031a25353d67fe049fd8evboxsync return true;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync if (a == b)
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return true;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return false;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return a.equals(b);
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync OpenMBeanParameterInfo opi = (OpenMBeanParameterInfo) pi;
dd3b708fb52e912a0a07fab811a5427d5abf15e6vboxsync return new OpenMBeanConstructorInfoSupport(ci.getName(),
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return new OpenMBeanOperationInfoSupport(oi.getName(),
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return new OpenMBeanAttributeInfoSupport(ai.getName(),
4f4877d6f6ea6dbe54cba4595450e5c837d5d419vboxsync private static OpenMBeanParameterInfo[]
4f4877d6f6ea6dbe54cba4595450e5c837d5d419vboxsync System.arraycopy(params, 0, oparams, 0, params.length);
4f4877d6f6ea6dbe54cba4595450e5c837d5d419vboxsync // ------------------------------------------------------------------
4f4877d6f6ea6dbe54cba4595450e5c837d5d419vboxsync // Build the custom MBeanConstructorInfo[]
4f4877d6f6ea6dbe54cba4595450e5c837d5d419vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanConstructorInfo[] nctors = new MBeanConstructorInfo[ctorlen];
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanParameterInfo[] params = c.getSignature();
917bfda215593dc13467684ab6bfa6b7f67cc5d2vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // Build the custom MBeanOperationInfo[]
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync private MBeanOperationInfo[] getOperations(MBeanInfo info) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanOperationInfo[] ops = info.getOperations();
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanOperationInfo[] nops = new MBeanOperationInfo[oplen];
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanParameterInfo[] params = o.getSignature();
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync nops[i] = customize(o, getDescription(o), nps, getImpact(o));
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // Build the custom MBeanAttributeInfo[]
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // ------------------------------------------------------------------
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync private MBeanAttributeInfo[] getAttributes(MBeanInfo info) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync final MBeanAttributeInfo[] atts = info.getAttributes();
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Allows the MBean to perform any operations it needs before
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * being registered in the MBean server. If the name of the MBean
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * is not specified, the MBean can provide a name for its
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * registration. If any exception is raised, the MBean will not be
69e691ae98ad8d1b3c697e22704da6f73fa1dbedvboxsync * registered in the MBean server.</p>
9c2f0f35331ebfb1809126f5d6e30b2b4a889360vboxsync * <p>The default implementation of this method returns the {@code name}
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * parameter. It does nothing else for
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Standard MBeans. For MXBeans, it records the {@code MBeanServer}
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * and {@code ObjectName} parameters so they can be used to translate
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * inter-MXBean references.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>It is good practice for a subclass that overrides this method
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * to call the overridden method via {@code super.preRegister(...)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * This is necessary if this object is an MXBean that is referenced
d1bb48754376874c3cc6b1091a6abec549663c0cvboxsync * by attributes or operations in other MXBeans.</p>
3f2f91afeed4e8cb37bea26c44380ea8252103a0vboxsync * @param server The MBean server in which the MBean will be registered.
1eda04de692c4c416332941e87bab4cc8fc45a18vboxsync * @param name The object name of the MBean. This name is null if
1eda04de692c4c416332941e87bab4cc8fc45a18vboxsync * the name parameter to one of the <code>createMBean</code> or
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <code>registerMBean</code> methods in the {@link MBeanServer}
d1bb48754376874c3cc6b1091a6abec549663c0cvboxsync * interface is null. In that case, this method must return a
4e055140bcd2406a7ebade59f30db5ca8d13219cvboxsync * non-null ObjectName for the new MBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @return The name under which the MBean is to be registered.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * This value must not be null. If the <code>name</code>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * parameter is not null, it will usually but not necessarily be
00fc6ac8df60b81c37900a4e987a0d02bac39903vboxsync * the returned value.
a2af3325cd2539bfcca532f15b1c7683272888cevboxsync * @throws IllegalArgumentException if this is an MXBean and
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * {@code name} is null.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @throws InstanceAlreadyExistsException if this is an MXBean and
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * it has already been registered under another name (in this
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * MBean Server or another).
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @throws Exception no other checked exceptions are thrown by
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * this method but {@code Exception} is declared so that subclasses
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * can override the method and throw their own exceptions.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @since 1.6
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public ObjectName preRegister(MBeanServer server, ObjectName name)
d1bb48754376874c3cc6b1091a6abec549663c0cvboxsync * <p>Allows the MBean to perform any operations needed after having been
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * registered in the MBean server or after the registration has failed.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>The default implementation of this method does nothing for
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Standard MBeans. For MXBeans, it undoes any work done by
939e2ecb812c6402abcc63e7d615c5444acfd02evboxsync * {@link #preRegister preRegister} if registration fails.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>It is good practice for a subclass that overrides this method
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * to call the overridden method via {@code super.postRegister(...)}.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * This is necessary if this object is an MXBean that is referenced
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * by attributes or operations in other MXBeans.</p>
1729795f504cc1975ec195bca8b493c2faa0f5ddvboxsync * @param registrationDone Indicates whether or not the MBean has
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * been successfully registered in the MBean server. The value
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * false means that the registration phase has failed.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @since 1.6
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync public void postRegister(Boolean registrationDone) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>Allows the MBean to perform any operations it needs before
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * being unregistered by the MBean server.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>The default implementation of this method does nothing.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>It is good practice for a subclass that overrides this method
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * to call the overridden method via {@code super.preDeregister(...)}.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @throws Exception no checked exceptions are throw by this method
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * but {@code Exception} is declared so that subclasses can override
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * this method and throw their own exceptions.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * @since 1.6
ed65cb72708fa824c83162ab8604d35e90f78ce9vboxsync * <p>Allows the MBean to perform any operations needed after having been
b8601aa57872ad208a7ef5facab06c61d7886d60vboxsync * unregistered in the MBean server.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>The default implementation of this method does nothing for
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Standard MBeans. For MXBeans, it removes any information that
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * was recorded by the {@link #preRegister preRegister} method.</p>
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * <p>It is good practice for a subclass that overrides this method
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * to call the overridden method via {@code super.postRegister(...)}.
4dcf37df51439573b55cc16f53590c7b68cb1051vboxsync * This is necessary if this object is an MXBean that is referenced
4dcf37df51439573b55cc16f53590c7b68cb1051vboxsync * by attributes or operations in other MXBeans.</p>
4dcf37df51439573b55cc16f53590c7b68cb1051vboxsync * @since 1.6
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // MBeanInfo immutability
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Cached results of previous calls to immutableInfo. This is
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * a WeakHashMap so that we don't prevent a class from being
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * garbage collected just because we know whether its MBeanInfo
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * is immutable.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync private static final Map<Class<?>, Boolean> mbeanInfoSafeMap =
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * Return true if {@code subclass} is known to preserve the immutability
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * of the {@code MBeanInfo}. The {@code subclass} is considered to have
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * an immutable {@code MBeanInfo} if it does not override any of the
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync * getMBeanInfo, getCachedMBeanInfo, cacheMBeanInfo and getNotificationInfo
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync static boolean immutableInfo(Class<? extends StandardMBean> subclass) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return true;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync synchronized (mbeanInfoSafeMap) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync /* We don't know, so we assume it isn't. */
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync static boolean overrides(Class<?> subclass, Class<?> superclass,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync for (Class<?> c = subclass; c != superclass; c = c.getSuperclass()) {
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return true;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // OK: this class doesn't override it
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return false;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync // Check for "void cacheMBeanInfo(MBeanInfo)" method.
f5edc444546b57af847ae33f2bd1e10442496e47vboxsync return false;
f5edc444546b57af847ae33f2bd1e10442496e47vboxsync // Check for "MBeanInfo getCachedMBeanInfo()" method.
9de47c4ec7b0fc9a384e4b815153de399da7b8devboxsync return false;
9de47c4ec7b0fc9a384e4b815153de399da7b8devboxsync // Check for "MBeanInfo getMBeanInfo()" method.
672b9b73c5db0590fa77ef0f26b024d4e61bad86vboxsync return false;
672b9b73c5db0590fa77ef0f26b024d4e61bad86vboxsync // Check for "MBeanNotificationInfo[] getNotificationInfo()"
672b9b73c5db0590fa77ef0f26b024d4e61bad86vboxsync // This method is taken into account for the MBeanInfo
672b9b73c5db0590fa77ef0f26b024d4e61bad86vboxsync // immutability checks if and only if the given subclass is
672b9b73c5db0590fa77ef0f26b024d4e61bad86vboxsync // StandardEmitterMBean itself or can be assigned to
f5edc444546b57af847ae33f2bd1e10442496e47vboxsync // StandardEmitterMBean.
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync if (StandardEmitterMBean.class.isAssignableFrom(subclass))
0229b85e94ec942dbb9b8748e9dbb30cef9f3ed9vboxsync if (overrides(subclass, StandardEmitterMBean.class,
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return false;
7383be37f7fdafd682028c4ab39ffeab51fccc36vboxsync return true;