author | rriggs |
Fri, 30 May 2014 15:46:12 -0400 | |
changeset 24685 | 215fa91e1b4c |
parent 9693 | ee89bfc8fa66 |
permissions | -rw-r--r-- |
2 | 1 |
<html> |
2 |
<head> |
|
3 |
<title>javax.management.modelmbean package</title> |
|
4 |
<!-- |
|
9693
ee89bfc8fa66
7031754: javax.management docs need to be updated to replace Java SE 6 occurrences
fparain
parents:
5551
diff
changeset
|
5 |
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 6 |
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7 |
||
8 |
This code is free software; you can redistribute it and/or modify it |
|
9 |
under the terms of the GNU General Public License version 2 only, as |
|
5506 | 10 |
published by the Free Software Foundation. Oracle designates this |
2 | 11 |
particular file as subject to the "Classpath" exception as provided |
5506 | 12 |
by Oracle in the LICENSE file that accompanied this code. |
2 | 13 |
|
14 |
This code is distributed in the hope that it will be useful, but WITHOUT |
|
15 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
16 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
17 |
version 2 for more details (a copy is included in the LICENSE file that |
|
18 |
accompanied this code). |
|
19 |
||
20 |
You should have received a copy of the GNU General Public License version |
|
21 |
2 along with this work; if not, write to the Free Software Foundation, |
|
22 |
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
23 |
||
5551
327690766109
6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents:
5506
diff
changeset
|
24 |
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
327690766109
6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents:
5506
diff
changeset
|
25 |
or visit www.oracle.com if you need additional information or have any |
327690766109
6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents:
5506
diff
changeset
|
26 |
questions. |
2 | 27 |
--> |
28 |
</head> |
|
29 |
<body bgcolor="white"> |
|
30 |
||
31 |
<p>Provides the definition of the ModelMBean classes. A Model |
|
32 |
MBean is an MBean that acts as a bridge between the management |
|
33 |
interface and the underlying managed resource. Both the |
|
34 |
management interface and the managed resource are specified as |
|
35 |
Java objects. The same Model MBean implementation can be |
|
36 |
reused many times with different management interfaces and |
|
37 |
managed resources, and it can provide common functionality |
|
38 |
such as persistence and caching.</p> |
|
39 |
||
40 |
<p>A Model MBean implements the {@link |
|
41 |
javax.management.modelmbean.ModelMBean ModelMBean} interface. |
|
42 |
It is a {@link javax.management.DynamicMBean DynamicMBean} |
|
43 |
whose {@link javax.management.DynamicMBean#getMBeanInfo() |
|
44 |
getMBeanInfo} method returns an object implementing {@link |
|
45 |
javax.management.modelmbean.ModelMBeanInfo |
|
46 |
ModelMBeanInfo}.</p> |
|
47 |
||
48 |
<p>Every MBean has an {@link javax.management.MBeanInfo |
|
49 |
MBeanInfo} with information about the MBean itself, and its |
|
50 |
attributes, operations, constructors, and notifications. A |
|
51 |
Model MBean augments this <code>MBeanInfo</code> with {@link |
|
52 |
javax.management.Descriptor Descriptor}s that encode |
|
53 |
additional information in the form of (key,value) pairs. |
|
54 |
Usually, <code>Descriptor</code>s are instances of {@link |
|
55 |
javax.management.modelmbean.DescriptorSupport |
|
56 |
DescriptorSupport}.</p> |
|
57 |
||
58 |
<p>The class {@link |
|
59 |
javax.management.modelmbean.RequiredModelMBean |
|
60 |
RequiredModelMBean} provides a standard Model MBean |
|
61 |
implementation.</p> |
|
62 |
||
63 |
<p>The following example shows a Model MBean being used to make |
|
64 |
the <code>get</code> method of a <code>HashMap</code> |
|
65 |
available for management through an MBean server. No other |
|
66 |
methods are available through the MBean server. There is |
|
67 |
nothing special about <code>HashMap</code> here. Public |
|
68 |
methods from any public class can be exposed for management in |
|
69 |
the same way.</p> |
|
70 |
||
71 |
<pre> |
|
72 |
import java.lang.reflect.Method; |
|
73 |
import java.util.HashMap; |
|
74 |
import javax.management.*; |
|
75 |
import javax.management.modelmbean.*; |
|
76 |
||
77 |
// ... |
|
78 |
||
79 |
MBeanServer mbs = MBeanServerFactory.createMBeanServer(); |
|
80 |
// The MBean Server |
|
81 |
||
82 |
HashMap map = new HashMap(); |
|
83 |
// The resource that will be managed |
|
84 |
||
85 |
// Construct the management interface for the Model MBean |
|
86 |
Method getMethod = HashMap.class.getMethod("get", new Class[] {Object.class}); |
|
87 |
ModelMBeanOperationInfo getInfo = |
|
88 |
new ModelMBeanOperationInfo("Get value for key", getMethod); |
|
89 |
ModelMBeanInfo mmbi = |
|
90 |
new ModelMBeanInfoSupport(HashMap.class.getName(), |
|
91 |
"Map of keys and values", |
|
92 |
null, // no attributes |
|
93 |
null, // no constructors |
|
94 |
new ModelMBeanOperationInfo[] {getInfo}, |
|
95 |
null); // no notifications |
|
96 |
||
97 |
// Make the Model MBean and link it to the resource |
|
98 |
ModelMBean mmb = new RequiredModelMBean(mmbi); |
|
99 |
mmb.setManagedResource(map, "ObjectReference"); |
|
100 |
||
101 |
// Register the Model MBean in the MBean Server |
|
102 |
ObjectName mapName = new ObjectName(":type=Map,name=whatever"); |
|
103 |
mbs.registerMBean(mmb, mapName); |
|
104 |
||
105 |
// Resource can evolve independently of the MBean |
|
106 |
map.put("key", "value"); |
|
107 |
||
108 |
// Can access the "get" method through the MBean Server |
|
109 |
mbs.invoke(mapName, "get", new Object[] {"key"}, new String[] {Object.class.getName()}); |
|
110 |
// returns "value" |
|
111 |
</pre> |
|
112 |
||
113 |
<h2><a name="spec">Package Specification</a></h2> |
|
114 |
||
115 |
<ul> |
|
116 |
<li>See the <i>JMX 1.4 Specification</i> |
|
117 |
PDF document available from the |
|
118 |
<a href="{@docRoot}/../technotes/guides/jmx/"> |
|
9693
ee89bfc8fa66
7031754: javax.management docs need to be updated to replace Java SE 6 occurrences
fparain
parents:
5551
diff
changeset
|
119 |
Java Platform documentation on JMX technology</a> |
2 | 120 |
</ul> |
121 |
||
122 |
@since 1.5 |
|
123 |
||
124 |
</BODY> |
|
125 |
</HTML> |