0N/A<html>
0N/A<head>
0N/A<title>javax.management.modelmbean package</title>
0N/A<!--
4230N/ACopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0N/ADO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A
0N/AThis code is free software; you can redistribute it and/or modify it
0N/Aunder the terms of the GNU General Public License version 2 only, as
2362N/Apublished by the Free Software Foundation. Oracle designates this
0N/Aparticular file as subject to the "Classpath" exception as provided
2362N/Aby Oracle in the LICENSE file that accompanied this code.
0N/A
0N/AThis code is distributed in the hope that it will be useful, but WITHOUT
0N/AANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/AFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/Aversion 2 for more details (a copy is included in the LICENSE file that
0N/Aaccompanied this code).
0N/A
0N/AYou should have received a copy of the GNU General Public License version
0N/A2 along with this work; if not, write to the Free Software Foundation,
0N/AInc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A
2365N/APlease contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2365N/Aor visit www.oracle.com if you need additional information or have any
2365N/Aquestions.
0N/A-->
0N/A</head>
0N/A<body bgcolor="white">
0N/A
0N/A <p>Provides the definition of the ModelMBean classes. A Model
0N/A MBean is an MBean that acts as a bridge between the management
0N/A interface and the underlying managed resource. Both the
0N/A management interface and the managed resource are specified as
0N/A Java objects. The same Model MBean implementation can be
0N/A reused many times with different management interfaces and
0N/A managed resources, and it can provide common functionality
0N/A such as persistence and caching.</p>
0N/A
0N/A <p>A Model MBean implements the {@link
0N/A javax.management.modelmbean.ModelMBean ModelMBean} interface.
0N/A It is a {@link javax.management.DynamicMBean DynamicMBean}
0N/A whose {@link javax.management.DynamicMBean#getMBeanInfo()
0N/A getMBeanInfo} method returns an object implementing {@link
0N/A javax.management.modelmbean.ModelMBeanInfo
0N/A ModelMBeanInfo}.</p>
0N/A
0N/A <p>Every MBean has an {@link javax.management.MBeanInfo
0N/A MBeanInfo} with information about the MBean itself, and its
0N/A attributes, operations, constructors, and notifications. A
0N/A Model MBean augments this <code>MBeanInfo</code> with {@link
0N/A javax.management.Descriptor Descriptor}s that encode
0N/A additional information in the form of (key,value) pairs.
0N/A Usually, <code>Descriptor</code>s are instances of {@link
0N/A javax.management.modelmbean.DescriptorSupport
0N/A DescriptorSupport}.</p>
0N/A
0N/A <p>The class {@link
0N/A javax.management.modelmbean.RequiredModelMBean
0N/A RequiredModelMBean} provides a standard Model MBean
0N/A implementation.</p>
0N/A
0N/A <p>The following example shows a Model MBean being used to make
0N/A the <code>get</code> method of a <code>HashMap</code>
0N/A available for management through an MBean server. No other
0N/A methods are available through the MBean server. There is
0N/A nothing special about <code>HashMap</code> here. Public
0N/A methods from any public class can be exposed for management in
0N/A the same way.</p>
0N/A
0N/A <pre>
0N/Aimport java.lang.reflect.Method;
0N/Aimport java.util.HashMap;
0N/Aimport javax.management.*;
0N/Aimport javax.management.modelmbean.*;
0N/A
0N/A// ...
0N/A
0N/AMBeanServer mbs = MBeanServerFactory.createMBeanServer();
0N/A// The MBean Server
0N/A
0N/AHashMap map = new HashMap();
0N/A// The resource that will be managed
0N/A
0N/A// Construct the management interface for the Model MBean
0N/AMethod getMethod = HashMap.class.getMethod("get", new Class[] {Object.class});
0N/AModelMBeanOperationInfo getInfo =
0N/A new ModelMBeanOperationInfo("Get value for key", getMethod);
0N/AModelMBeanInfo mmbi =
0N/A new ModelMBeanInfoSupport(HashMap.class.getName(),
0N/A "Map of keys and values",
0N/A null, // no attributes
0N/A null, // no constructors
0N/A new ModelMBeanOperationInfo[] {getInfo},
0N/A null); // no notifications
0N/A
0N/A// Make the Model MBean and link it to the resource
0N/AModelMBean mmb = new RequiredModelMBean(mmbi);
0N/Ammb.setManagedResource(map, "ObjectReference");
0N/A
0N/A// Register the Model MBean in the MBean Server
0N/AObjectName mapName = new ObjectName(":type=Map,name=whatever");
0N/Ambs.registerMBean(mmb, mapName);
0N/A
0N/A// Resource can evolve independently of the MBean
0N/Amap.put("key", "value");
0N/A
0N/A// Can access the "get" method through the MBean Server
0N/Ambs.invoke(mapName, "get", new Object[] {"key"}, new String[] {Object.class.getName()});
0N/A// returns "value"
0N/A </pre>
0N/A
0N/A <h2><a name="spec">Package Specification</a></h2>
0N/A
0N/A <ul>
0N/A <li>See the <i>JMX 1.4 Specification</i>
0N/A PDF document available from the
0N/A <a href="{@docRoot}/technotes/guides/jmx/">
4230N/A Java Platform documentation on JMX technology</a>
0N/A </ul>
0N/A
0N/A @since 1.5
0N/A
0N/A </BODY>
0N/A</HTML>