public interface Relation
Simple relations, i.e. having only roles, no properties or methods, can be created directly by the Relation Service (represented as RelationSupport objects, internally handled by the Relation Service).
If the user wants to represent more complex relations, involving properties and/or methods, he has to provide his own class implementing the Relation interface. This can be achieved either by inheriting from RelationSupport class, or by implementing the interface (fully or delegation to a RelationSupport object member).
Specifying such user relation class is to introduce properties and/or methods. Those have to be exposed for remote management. So this means that any user relation class must be a MBean class.
Modifier and Type | Method and Description |
---|---|
RoleResult |
getAllRoles()
Returns all roles present in the relation.
|
Map<ObjectName,List<String>> |
getReferencedMBeans()
Retrieves MBeans referenced in the various roles of the relation.
|
String |
getRelationId()
Returns relation identifier (used to uniquely identify the relation
inside the Relation Service).
|
ObjectName |
getRelationServiceName()
Returns ObjectName of the Relation Service handling the relation.
|
String |
getRelationTypeName()
Returns name of associated relation type.
|
List<ObjectName> |
getRole(String roleName)
Retrieves role value for given role name.
|
Integer |
getRoleCardinality(String roleName)
Returns the number of MBeans currently referenced in the given role.
|
RoleResult |
getRoles(String[] roleNameArray)
Retrieves values of roles with given names.
|
void |
handleMBeanUnregistration(ObjectName objectName,
String roleName)
Callback used by the Relation Service when a MBean referenced in a role
is unregistered.
|
RoleList |
retrieveAllRoles()
Returns all roles in the relation without checking read mode.
|
void |
setRole(Role role)
Sets the given role.
|
RoleResult |
setRoles(RoleList roleList)
Sets the given roles.
|
List<ObjectName> getRole(String roleName) throws IllegalArgumentException, RoleNotFoundException, RelationServiceNotRegisteredException
Checks if the role exists and is readable according to the relation type.
roleName
- name of roleIllegalArgumentException
- if null role nameRoleNotFoundException
- if:
- there is no role with given name
- the role is not readable.
RelationServiceNotRegisteredException
- if the Relation
Service is not registered in the MBean ServersetRole(javax.management.relation.Role)
RoleResult getRoles(String[] roleNameArray) throws IllegalArgumentException, RelationServiceNotRegisteredException
Checks for each role if it exists and is readable according to the relation type.
roleNameArray
- array of names of roles to be retrievedIllegalArgumentException
- if null role nameRelationServiceNotRegisteredException
- if the Relation
Service is not registered in the MBean ServersetRoles(javax.management.relation.RoleList)
Integer getRoleCardinality(String roleName) throws IllegalArgumentException, RoleNotFoundException
roleName
- name of roleIllegalArgumentException
- if null role nameRoleNotFoundException
- if there is no role with given nameRoleResult getAllRoles() throws RelationServiceNotRegisteredException
RelationServiceNotRegisteredException
- if the Relation
Service is not registered in the MBean ServerRoleList retrieveAllRoles()
void setRole(Role role) throws IllegalArgumentException, RoleNotFoundException, RelationTypeNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationNotFoundException
Will check the role according to its corresponding role definition provided in relation's relation type
Will send a notification (RelationNotification with type RELATION_BASIC_UPDATE or RELATION_MBEAN_UPDATE, depending if the relation is a MBean or not).
role
- role to be set (name and new value)IllegalArgumentException
- if null roleRoleNotFoundException
- if there is no role with the supplied
role's name or if the role is not writable (no test on the write access
mode performed when initializing the role)InvalidRoleValueException
- if value provided for
role is not valid, i.e.:
- the number of referenced MBeans in given value is less than expected minimum degree
- the number of referenced MBeans in provided value exceeds expected maximum degree
- one referenced MBean in the value is not an Object of the MBean class expected for that role
- a MBean provided for that role does not exist.
RelationServiceNotRegisteredException
- if the Relation
Service is not registered in the MBean ServerRelationTypeNotFoundException
- if the relation type has not
been declared in the Relation Service.RelationNotFoundException
- if the relation has not been
added in the Relation Service.getRole(java.lang.String)
RoleResult setRoles(RoleList roleList) throws IllegalArgumentException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException
Will check the role according to its corresponding role definition provided in relation's relation type
Will send one notification (RelationNotification with type RELATION_BASIC_UPDATE or RELATION_MBEAN_UPDATE, depending if the relation is a MBean or not) per updated role.
roleList
- list of roles to be setIllegalArgumentException
- if null role listRelationServiceNotRegisteredException
- if the Relation
Service is not registered in the MBean ServerRelationTypeNotFoundException
- if the relation type has not
been declared in the Relation Service.RelationNotFoundException
- if the relation MBean has not been
added in the Relation Service.getRoles(java.lang.String[])
void handleMBeanUnregistration(ObjectName objectName, String roleName) throws IllegalArgumentException, RoleNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException
The Relation Service will call this method to let the relation take action to reflect the impact of such unregistration.
BEWARE. the user is not expected to call this method.
Current implementation is to set the role with its current value (list of ObjectNames of referenced MBeans) without the unregistered one.
objectName
- ObjectName of unregistered MBeanroleName
- name of role where the MBean is referencedIllegalArgumentException
- if null parameterRoleNotFoundException
- if role does not exist in the
relation or is not writableInvalidRoleValueException
- if role value does not conform to
the associated role info (this will never happen when called from the
Relation Service)RelationServiceNotRegisteredException
- if the Relation
Service is not registered in the MBean ServerRelationTypeNotFoundException
- if the relation type has not
been declared in the Relation Service.RelationNotFoundException
- if this method is called for a
relation MBean not added in the Relation Service.Map<ObjectName,List<String>> getReferencedMBeans()
ObjectName -> ArrayList of String (role names)
String getRelationTypeName()
ObjectName getRelationServiceName()
String getRelationId()
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, 2013, Oracle and/or its affiliates. All rights reserved.