Class: javax.management.relation.RelationService
- public class RelationService
- extends NotificationBroadcasterSupport
- implements RelationServiceMBean, MBeanRegistration, NotificationListener
It implements the NotificationBroadcaster by extending NotificationBroadcasterSupport to send notifications when a relation is removed from it.
It implements the NotificationListener interface to be able to receive notifications concerning unregistration of MBeans referenced in relation roles and of relation MBeans.
It implements the MBeanRegistration interface to be able to retrieve its ObjectName and MBean Server.
Inheritance
Superclass tree:- java.lang.Object
- javax.management.NotificationBroadcasterSupport
- javax.management.relation.RelationService
Methods
-
RelationServicetop
public RelationService(boolean immediatePurgeFlag)Constructor. -
addRelationtop
public void addRelation(ObjectName relationObjectName) throws IllegalArgumentException, RelationServiceNotRegisteredException, NoSuchMethodException, InvalidRelationIdException, InstanceNotFoundException, InvalidRelationServiceException, RelationTypeNotFoundException, RoleNotFoundException, InvalidRoleValueExceptionAdds an MBean created by the user (and registered by him in the MBean Server) as a relation in the Relation Service.To be added as a relation, the MBean must conform to the following:
- implement the Relation interface
- have for RelationService ObjectName the ObjectName of current Relation Service
- have a relation id unique and unused in current Relation Service
- have for relation type a relation type created in the Relation Service
- have roles conforming to the role info provided in the relation type.
- Specified by:
- addRelation from RelationServiceMBean
-
addRelationTypetop
public void addRelationType(RelationType relationTypeObj) throws IllegalArgumentException, InvalidRelationTypeExceptionAdds given object as a relation type. The object is expected to implement the RelationType interface.- Specified by:
- addRelationType from RelationServiceMBean
-
checkRoleReadingtop
public Integer checkRoleReading(String roleName, String relationTypeName) throws IllegalArgumentException, RelationTypeNotFoundExceptionChecks if given Role can be read in a relation of the given type.- Specified by:
- checkRoleReading from RelationServiceMBean
-
checkRoleWritingtop
public Integer checkRoleWriting(Role role, String relationTypeName, Boolean initFlag) throws IllegalArgumentException, RelationTypeNotFoundExceptionChecks if given Role can be set in a relation of given type.- Specified by:
- checkRoleWriting from RelationServiceMBean
-
createRelationtop
public void createRelation(String relationId, String relationTypeName, RoleList roleList) throws RelationServiceNotRegisteredException, IllegalArgumentException, RoleNotFoundException, InvalidRelationIdException, RelationTypeNotFoundException, InvalidRoleValueExceptionCreates a simple relation (represented by a RelationSupport object) of given relation type, and adds it in the Relation Service.Roles are initialized according to the role list provided in parameter. The ones not initialized in this way are set to an empty ArrayList of ObjectNames.
A RelationNotification, with type RELATION_BASIC_CREATION, is sent.
- Specified by:
- createRelation from RelationServiceMBean
-
createRelationTypetop
public void createRelationType(String relationTypeName, RoleInfo[] roleInfoArray) throws IllegalArgumentException, InvalidRelationTypeExceptionCreates a relation type (a RelationTypeSupport object) with given role infos (provided by the RoleInfo objects), and adds it in the Relation Service.- Specified by:
- createRelationType from RelationServiceMBean
-
findAssociatedMBeanstop
public Map<ObjectName, List<String>> findAssociatedMBeans(ObjectName mbeanName, String relationTypeName, String roleName) throws IllegalArgumentExceptionRetrieves the MBeans associated to given one in a relation.This corresponds to CIM Associators and AssociatorNames operations.
- Specified by:
- findAssociatedMBeans from RelationServiceMBean
-
findReferencingRelationstop
public Map<String, List<String>> findReferencingRelations(ObjectName mbeanName, String relationTypeName, String roleName) throws IllegalArgumentExceptionRetrieves the relations where a given MBean is referenced.This corresponds to the CIM "References" and "ReferenceNames" operations.
- Specified by:
- findReferencingRelations from RelationServiceMBean
-
findRelationsOfTypetop
public List<String> findRelationsOfType(String relationTypeName) throws IllegalArgumentException, RelationTypeNotFoundExceptionReturns the relation ids for relations of the given type.- Specified by:
- findRelationsOfType from RelationServiceMBean
-
getAllRelationIdstop
Returns all the relation ids for all the relations handled by the Relation Service.- Specified by:
- getAllRelationIds from RelationServiceMBean
-
getAllRelationTypeNamestop
Retrieves names of all known relation types.- Specified by:
- getAllRelationTypeNames from RelationServiceMBean
-
getAllRolestop
public RoleResult getAllRoles(String relationId) throws IllegalArgumentException, RelationNotFoundException, RelationServiceNotRegisteredExceptionReturns all roles present in the relation.- Specified by:
- getAllRoles from RelationServiceMBean
-
getNotificationInfotop
public MBeanNotificationInfo[] getNotificationInfo()Returns a NotificationInfo object containing the name of the Java class of the notification and the notification types sent.- Specified by:
- getNotificationInfo from NotificationBroadcaster
- Override hierarchy:
- getNotificationInfo from NotificationBroadcasterSupport
-
getPurgeFlagtop
public boolean getPurgeFlag()Returns the flag to indicate if when a notification is received for the unregistration of an MBean referenced in a relation, if an immediate "purge" of the relations (look for the relations no longer valid) has to be performed , or if that will be performed only when the purgeRelations method will be explicitly called.true is immediate purge.
- Specified by:
- getPurgeFlag from RelationServiceMBean
-
getReferencedMBeanstop
public Map<ObjectName, List<String>> getReferencedMBeans(String relationId) throws IllegalArgumentException, RelationNotFoundExceptionRetrieves MBeans referenced in the various roles of the relation.- Specified by:
- getReferencedMBeans from RelationServiceMBean
-
getRelationTypeNametop
public String getRelationTypeName(String relationId) throws IllegalArgumentException, RelationNotFoundExceptionReturns name of associated relation type for given relation.- Specified by:
- getRelationTypeName from RelationServiceMBean
-
getRoletop
public List<ObjectName> getRole(String relationId, String roleName) throws RelationServiceNotRegisteredException, IllegalArgumentException, RelationNotFoundException, RoleNotFoundExceptionRetrieves role value for given role name in given relation.- Specified by:
- getRole from RelationServiceMBean
-
getRoleCardinalitytop
public Integer getRoleCardinality(String relationId, String roleName) throws IllegalArgumentException, RelationNotFoundException, RoleNotFoundExceptionRetrieves the number of MBeans currently referenced in the given role.- Specified by:
- getRoleCardinality from RelationServiceMBean
-
getRoleInfotop
public RoleInfo getRoleInfo(String relationTypeName, String roleInfoName) throws IllegalArgumentException, RelationTypeNotFoundException, RoleInfoNotFoundExceptionRetrieves role info for given role name of a given relation type.- Specified by:
- getRoleInfo from RelationServiceMBean
-
getRoleInfostop
public List<RoleInfo> getRoleInfos(String relationTypeName) throws IllegalArgumentException, RelationTypeNotFoundExceptionRetrieves list of role infos (RoleInfo objects) of a given relation type.- Specified by:
- getRoleInfos from RelationServiceMBean
-
getRolestop
public RoleResult getRoles(String relationId, String[] roleNameArray) throws RelationServiceNotRegisteredException, IllegalArgumentException, RelationNotFoundExceptionRetrieves values of roles with given names in given relation.- Specified by:
- getRoles from RelationServiceMBean
-
handleNotificationtop
public void handleNotification(Notification notif, Object handback)Invoked when a JMX notification occurs. Currently handles notifications for unregistration of MBeans, either referenced in a relation role or being a relation itself.- Specified by:
- handleNotification from NotificationListener
-
hasRelationtop
Checks if there is a relation identified in Relation Service with given relation id.- Specified by:
- hasRelation from RelationServiceMBean
-
isActivetop
public void isActive() throws RelationServiceNotRegisteredExceptionChecks if the Relation Service is active. Current condition is that the Relation Service must be registered in the MBean Server- Specified by:
- isActive from RelationServiceMBean
-
isRelationtop
Returns the relation id associated to the given ObjectName if the MBean has been added as a relation in the Relation Service.- Specified by:
- isRelation from RelationServiceMBean
-
isRelationMBeantop
public ObjectName isRelationMBean(String relationId) throws IllegalArgumentException, RelationNotFoundExceptionIf the relation is represented by an MBean (created by the user and added as a relation in the Relation Service), returns the ObjectName of the MBean.- Specified by:
- isRelationMBean from RelationServiceMBean
-
postDeregistertop
public void postDeregister()Allows the MBean to perform any operations needed after having been unregistered in the MBean server.- Specified by:
- postDeregister from MBeanRegistration
-
postRegistertop
public void postRegister(Boolean registrationDone)Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.- Specified by:
- postRegister from MBeanRegistration
-
preDeregistertop
public void preDeregister() throws ExceptionAllows the MBean to perform any operations it needs before being unregistered by the MBean server.- Specified by:
- preDeregister from MBeanRegistration
-
preRegistertop
Allows the MBean to perform any operations it needs before being registered in the MBean server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean server.- Specified by:
- preRegister from MBeanRegistration
-
purgeRelationstop
public void purgeRelations() throws RelationServiceNotRegisteredExceptionPurges the relations.Depending on the purgeFlag value, this method is either called automatically when a notification is received for the unregistration of an MBean referenced in a relation (if the flag is set to true), or not (if the flag is set to false).
In that case it is up to the user to call it to maintain the consistency of the relations. To be kept in mind that if an MBean is unregistered and the purge not done immediately, if the ObjectName is reused and assigned to another MBean referenced in a relation, calling manually this purgeRelations() method will cause trouble, as will consider the ObjectName as corresponding to the unregistered MBean, not seeing the new one.
The behavior depends on the cardinality of the role where the unregistered MBean is referenced:
- if removing one MBean reference in the role makes its number of references less than the minimum degree, the relation has to be removed.
- if the remaining number of references after removing the MBean reference is still in the cardinality range, keep the relation and update it calling its handleMBeanUnregistration() callback.
- Specified by:
- purgeRelations from RelationServiceMBean
-
removeRelationtop
public void removeRelation(String relationId) throws RelationServiceNotRegisteredException, IllegalArgumentException, RelationNotFoundExceptionRemoves given relation from the Relation Service.A RelationNotification notification is sent, its type being:
- RelationNotification.RELATION_BASIC_REMOVAL if the relation was only internal to the Relation Service
- RelationNotification.RELATION_MBEAN_REMOVAL if the relation is registered as an MBean.
For MBeans referenced in such relation, nothing will be done,
- Specified by:
- removeRelation from RelationServiceMBean
-
removeRelationTypetop
public void removeRelationType(String relationTypeName) throws RelationServiceNotRegisteredException, IllegalArgumentException, RelationTypeNotFoundExceptionRemoves given relation type from Relation Service.The relation objects of that type will be removed from the Relation Service.
- Specified by:
- removeRelationType from RelationServiceMBean
-
sendRelationCreationNotificationtop
public void sendRelationCreationNotification(String relationId) throws IllegalArgumentException, RelationNotFoundExceptionSends a notification (RelationNotification) for a relation creation. The notification type is:- RelationNotification.RELATION_BASIC_CREATION if the relation is an object internal to the Relation Service
- RelationNotification.RELATION_MBEAN_CREATION if the relation is a MBean added as a relation.
The source object is the Relation Service itself.
It is called in Relation Service createRelation() and addRelation() methods.
- Specified by:
- sendRelationCreationNotification from RelationServiceMBean
-
sendRelationRemovalNotificationtop
public void sendRelationRemovalNotification(String relationId, List<ObjectName> unregMBeanList) throws IllegalArgumentException, RelationNotFoundExceptionSends a notification (RelationNotification) for a relation removal. The notification type is:- RelationNotification.RELATION_BASIC_REMOVAL if the relation is an object internal to the Relation Service
- RelationNotification.RELATION_MBEAN_REMOVAL if the relation is a MBean added as a relation.
The source object is the Relation Service itself.
It is called in Relation Service removeRelation() method.
- Specified by:
- sendRelationRemovalNotification from RelationServiceMBean
-
sendRoleUpdateNotificationtop
public void sendRoleUpdateNotification(String relationId, Role newRole, List<ObjectName> oldValue) throws IllegalArgumentException, RelationNotFoundExceptionSends a notification (RelationNotification) for a role update in the given relation. The notification type is:- RelationNotification.RELATION_BASIC_UPDATE if the relation is an object internal to the Relation Service
- RelationNotification.RELATION_MBEAN_UPDATE if the relation is a MBean added as a relation.
The source object is the Relation Service itself.
It is called in relation MBean setRole() (for given role) and setRoles() (for each role) methods (implementation provided in RelationSupport class).
It is also called in Relation Service setRole() (for given role) and setRoles() (for each role) methods.
- Specified by:
- sendRoleUpdateNotification from RelationServiceMBean
-
setPurgeFlagtop
public void setPurgeFlag(boolean purgeFlag)Sets the flag to indicate if when a notification is received for the unregistration of an MBean referenced in a relation, if an immediate "purge" of the relations (look for the relations no longer valid) has to be performed , or if that will be performed only when the purgeRelations method will be explicitly called.true is immediate purge.
- Specified by:
- setPurgeFlag from RelationServiceMBean
-
setRoletop
public void setRole(String relationId, Role role) throws RelationServiceNotRegisteredException, IllegalArgumentException, RelationNotFoundException, RoleNotFoundException, InvalidRoleValueExceptionSets the given role in given relation.Will check the role according to its corresponding role definition provided in relation's relation type
The Relation Service will keep track of the change to keep the consistency of relations by handling referenced MBean unregistrations.
- Specified by:
- setRole from RelationServiceMBean
-
setRolestop
public RoleResult setRoles(String relationId, RoleList roleList) throws RelationServiceNotRegisteredException, IllegalArgumentException, RelationNotFoundExceptionSets the given roles in given relation.Will check the role according to its corresponding role definition provided in relation's relation type
The Relation Service keeps track of the changes to keep the consistency of relations by handling referenced MBean unregistrations.
- Specified by:
- setRoles from RelationServiceMBean
-
updateRoleMaptop
public void updateRoleMap(String relationId, Role newRole, List<ObjectName> oldValue) throws IllegalArgumentException, RelationServiceNotRegisteredException, RelationNotFoundExceptionHandles update of the Relation Service role map for the update of given role in given relation.It is called in relation MBean setRole() (for given role) and setRoles() (for each role) methods (implementation provided in RelationSupport class).
It is also called in Relation Service setRole() (for given role) and setRoles() (for each role) methods.
To allow the Relation Service to maintain the consistency (in case of MBean unregistration) and to be able to perform queries, this method must be called when a role is updated.
- Specified by:
- updateRoleMap from RelationServiceMBean
