author | uvangapally |
Tue, 01 Aug 2017 10:33:47 +0530 | |
changeset 46050 | f51c14dc540f |
parent 44858 | 7183899b064b |
permissions | -rw-r--r-- |
2 | 1 |
<html> |
2 |
<head> |
|
3 |
<title>javax.management.modelmbean package</title> |
|
4 |
<!-- |
|
46050
f51c14dc540f
8181895: javax management docs contain links to technotes
uvangapally
parents:
44858
diff
changeset
|
5 |
Copyright (c) 2000, 2017, 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 |
||
44858
7183899b064b
8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents:
25859
diff
changeset
|
113 |
<h2><a id="spec">Package Specification</a></h2> |
2 | 114 |
|
115 |
<ul> |
|
116 |
<li>See the <i>JMX 1.4 Specification</i> |
|
46050
f51c14dc540f
8181895: javax management docs contain links to technotes
uvangapally
parents:
44858
diff
changeset
|
117 |
<a href="https://jcp.org/aboutJava/communityprocess/mrel/jsr160/index2.html"> |
f51c14dc540f
8181895: javax management docs contain links to technotes
uvangapally
parents:
44858
diff
changeset
|
118 |
JMX Specification, version 1.4</a> |
2 | 119 |
</ul> |
120 |
||
121 |
@since 1.5 |
|
122 |
||
123 |
</BODY> |
|
124 |
</HTML> |