jdk/src/java.management/share/classes/javax/management/modelmbean/package.html
author uvangapally
Tue, 01 Aug 2017 10:33:47 +0530
changeset 46050 f51c14dc540f
parent 44858 7183899b064b
permissions -rw-r--r--
8181895: javax management docs contain links to technotes Summary: Edited links to point to Alternate paths Reviewed-by: rriggs Contributed-by: ujwal.vangapally@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
<html>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
<head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
<title>javax.management.modelmbean package</title>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    10
published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    12
by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
-->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
</head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
<body bgcolor="white">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
    <p>Provides the definition of the ModelMBean classes.  A Model
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
      MBean is an MBean that acts as a bridge between the management
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
      interface and the underlying managed resource.  Both the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
      management interface and the managed resource are specified as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
      Java objects.  The same Model MBean implementation can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
      reused many times with different management interfaces and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
      managed resources, and it can provide common functionality
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
      such as persistence and caching.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    <p>A Model MBean implements the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
      javax.management.modelmbean.ModelMBean ModelMBean} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
      It is a {@link javax.management.DynamicMBean DynamicMBean}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
      whose {@link javax.management.DynamicMBean#getMBeanInfo()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
      getMBeanInfo} method returns an object implementing {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
      javax.management.modelmbean.ModelMBeanInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
      ModelMBeanInfo}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    <p>Every MBean has an {@link javax.management.MBeanInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
      MBeanInfo} with information about the MBean itself, and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
      attributes, operations, constructors, and notifications.  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
      Model MBean augments this <code>MBeanInfo</code> with {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
      javax.management.Descriptor Descriptor}s that encode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
      additional information in the form of (key,value) pairs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
      Usually, <code>Descriptor</code>s are instances of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
      javax.management.modelmbean.DescriptorSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
      DescriptorSupport}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    <p>The class {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
      javax.management.modelmbean.RequiredModelMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
      RequiredModelMBean} provides a standard Model MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
      implementation.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    <p>The following example shows a Model MBean being used to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
      the <code>get</code> method of a <code>HashMap</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
      available for management through an MBean server.  No other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
      methods are available through the MBean server.  There is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
      nothing special about <code>HashMap</code> here.  Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
      methods from any public class can be exposed for management in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
      the same way.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
import javax.management.modelmbean.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
// ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
// The MBean Server
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
HashMap map = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
// The resource that will be managed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
// Construct the management interface for the Model MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
Method getMethod = HashMap.class.getMethod("get", new Class[] {Object.class});
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
ModelMBeanOperationInfo getInfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    new ModelMBeanOperationInfo("Get value for key", getMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
ModelMBeanInfo mmbi =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    new ModelMBeanInfoSupport(HashMap.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
			      "Map of keys and values",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
			      null,  // no attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
			      null,  // no constructors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
			      new ModelMBeanOperationInfo[] {getInfo},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
			      null); // no notifications
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
// Make the Model MBean and link it to the resource
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
ModelMBean mmb = new RequiredModelMBean(mmbi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
mmb.setManagedResource(map, "ObjectReference");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
// Register the Model MBean in the MBean Server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
ObjectName mapName = new ObjectName(":type=Map,name=whatever");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
mbs.registerMBean(mmb, mapName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
// Resource can evolve independently of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
map.put("key", "value");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
// Can access the "get" method through the MBean Server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
mbs.invoke(mapName, "get", new Object[] {"key"}, new String[] {Object.class.getName()});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
// returns "value"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  </BODY>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
</HTML>