javax.management.relation
类 RelationSupport

java.lang.Object
  继承者 javax.management.relation.RelationSupport
所有已实现的接口:
MBeanRegistration, Relation, RelationSupportMBean

public class RelationSupport
   
   
   
extends Object
implements RelationSupportMBean, MBeanRegistration

RelationSupport 对象由 Relation Service 内部使用,表示任何关系型的具有不限数量的角色的简单关系(只有角色,没有属性或方法)。作为内部表示形式,不会向用户公开它。

RelationSupport 类遵循标准的 MBean 设计模式。因此,用户可以决定将 RelationSupport 对象本身实例化为 MBean(因为它遵循 MBean 设计模式),以便在 MBean Server 中注册,然后将其添加到 Relation Service 中。

用户还可以在创建自己的 MBean 关系类时让其扩展 RelationSupport,以检索所需接口的实现(请参见下面内容)。

它还可以在用户关系 MBean 类中让一个成员成为 RelationSupport 对象,并通过将所有接口委托给此成员来实现所需接口。

RelationSupport 实现 Relation 接口(将由 Relation Service 处理)。

它还实现 MBeanRegistration 接口,以便能够检索它在其中注册的 MBean Server(如果注册为 MBean),从而访问其 Relation Service。

从以下版本开始:
1.5

构造方法摘要
RelationSupport(String relationId, ObjectName relationServiceName, MBeanServer relationServiceMBeanServer, String relationTypeName, RoleList list)
          创建一个 RelationSupport 对象。
RelationSupport(String relationId, ObjectName relationServiceName, String relationTypeName, RoleList list)
          创建一个 RelationSupport 对象。
 
方法摘要
 RoleResultgetAllRoles()
          返回关系中存在的所有角色。
 Map<ObjectName,List<String>>getReferencedMBeans()
          检索在该关系的各种角色中引用的 MBean。
 StringgetRelationId()
          返回关系标识符(用于唯一标识 Relation Service 中的关系)。
 ObjectNamegetRelationServiceName()
          返回处理关系的 Relation Service 的 ObjectName。
 StringgetRelationTypeName()
          返回相关关系类型的名称。
 List<ObjectName>getRole(String roleName)
          检索给定角色名称的角色值。
 IntegergetRoleCardinality(String roleName)
          返回当前在给定角色中引用的 MBean 数。
 RoleResultgetRoles(String[] roleNameArray)
          检索具有给定名称的角色值。
 voidhandleMBeanUnregistration(ObjectName objectName, String roleName)
          在注销角色中引用的 MBean 时由 Relation Service 使用的回调。
 BooleanisInRelationService()
          返回指定该对象是否仍然由 Relation Service 处理的内部标志。
 voidpostDeregister()
          允许 MBean 在已从 MBean 服务器注销之后执行所需要的任何操作。
 voidpostRegister(Boolean registrationDone)
          允许 MBean 在被注册到 MBean 服务器或注销失败后执行任何所需要的操作。
 voidpreDeregister()
          允许该 MBean 在从 MBean 服务器注销之前执行它所需要的任何操作。
 ObjectNamepreRegister(MBeanServer server, ObjectName name)
          允许 MBean 在被注册到 MBean 服务器之前执行它所需要的任何操作。
 RoleListretrieveAllRoles()
          返回关系中的所有角色,不检查读取模式。
 voidsetRelationServiceManagementFlag(Boolean flag)
          指定此关系是否由 Relation Service 处理。
 voidsetRole(Role role)
          设置给定的角色。
 RoleResultsetRoles(RoleList list)
          设置给定的角色。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

RelationSupport

public RelationSupport(String relationId,
                       ObjectName relationServiceName,
                       String relationTypeName,
                       RoleList list)
                throws InvalidRoleValueException,
                       IllegalArgumentException
创建一个 RelationSupport 对象。

在用户要将 RelationSupport 对象注册为 MBean 时,或者在创建扩展 RelationSupport 的用户关系 MBean 类时,必须使用此构造方法。

在 Relation Service 级别不执行任何操作,既不向 RelationService 添加 RelationSupport 对象,也不查看提供的值是否正确。始终创建该对象,除以下情况外:

- 任何所需的参数为 null

- 两个角色使用了同一名称。

为了将该对象作为关系处理,务必使用 Relation Service 方法 addRelation() 将 RelationSupport 对象添加到 Relation Service 中。

参数:
relationId - 关系标识符,用来在 Relation Service 中标识关系。

期望在给定的 Relation Service 中唯一。

relationServiceName - 将在其中注册关系的 Relation Service 的 ObjectName。

此参数是必需的,因为这是知道给定关系的关系类型定义的 Relation Service,所以将能够检查更新操作(集)。

relationTypeName - 关系类型的名称。

期望已在给定的 Relation Service 中创建。

list - 要初始化关系的角色(Role 对象)的列表。可以为 null

期望遵循相关关系类型中的关系信息。

