public class RelationSupport extends Object implements RelationSupportMBean, MBeanRegistration
relationsupport类符合标准的设计模式MBean。所以用户可以决定实例化一个relationsupport对象自己为MBean(如下MBean设计模式),将其登记在MBean服务器,然后将其添加在关系服务。
用户也可以创建自己的MBean关系类的时候,它延伸relationsupport,检索所需的接口的实现(见下文)。
也有可能在用户关系MBean类的一个成员是一个relationsupport对象,并委派所有成员实现所需的界面。
relationsupport实现关系的界面(由关系服务处理)。
它实现了也mbeanregistration接口能够检索MBean服务器在注册(如果注册为MBean)来访问其关系服务。
Constructor and Description |
---|
RelationSupport(String relationId, ObjectName relationServiceName, MBeanServer relationServiceMBeanServer, String relationTypeName, RoleList list)
创建一个
RelationSupport 对象。
|
RelationSupport(String relationId, ObjectName relationServiceName, String relationTypeName, RoleList list)
创建一个
RelationSupport 对象。
|
Modifier and Type | Method and Description |
---|---|
RoleResult |
getAllRoles()
返回当前在关系中的所有角色。
|
Map<ObjectName,List<String>> |
getReferencedMBeans()
检索关系的各种角色引用MBeans。
|
String |
getRelationId()
返回关系标识符(用于唯一标识关系服务中的关系)。
|
ObjectName |
getRelationServiceName()
返回对象的关系服务处理的关系。
|
String |
getRelationTypeName()
关联关系类型的返回名称。
|
List<ObjectName> |
getRole(String roleName)
检索给定角色名的角色值。
|
Integer |
getRoleCardinality(String roleName)
返回给定引用在MBeans目前角色的数量。
|
RoleResult |
getRoles(String[] roleNameArray)
检索给定名称的角色的值。
|
void |
handleMBeanUnregistration(ObjectName objectName, String roleName)
回调的关系服务当MBean中引用的作用是未注册。
|
Boolean |
isInRelationService()
返回指定对象是否仍由关系服务处理的内部标志。
|
void |
postDeregister()
允许MBean执行任何操作在MBean服务器被注册后需要。
|
void |
postRegister(Boolean registrationDone)
允许MBean执行任何操作在MBean服务器或注册后不需要注册后。
|
void |
preDeregister()
允许MBean执行任何需要的操作之前被注册的MBean服务器。
|
ObjectName |
preRegister(MBeanServer server, ObjectName name)
允许MBean执行任何操作之前,它需要在MBean服务器注册。
|
RoleList |
retrieveAllRoles()
返回关系中的所有角色,而不检查读模式。
|
void |
setRelationServiceManagementFlag(Boolean flag)
指定这种关系是否由关系服务处理。
|
void |
setRole(Role role)
设置给定的角色。
|
RoleResult |
setRoles(RoleList list)
设置给定的角色。
|
public RelationSupport(String relationId, ObjectName relationServiceName, String relationTypeName, RoleList list) throws InvalidRoleValueException, IllegalArgumentException
RelationSupport
对象。
此构造函数时必须使用的relationsupport对象将注册用户作为一个MBean,或创建一个用户关系的类扩展relationsupport当MBean。
什么是服务水平的关系,即RelationSupport
对象不会被添加到RelationService
没有进行检查,看是否提供的值是正确的。对象总是创建的,除非:
任何所需的参数是null
。
-相同的名称用于两个角色。
作为一个关系的处理,RelationSupport
对象已被添加到使用的关系服务的方法addrelation()关系服务。
relationId
关联的标识符,以确定在关系服务的关系。
预期在给定的关系服务中是唯一的。
relationServiceName
- ObjectName的关系,关系将注册服务。
此参数是必需的,因为它是一个关系服务,它知道给定关系的关系类型的定义,因此,将能够检查更新操作(集)。
relationTypeName
-关系型的名字。
预期在给定的关系服务中创建。
list
-角色列表(作用对象)来初始化的关系。可以
null
。
期望与关联关系类型的关系信息。
InvalidRoleValueException
-如果使用相同的名称为两个角色。
IllegalArgumentException
-如果任何所需的参数(关联ID,联系服务对象、关系或类型名称)是
null
。
public RelationSupport(String relationId, ObjectName relationServiceName, MBeanServer relationServiceMBeanServer, String relationTypeName, RoleList list) throws InvalidRoleValueException, IllegalArgumentException
RelationSupport
对象。
此构造函数时必须使用MBean实现用户关系预计将被委派到一个relationsupport对象支持的接口关系。
此对象需要知道处理关系的关系服务。所以它知道MBean服务器的关系服务注册。
根据一个限制,一个关系MBean必须在同一个MBean服务器注册为预期的处理关系的服务。所以用户关系的MBean被创建和注册,然后裹relationsupport对象可以在确定的MBean服务器创建。
什么是服务水平的关系,即RelationSupport
对象不会被添加到RelationService
没有进行检查,看是否提供的值是正确的。对象总是创建的,除非:
任何所需的参数是null
。
-相同的名称用于两个角色。
作为一个关系的处理,RelationSupport
对象已被添加到使用的关系服务的方法addrelation()关系服务。
relationId
关联的标识符,以确定在关系服务的关系。
预期在给定的关系服务中是唯一的。
relationServiceName
- ObjectName的关系,关系将注册服务。
此参数是必需的,因为它是一个关系服务,它知道给定关系的关系类型的定义,因此,将能够检查更新操作(集)。
relationServiceMBeanServer
- MBean服务器在包装MBean或将注册。
将MBean服务器的关系,或将注册服务。
relationTypeName
-关系型的名字。
预期在给定的关系服务中创建。
list
-角色列表(作用对象)来初始化的关系。可以
null
。
期望与关联关系类型的关系信息。
InvalidRoleValueException
-如果使用相同的名称为两个角色。
IllegalArgumentException
-如果任何所需的参数(关联ID,联系服务对象、关系服务的MBeanServer,或关系类型名称)是
null
。
public List<ObjectName> getRole(String roleName) throws IllegalArgumentException, RoleNotFoundException, RelationServiceNotRegisteredException
检查角色是否存在,并根据关系类型进行可读性检查。
getRole
接口
Relation
roleName
名字的角色
IllegalArgumentException
如果空角色名
RoleNotFoundException
如果:
-有没有角色与给定的名称
-角色是不可读的。
RelationServiceNotRegisteredException
如果关系服务不在MBean服务器注册
setRole(javax.management.relation.Role)
public RoleResult getRoles(String[] roleNameArray) throws IllegalArgumentException, RelationServiceNotRegisteredException
检查每个角色是否存在,并根据关系类型进行可读性。
getRoles
接口
Relation
roleNameArray
-要获取名称角色阵列
IllegalArgumentException
如果空角色名
RelationServiceNotRegisteredException
如果关系服务不在MBean服务器注册
setRoles(javax.management.relation.RoleList)
public RoleResult getAllRoles() throws RelationServiceNotRegisteredException
getAllRoles
接口
Relation
RelationServiceNotRegisteredException
如果关系服务不在MBean服务器注册
public RoleList retrieveAllRoles()
retrieveAllRoles
接口
Relation
public Integer getRoleCardinality(String roleName) throws IllegalArgumentException, RoleNotFoundException
getRoleCardinality
接口
Relation
roleName
名字的角色
IllegalArgumentException
如果空角色名
RoleNotFoundException
-如果名字没有作用
public void setRole(Role role) throws IllegalArgumentException, RoleNotFoundException, RelationTypeNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationNotFoundException
将根据其在关系类型中所提供的相应角色定义来检查角色
将发送通知(relationnotification relation_basic_update型或relation_mbean_update,如果关系是MBean或不)。
setRole
接口
Relation
role
角色被设置(名称和新价值)
IllegalArgumentException
如果空的作用
RoleNotFoundException
-如果没有角色提供的角色名称或角色如果不写(在写访问模式进行初始化的作用在没有测试)
InvalidRoleValueException
-如果提供的角色值无效,即:
-引用MBeans给定值的数量少于预期的最低程度
-提供价值参考MBeans最大程度超过预期的数量
一个引用MBean的价值不在于MBean类预期,作用对象
对于这个角色不存在提供一个MBean
RelationServiceNotRegisteredException
如果关系服务不在MBean服务器注册
RelationTypeNotFoundException
如果关系类型没有关系的服务声明
RelationNotFoundException
如果关系没有关系的服务添加。
getRole(java.lang.String)
public RoleResult setRoles(RoleList list) throws IllegalArgumentException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException
将根据其在关系类型中所提供的相应角色定义来检查角色
将发送一个通知(relationnotification relation_basic_update型或relation_mbean_update,如果关系是MBean或不)每更新的作用。
setRoles
接口
Relation
list
-角色设定
IllegalArgumentException
如果空角色列表
RelationServiceNotRegisteredException
如果关系服务不在MBean服务器注册
RelationTypeNotFoundException
如果关系类型没有关系的服务声明。
RelationNotFoundException
如果关系的MBean没有关系的服务添加。
getRoles(java.lang.String[])
public void handleMBeanUnregistration(ObjectName objectName, String roleName) throws IllegalArgumentException, RoleNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException
关系服务将调用这个方法来让关系采取行动来反映这些注销的影响。
当心。用户不希望调用此方法。
当前的实现是其当前价值的角色设定(对引用MBeans objectnames列表)没有注册一个。
handleMBeanUnregistration
接口
Relation
objectName
-未注册MBean ObjectName
roleName
名字的角色在MBean参考
IllegalArgumentException
如果空参数
RoleNotFoundException
-如果角色不在关系存在或不可写
InvalidRoleValueException
-如果角色值不符合相关的角色信息(这将永远不会发生在被称为从关系服务)
RelationServiceNotRegisteredException
如果关系服务不在MBean服务器注册
RelationTypeNotFoundException
如果关系类型没有关系的服务声明。
RelationNotFoundException
-如果这种方法被称为一个关系的MBean中不添加关系服务。
public Map<ObjectName,List<String>> getReferencedMBeans()
getReferencedMBeans
接口
Relation
ArrayList对象->字符串(角色名称)
public String getRelationTypeName()
getRelationTypeName
接口
Relation
public ObjectName getRelationServiceName()
getRelationServiceName
接口
Relation
public String getRelationId()
getRelationId
接口
Relation
public ObjectName preRegister(MBeanServer server, ObjectName name) throws 异常
MBeanRegistration
preRegister
接口
MBeanRegistration
server
的MBean服务器中,MBean将注册。
name
- MBean对象名称。如果Name参数中的一个
MBeanServer
接口
createMBean
或
registerMBean
方法是零这个名字是空的。在这种情况下,该方法必须返回一个非空的新的MBean对象。
name
参数不为空,它通常但不返回值。
异常
这个例外将被重新抛出的MBean服务器作为一个
MBeanRegistrationException
。
public void postRegister(Boolean registrationDone)
MBeanRegistration
如果执行此方法抛出一个RuntimeException
或Error
MBean服务器对象,将里面的人RuntimeMBeanException
或RuntimeErrorException
,分别。然而,在postRegister
抛出异常并不会改变MBean的状态:如果MBean已经注册(registrationDone
是true
),MBean将保持注册。
这可能是混乱的代码调用createMBean()
或registerMBean()
,这样的代码可能会认为MBean注册失败时抛出一个异常。因此建议实现postRegister
不抛出运行时异常或错误,如果它是可以避免的。
postRegister
接口
MBeanRegistration
registrationDone
-指示是否MBean已在MBean服务器注册成功。价值错误意味着注册阶段已经失败。
public void preDeregister() throws 异常
MBeanRegistration
preDeregister
接口
MBeanRegistration
异常
这个例外将被重新抛出的MBean服务器作为一个
MBeanRegistrationException
。
public void postDeregister()
MBeanRegistration
如果执行此方法抛出一个RuntimeException
或Error
MBean服务器对象,将里面的人RuntimeMBeanException
或RuntimeErrorException
,分别。然而,在postDeregister
抛出异常并不会改变MBean状态:MBean已成功注销,今后仍将如此。
这可能是混乱的代码调用unregisterMBean()
,它可能认为MBean deregistration已经失败了。因此建议实现postDeregister
不抛出运行时异常或错误,如果它是可以避免的。
postDeregister
接口
MBeanRegistration
public Boolean isInRelationService()
isInRelationService
接口
RelationSupportMBean
Boolean.TRUE
如果对象仍然是由关系服务和
Boolean.FALSE
否则。
public void setRelationServiceManagementFlag(Boolean flag) throws IllegalArgumentException
RelationSupportMBean
指定这种关系是否由关系服务处理。
小心,这种方法必须被暴露的关系服务将通过其管理接口访问关系。建议不要使用这种方法。使用它不影响关系服务中关系对象的注册,但会提供关于它的错误信息!
setRelationServiceManagementFlag
接口
RelationSupportMBean
flag
无论关系是由关系服务处理。
IllegalArgumentException
如果空参数
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.