jdk/src/java.management/share/classes/javax/management/relation/package.html
author uvangapally
Tue, 01 Aug 2017 10:33:47 +0530
changeset 46050 f51c14dc540f
parent 25859 3317bb8137f4
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.relation package</title>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
<!--
46050
f51c14dc540f 8181895: javax management docs contain links to technotes
uvangapally
parents: 25859
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
      <p>Provides the definition of the Relation Service.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
	Relation Service is used to record relationships between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
	MBeans in an MBean Server.  The Relation Service is itself an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
	MBean.  More than one instance of a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
	javax.management.relation.RelationService RelationService}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
	MBean can be registered in an MBean Server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
      <p>A <em>relation type</em> defines a relationship between MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
	It contains <em>roles</em> that the MBeans play in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
	relationship.  Usually there are at least two roles in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
	relation type.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
      <p>A <em>relation</em> is a named instance of a relation type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
	where specific MBeans appear in the roles, represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
	their {@link javax.management.ObjectName ObjectName}s.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
      <p>For example, suppose there are <code>Module</code> MBeans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
	representing modules within an application.  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
	<code>DependsOn</code> relation type could express the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
	relationship that some modules depend on others, which could
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
	be used to determine the order in which the modules are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
	started or stopped.  The <code>DependsOn</code> relation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
	would have two roles, <code>dependent</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
	<code>dependedOn</code>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
      <p>Every role is <em>typed</em>, meaning that an MBean that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
	appears in that role must be an instance of the role's type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
	In the <code>DependsOn</code> example, both roles would be of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
	type <code>Module</code>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
      <p>Every role has a <em>cardinality</em>, which provides lower
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
	and upper bounds on the number of MBeans that can appear in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
	that role in a given relation instance.  Usually, the lower
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
	and upper bounds are both 1, with exactly one MBean appearing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
	in the role.  The cardinality only limits the number of MBeans
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
	in the role per relation instance.  The same MBean can appear
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
	in the same role in any number of instances of a relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
	type.  In the <code>DependsOn</code> example, a given module
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
	can depend on many other modules, and be depended on by many
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
	others, but any given relation instance links exactly one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
	<code>dependent</code> module with exactly one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
	<code>dependedOn</code> module.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
      <p>A relation type can be created explicitly, as an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
	implementing the {@link javax.management.relation.RelationType
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
	RelationType} interface, typically a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
	javax.management.relation.RelationTypeSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
	RelationTypeSupport}.  Alternatively, it can be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
	implicitly using the Relation Service's {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
	javax.management.relation.RelationServiceMBean#createRelationType(String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
	RoleInfo[]) createRelationType} method.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      <p>A relation instance can be created explicitly, as an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
	implementing the {@link javax.management.relation.Relation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
	Relation} interface, typically a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
	javax.management.relation.RelationSupport RelationSupport}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
	(A <code>RelationSupport</code> is itself a valid MBean, so it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
	can be registered in the MBean Server, though this is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
	required.)  Alternatively, a relation instance can be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
	implicitly using the Relation Service's {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
	javax.management.relation.RelationServiceMBean#createRelation(String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
	String, RoleList) createRelation} method.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
      <p>The <code>DependsOn</code> example might be coded as follows.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
<pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
import javax.management.relation.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
// ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
MBeanServer mbs = ...;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
// Create the Relation Service MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
ObjectName relSvcName = new ObjectName(":type=RelationService");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
RelationService relSvcObject = new RelationService(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
mbs.registerMBean(relSvcObject, relSvcName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
// Create an MBean proxy for easier access to the Relation Service
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
RelationServiceMBean relSvc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    MBeanServerInvocationHandler.newProxyInstance(mbs, relSvcName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
						  RelationServiceMBean.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
						  false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
// Define the DependsOn relation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
RoleInfo[] dependsOnRoles = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    new RoleInfo("dependent", Module.class.getName()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    new RoleInfo("dependedOn", Module.class.getName())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
relSvc.createRelationType("DependsOn", dependsOnRoles);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
// Now define a relation instance "moduleA DependsOn moduleB"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
ObjectName moduleA = new ObjectName(":type=Module,name=A");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
ObjectName moduleB = new ObjectName(":type=Module,name=B");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
Role dependent = new Role("dependent", Collections.singletonList(moduleA));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
Role dependedOn = new Role("dependedOn", Collections.singletonList(moduleB));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
Role[] roleArray = {dependent, dependedOn};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
RoleList roles = new RoleList(Arrays.asList(roleArray));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
relSvc.createRelation("A-DependsOn-B", "DependsOn", roles);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
// Query the Relation Service to find what modules moduleA depends on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
Map&lt;ObjectName,List&lt;String&gt;&gt; dependentAMap =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    relSvc.findAssociatedMBeans(moduleA, "DependsOn", "dependent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
Set&lt;ObjectName&gt; dependentASet = dependentAMap.keySet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
// Set of ObjectName containing moduleB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
46050
f51c14dc540f 8181895: javax management docs contain links to technotes
uvangapally
parents: 25859
diff changeset
   139
    @see <a href="https://jcp.org/aboutJava/communityprocess/mrel/jsr160/index2.html">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
      JMX Specification, version 1.4</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
</BODY>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
</HTML>