抛出:
InvalidRoleValueException - 如果两个角色使用了同一个名称。
IllegalArgumentException - 如果任何所需参数(关系 id、关系服务 ObjectName、关系服务 MBeanServer 或者关系类型名称)为 null

RelationSupport

public RelationSupport(String relationId,
                       ObjectName relationServiceName,
                       MBeanServer relationServiceMBeanServer,
                       String relationTypeName,
                       RoleList list)
                throws InvalidRoleValueException,
                       IllegalArgumentException
创建一个 RelationSupport 对象。

在用户关系 MBean 实现期望通过委托给 RelationSupport 对象受关系支持的接口时,务必使用此构造方法。

此对象需要知道期望处理该关系的 Relation Service。所以它必须知道 Relation Service 在其中注册的 MBean Server。

按照限制,必须像期望处理它的 Relation Service 一样在同一 MBean Server 中注册关系 MBean。所以必须创建并注册用户关系 MBean,然后可以使用标识的 MBean Server 创建包装的 RelationSupport 对象。

在 Relation Service 级别不执行任何操作,既不向 RelationService 添加 RelationSupport 对象,也不查看提供的值是否正确。始终创建该对象,除以下情况外:

- 任何所需的参数为 null

- 两个角色使用了同一个名称。

为了将该对象作为关系处理,务必使用 Relation Service 方法 addRelation() 将 RelationSupport 对象添加到 Relation Service 中。

参数:
relationId - 关系标识符,用来在 Relation Service 中标识关系。

期望在给定的 Relation Service 中唯一。

relationServiceName - 将在其中注册关系的 Relation Service 的 ObjectName。

此参数是必需的,因为这是知道给定关系的关系类型定义的 Relation Service,所以将能够检查更新操作(集合)。

relationServiceMBeanServer - 该包装 MBean 在其中或将在其中注册的 MBean Server。

期望是 Relation Service 在其中或将在其中注册的 MBean Server。

relationTypeName - 关系类型的名称。

期望已在给定的 Relation Service 中创建该名称。

list - 要初始化关系的角色(Role 对象)的列表。可以为 null

期望遵循相关关系类型中的关系信息。

抛出:
InvalidRoleValueException - 如果两个角色使用了同一个名称。
IllegalArgumentException - 如果任何所需参数(关系 id、关系服务 ObjectName 或者关系类型名称)为 null
方法详细信息

getRole

public List<ObjectName> getRole(String roleName)
                         throws IllegalArgumentException,
                                RoleNotFoundException,
                                RelationServiceNotRegisteredException
检索给定角色名称的角色值。

按照关系类型检查角色是否存在以及是否可读。

指定者:
接口 Relation 中的 getRole
参数:
roleName - 角色名称
返回:
作为角色值的 ObjectName 对象的 ArrayList
抛出:
IllegalArgumentException - 如果为 null 角色名称
RoleNotFoundException - 如果:

- 不存在具有给定名称的角色

- 角色不可读。

RelationServiceNotRegisteredException - 如果 Relation Service 未在 MBean Server 中注册
另请参见:
setRole(javax.management.relation.Role)

getRoles

public RoleResult getRoles(String[] roleNameArray)
                    throws IllegalArgumentException,
                           RelationServiceNotRegisteredException
检索具有给定名称的角色值。

按照关系类型检查每个角色是否存在以及是否可读。

指定者:
接口 Relation 中的 getRoles
参数:
roleNameArray - 要检索的角色名称的数组
返回:
RoleResult 对象,包括一个 RoleList(针对成功检索到的角色)和一个 RoleUnresolvedList(针对未检索到的角色)。
抛出:
IllegalArgumentException - 如果角色名称为 null
RelationServiceNotRegisteredException - 如果 Relation Service 未在 MBean Server 中注册。
另请参见:
setRoles(javax.management.relation.RoleList)

getAllRoles

public RoleResult getAllRoles()
                       throws RelationServiceNotRegisteredException
返回关系中存在的所有角色。

指定者:
接口 Relation 中的 getAllRoles
返回:
RoleResult 对象,该对象包括一个 RoleList(针对成功检索到的角色)和一个 RoleUnresolvedList(针对不可读的角色)。
抛出:
RelationServiceNotRegisteredException - 如果 Relation Service 未在 MBean Server 中注册

retrieveAllRoles

public RoleList retrieveAllRoles()
返回关系中的所有角色,不检查读取模式。

指定者:
接口 Relation 中的 retrieveAllRoles
返回:
一个 RoleList

getRoleCardinality

public Integer getRoleCardinality(String roleName)
                           throws IllegalArgumentException,
                                  RoleNotFoundException
返回当前在给定角色中引用的 MBean 数。

指定者:
接口 Relation 中的 getRoleCardinality
参数:
roleName - 角色名称
返回:
当前在此角色中引用的 MBean 数
抛出:
IllegalArgumentException - 如果角色名称为 null
RoleNotFoundException - 如果不存在具有给定名称的角色