< prev index next >

src/java.management/share/classes/javax/management/MXBean.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2005, 2019, Oracle and/or its affiliates. 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. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2005, 2017, Oracle and/or its affiliates. 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. Oracle designates this
*** 77,87 **** @MXBean(false) public interface MisleadingMXBean {} </pre> ! <h2 id="MXBean-spec">MXBean specification</h2> <p>The MXBean concept provides a simple way to code an MBean that only references a predefined set of types, the ones defined by {@link javax.management.openmbean}. In this way, you can be sure that your MBean will be usable by any client, including --- 77,87 ---- @MXBean(false) public interface MisleadingMXBean {} </pre> ! <h3 id="MXBean-spec">MXBean specification</h3> <p>The MXBean concept provides a simple way to code an MBean that only references a predefined set of types, the ones defined by {@link javax.management.openmbean}. In this way, you can be sure that your MBean will be usable by any client, including
*** 92,112 **** <p>The concepts are easier to understand by comparison with the Standard MBean concept. Here is how a managed object might be represented as a Standard MBean, and as an MXBean:</p> <div style="display:inline-block; margin: 0 3em"> ! <h3>Standard MBean</h3> <pre> public interface MemoryPool<b>MBean</b> { String getName(); MemoryUsage getUsage(); // ... } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h3>MXBean</h3> <pre> public interface MemoryPool<b>MXBean</b> { String getName(); MemoryUsage getUsage(); // ... --- 92,112 ---- <p>The concepts are easier to understand by comparison with the Standard MBean concept. Here is how a managed object might be represented as a Standard MBean, and as an MXBean:</p> <div style="display:inline-block; margin: 0 3em"> ! <h4>Standard MBean</h4> <pre> public interface MemoryPool<b>MBean</b> { String getName(); MemoryUsage getUsage(); // ... } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h4>MXBean</h4> <pre> public interface MemoryPool<b>MXBean</b> { String getName(); MemoryUsage getUsage(); // ...
*** 131,141 **** <code>max</code> value.</p> <p>So, we might define <code>MemoryUsage</code> like this:</p> <div style="display:inline-block; margin: 0 3em"> ! <h3>Standard MBean</h3> <pre> public class MemoryUsage <b>implements Serializable</b> { // standard JavaBean conventions with getters public MemoryUsage(long init, long used, --- 131,141 ---- <code>max</code> value.</p> <p>So, we might define <code>MemoryUsage</code> like this:</p> <div style="display:inline-block; margin: 0 3em"> ! <h4>Standard MBean</h4> <pre> public class MemoryUsage <b>implements Serializable</b> { // standard JavaBean conventions with getters public MemoryUsage(long init, long used,
*** 146,156 **** long getMax() {...} } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h3>MXBean</h3> <pre> public class MemoryUsage { // standard JavaBean conventions with getters <b>@ConstructorParameters({"init", "used", "committed", "max"})</b> public MemoryUsage(long init, long used, --- 146,156 ---- long getMax() {...} } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h4>MXBean</h4> <pre> public class MemoryUsage { // standard JavaBean conventions with getters <b>@ConstructorParameters({"init", "used", "committed", "max"})</b> public MemoryUsage(long init, long used,
*** 192,213 **** <p>This becomes clearer if we compare what the clients of the two models might look like:</p> <div style="display:inline-block; margin: 0 3em"> ! <h3>Standard MBean</h3> <pre> String name = (String) mbeanServer.{@link MBeanServer#getAttribute getAttribute}(objectName, "Name"); <b>MemoryUsage</b> usage = (<b>MemoryUsage</b>) mbeanServer.getAttribute(objectName, "Usage"); <b>long used = usage.getUsed();</b> </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h3>MXBean</h3> <pre> String name = (String) mbeanServer.{@link MBeanServer#getAttribute getAttribute}(objectName, "Name"); <b>{@link CompositeData}</b> usage = (<b>CompositeData</b>) --- 192,213 ---- <p>This becomes clearer if we compare what the clients of the two models might look like:</p> <div style="display:inline-block; margin: 0 3em"> ! <h4>Standard MBean</h4> <pre> String name = (String) mbeanServer.{@link MBeanServer#getAttribute getAttribute}(objectName, "Name"); <b>MemoryUsage</b> usage = (<b>MemoryUsage</b>) mbeanServer.getAttribute(objectName, "Usage"); <b>long used = usage.getUsed();</b> </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h4>MXBean</h4> <pre> String name = (String) mbeanServer.{@link MBeanServer#getAttribute getAttribute}(objectName, "Name"); <b>{@link CompositeData}</b> usage = (<b>CompositeData</b>)
*** 229,239 **** <em>proxy</em>. This is the recommended way to interact with managed objects when you know the model beforehand, regardless of whether you are using Standard MBeans or MXBeans:</p> <div style="display:inline-block; margin: 0 3em"> ! <h3>Standard MBean</h3> <pre> MemoryPool<b>MBean</b> proxy = JMX.<b>{@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class) newMBeanProxy}</b>( mbeanServer, --- 229,239 ---- <em>proxy</em>. This is the recommended way to interact with managed objects when you know the model beforehand, regardless of whether you are using Standard MBeans or MXBeans:</p> <div style="display:inline-block; margin: 0 3em"> ! <h4>Standard MBean</h4> <pre> MemoryPool<b>MBean</b> proxy = JMX.<b>{@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class) newMBeanProxy}</b>( mbeanServer,
*** 243,253 **** MemoryUsage usage = proxy.getUsage(); long used = usage.getUsed(); </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h3>MXBean</h3> <pre> MemoryPool<b>MXBean</b> proxy = JMX.<b>{@link JMX#newMXBeanProxy(MBeanServerConnection, ObjectName, Class) newMXBeanProxy}</b>( mbeanServer, --- 243,253 ---- MemoryUsage usage = proxy.getUsage(); long used = usage.getUsed(); </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h4>MXBean</h4> <pre> MemoryPool<b>MXBean</b> proxy = JMX.<b>{@link JMX#newMXBeanProxy(MBeanServerConnection, ObjectName, Class) newMXBeanProxy}</b>( mbeanServer,
*** 261,282 **** <p>Implementing the MemoryPool object works similarly for both Standard MBeans and MXBeans.</p> <div style="display:inline-block; margin: 0 3em"> ! <h3>Standard MBean</h3> <pre> public class MemoryPool implements MemoryPool<b>MBean</b> { public String getName() {...} public MemoryUsage getUsage() {...} // ... } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h3>MXBean</h3> <pre> public class MemoryPool implements MemoryPool<b>MXBean</b> { public String getName() {...} public MemoryUsage getUsage() {...} --- 261,282 ---- <p>Implementing the MemoryPool object works similarly for both Standard MBeans and MXBeans.</p> <div style="display:inline-block; margin: 0 3em"> ! <h4>Standard MBean</h4> <pre> public class MemoryPool implements MemoryPool<b>MBean</b> { public String getName() {...} public MemoryUsage getUsage() {...} // ... } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h4>MXBean</h4> <pre> public class MemoryPool implements MemoryPool<b>MXBean</b> { public String getName() {...} public MemoryUsage getUsage() {...}
*** 287,307 **** <p>Registering the MBean in the MBean Server works in the same way in both cases:</p> <div style="display:inline-block; margin: 0 3em"> ! <h3>Standard MBean</h3> <pre> { MemoryPool<b>MBean</b> pool = new MemoryPool(); mbeanServer.{@link MBeanServer#registerMBean registerMBean}(pool, objectName); } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h3>MXBean</h3> <pre> { MemoryPool<b>MXBean</b> pool = new MemoryPool(); mbeanServer.{@link MBeanServer#registerMBean registerMBean}(pool, objectName); --- 287,307 ---- <p>Registering the MBean in the MBean Server works in the same way in both cases:</p> <div style="display:inline-block; margin: 0 3em"> ! <h4>Standard MBean</h4> <pre> { MemoryPool<b>MBean</b> pool = new MemoryPool(); mbeanServer.{@link MBeanServer#registerMBean registerMBean}(pool, objectName); } </pre> </div> <div style="display:inline-block; margin: 0 3em"> ! <h4>MXBean</h4> <pre> { MemoryPool<b>MXBean</b> pool = new MemoryPool(); mbeanServer.{@link MBeanServer#registerMBean registerMBean}(pool, objectName);
< prev index next >