javax.management.relation
Interface RelationServiceMBean

All Known Implementing Classes:
RelationService

public interface RelationServiceMBean

The Relation Service is in charge of creating and deleting relation types and relations, of handling the consistency and of providing query mechanisms.

Author:
Young Yang

Method Summary
 void addRelation(ObjectName objectName)
          Adds a MBean created by te user (and registered by him in the MBean Server) as a relation in the Relation Service.
 void addRelationType(RelationType relationType)
          Adds given object as a relation type.
 java.lang.Integer checkRoleReading(java.lang.String roleName, java.lang.String relaionTypeName)
          Checks if given Role can be read in a relation of the given type.
 java.lang.Integer checkRoleWriting(Role role, java.lang.String relTypeName, java.lang.Boolean initFlag)
          Checks if given Role can be set in a relation of given type.
 void createRelation(java.lang.String relationId, java.lang.String relTypeName, RoleList roleList)
          Creates a simple relation (represented by a RelationSupport object) of given relation type, and adds it in the Relation Service.
 void createRelationType(java.lang.String relTypeName, RoleInfo[] roleInfoArray)
          Creates a relation type (RelationTypeSupport object) with given role infos (provided by the RoleInfo objects), and adds it in the Relation Service.
 java.util.Map findAssociatedMBeans(ObjectName mbeanObjectName, java.lang.String relTypeName, java.lang.String roleName)
          Retrieves the MBeans associated to given one in a relation.
 java.util.Map findReferencingRelations(ObjectName mbeanObjectName, java.lang.String relTypeName, java.lang.String roleName)
          Retrieves the relations where a given MBean is referenced.
 java.util.List findRelationsOfType(java.lang.String relTypeName)
          Returns the relation ids for relations of the given type.
 java.util.List getAllRelationIds()
          Returns all the relation ids for all the relations handled by the Relation Service
 java.util.List getAllRelationTypeNames()
          Retrieves names of all known relation types
 RoleResult getAllRoles(java.lang.String relationId)
          Returns all roles present in the relation
 boolean getPurgeFlag()
          Returns the flag to indicate if when a notification is received for the unregistration of a 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.
 java.util.Map getReferencedMBeans(java.lang.String relationId)
          Retrieves MBeans referenced in the various roles of the relation.
 java.lang.String getRelationTypeName(java.lang.String relationId)
          Returns name of associated relation type for given relation.
 java.util.List getRole(java.lang.String relationId, java.lang.String roleName)
          Retrieves role value for given role name in given relation.
 java.lang.Integer getRoleCardinality(java.lang.String relationId, java.lang.String roleName)
          Retrieves the number of MBeans currently referenced in the given role
 RoleInfo getRoleInfo(java.lang.String relTypeName, java.lang.String roleInfoName)
          Retrieves role info for given role of a given relation type
 java.util.List getRoleInfos(java.lang.String relTypeName)
          Retrieves list of role infos (RoleInfo objects) of a given relation type
 RoleResult getRoles(java.lang.String relationId, java.lang.String[] roleNames)
          Retrieves values of roles with given names in given relation.
 java.lang.Boolean hasRelation(java.lang.String relationId)
          Checks if there is a relation identified in Relation Service with given relation id.
 void isActive()
          Checks if the Relation Service is active.
 java.lang.String isRelation(ObjectName objectName)
          Returns the relation id associated to the given ObjectName if the MBean has been added as a relation in the Relation Service.
 ObjectName isRelationMBean(java.lang.String relationId)
          If the relation is represented by a MBean (created by the user and added as a relation in the Relation Service), returns the ObjectName of the MBean.
 void purgeRelations()
          Purges the relations.
 void removeRelation(java.lang.String relationId)
          Removes given relation from the Relation Service.
 void removeRelationType(java.lang.String relTypeName)
          Removes given relation type from Relation Service.
 void sendRelationCreationNotification(java.lang.String relationId)
          Sends a notification (RelationNotification) for a relation creation.
 void sendRelationRemovalNotification(java.lang.String relaionId, java.util.List unregMBeanList)
          Sends a notification (RelationNotification) for a relation removal.
 void sendRoleUpdateNotification(java.lang.String relationId, Role newRole, java.util.List oldRoleValue)
          Sends a notification (RelationNotification) for a role update in the given relation.
 void setPurgeFlag(boolean purgeFlag)
          Sets the flag to indicate if when a notification is received for the unregistration of a 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.
 void setRole(java.lang.String relationId, Role role)
          Sets the given role in given relation.
 RoleResult setRoles(java.lang.String relationId, RoleList roleList)
          Sets the given roles in given relation.
 void updateRoleMap(java.lang.String relationId, Role role, java.util.List oldRoleValue)
          Handles update of the Relation Service role map for the update of given role in given relation.
 

Method Detail

isActive

public void isActive()
              throws RelationServiceNotRegisteredException
Checks if the Relation Service is active. Current condition is that the Relation Service must be registered in the MBean Server

Throws:
RelationServiceNotRegisteredException - if it is not registered

getPurgeFlag

public boolean getPurgeFlag()
Returns the flag to indicate if when a notification is received for the unregistration of a 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.


setPurgeFlag

public void setPurgeFlag(boolean purgeFlag)
Sets the flag to indicate if when a notification is received for the unregistration of a 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.

Parameters:
purgeFlag - flag

createRelationType

public void createRelationType(java.lang.String relTypeName,
                               RoleInfo[] roleInfoArray)
                        throws java.lang.IllegalArgumentException,
                               InvalidRelationTypeException
Creates a relation type (RelationTypeSupport object) with given role infos (provided by the RoleInfo objects), and adds it in the Relation Service.

Parameters:
relTypeName - name of the relation type
roleInfoArray - array of role infos
Throws:
java.lang.IllegalArgumentException - if null parameter
InvalidRelationTypeException - If:

- there is already a relation type with that name

- the same name has been used for two different role infos

- no role info provided

- one null role info provided


addRelationType

public void addRelationType(RelationType relationType)
                     throws java.lang.IllegalArgumentException,
                            InvalidRelationTypeException
Adds given object as a relation type. The object is expected to implement the RelationType interface.

Parameters:
relationType - relation type object (implementing the RelationType interface)
Throws:
java.lang.IllegalArgumentException - if null parameter
InvalidRelationTypeException - if there is already a relation type with that name

getAllRelationTypeNames

public java.util.List getAllRelationTypeNames()
Retrieves names of all known relation types

Returns:
ArrayList of relation type names (Strings)

getRoleInfos

public java.util.List getRoleInfos(java.lang.String relTypeName)
                            throws java.lang.IllegalArgumentException,
                                   RelationTypeNotFoundException
Retrieves list of role infos (RoleInfo objects) of a given relation type

Parameters:
relTypeName - name of relation type
Returns:
ArrayList of RoleInfo.
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationTypeNotFoundException - if there is no relation type with that name.

getRoleInfo

public RoleInfo getRoleInfo(java.lang.String relTypeName,
                            java.lang.String roleInfoName)
                     throws java.lang.IllegalArgumentException,
                            RelationTypeNotFoundException,
                            RoleInfoNotFoundException
Retrieves role info for given role of a given relation type

Parameters:
relTypeName - name of relation type
roleInfoName - name of role
Returns:
RoleInfo object.
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationTypeNotFoundException - if the relation type is not known in the Relation Service
RoleInfoNotFoundException - if the role is not part of the relation type.

removeRelationType

public void removeRelationType(java.lang.String relTypeName)
                        throws RelationServiceNotRegisteredException,
                               java.lang.IllegalArgumentException,
                               RelationTypeNotFoundException
Removes given relation type from Relation Service.

The relation objects of that type will be removed from the Relation Service.

Parameters:
relTypeName - name of the relation type to be removed
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.IllegalArgumentException - if null parameter
RelationTypeNotFoundException - If there is no relation type with that name

createRelation

public void createRelation(java.lang.String relationId,
                           java.lang.String relTypeName,
                           RoleList roleList)
                    throws RelationServiceNotRegisteredException,
                           java.lang.IllegalArgumentException,
                           RoleNotFoundException,
                           InvalidRelationIdException,
                           RelationTypeNotFoundException,
                           InvalidRoleValueException
Creates 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 initialised using that mean are set to an empty ArrayList of ObjectNames.

A RelationNotification, with type RELATION_BASIC_CREATION, is sent.

Parameters:
relationId - relation identifier, to uniquely identify the relation inside the Relation Service
relTypeName - name of the relation type (has to be created in the Relation Service)
roleList - role list to initialise roles of the relation (can be null).
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.IllegalArgumentException - if null paramater
RoleNotFoundException - if a value is provided for a role that does not exist in the relation type
InvalidRelationIdException - if relation id already used
RelationTypeNotFoundException - if relation type not known in Relation Service
InvalidRoleValueException - if:

- the same role name is used for two different roles

- 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


addRelation

public void addRelation(ObjectName objectName)
                 throws java.lang.IllegalArgumentException,
                        RelationServiceNotRegisteredException,
                        java.lang.NoSuchMethodException,
                        InvalidRelationIdException,
                        InstanceNotFoundException,
                        InvalidRelationServiceException,
                        RelationTypeNotFoundException,
                        RoleNotFoundException,
                        InvalidRoleValueException
Adds a MBean created by te 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.

Parameters:
objectName - ObjectName of the relation MBean to be added.
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.NoSuchMethodException - If the MBean does not implement the Relation interface
InvalidRelationIdException - if:

- no relation identifier in MBean

- the relation identifier is already used in the Relation Service

InstanceNotFoundException - if the MBean for given ObjectName has not been registered
InvalidRelationServiceException - if:

- no Relation Service name in MBean

- the Relation Service name in the MBean is not the one of the current Relation Service

RelationTypeNotFoundException - if:

- no relation type name in MBean

- the relation type name in MBean does not correspond to a relation type created in the Relation Service

InvalidRoleValueException - if:

- the number of referenced MBeans in a role is less than expected minimum degree

- the number of referenced MBeans in a role 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 a role does not exist

RoleNotFoundException - if a value is provided for a role that does not exist in the relation type

isRelationMBean

public ObjectName isRelationMBean(java.lang.String relationId)
                           throws java.lang.IllegalArgumentException,
                                  RelationNotFoundException
If the relation is represented by a MBean (created by the user and added as a relation in the Relation Service), returns the ObjectName of the MBean.

Parameters:
relationId - relation id identifying the relation
Returns:
ObjectName of the corresponding relation MBean, or null if the relation is not a MBean.
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - there is no relation associated to that id

isRelation

public java.lang.String isRelation(ObjectName objectName)
                            throws java.lang.IllegalArgumentException
Returns the relation id associated to the given ObjectName if the MBean has been added as a relation in the Relation Service.

Parameters:
objectName - ObjectName of supposed relation
Returns:
relation id (String) or null (if the ObjectName is not a relation handled by the Relation Service)
Throws:
java.lang.IllegalArgumentException - if null parameter

hasRelation

public java.lang.Boolean hasRelation(java.lang.String relationId)
                              throws java.lang.IllegalArgumentException
Checks if there is a relation identified in Relation Service with given relation id.

Parameters:
relationId - relation id identifying the relation
Returns:
boolean: true if there is a relation, false else
Throws:
java.lang.IllegalArgumentException - if null parameter

getAllRelationIds

public java.util.List getAllRelationIds()
Returns all the relation ids for all the relations handled by the Relation Service

Returns:
ArrayList of String

checkRoleReading

public java.lang.Integer checkRoleReading(java.lang.String roleName,
                                          java.lang.String relaionTypeName)
                                   throws java.lang.IllegalArgumentException,
                                          RelationTypeNotFoundException
Checks if given Role can be read in a relation of the given type.

Parameters:
roleName - name of role to be checked
relaionTypeName - name of the relation type
Returns:
an Integer wrapping an integer corresponding to possible problems represented as constants in RoleUnresolved:

- 0 if role can be read

- integer corresponding to RoleStatus.NO_ROLE_WITH_NAME

- integer corresponding to RoleStatus.ROLE_NOT_READABLE

Throws:
java.lang.IllegalArgumentException - if null parameter
RelationTypeNotFoundException - if the relation type is not known in the Relation Service

checkRoleWriting

public java.lang.Integer checkRoleWriting(Role role,
                                          java.lang.String relTypeName,
                                          java.lang.Boolean initFlag)
                                   throws java.lang.IllegalArgumentException,
                                          RelationTypeNotFoundException
Checks if given Role can be set in a relation of given type.

Parameters:
role - role to be checked
relTypeName - name of relation type
initFlag - flag to specify that the checking is done for the initialisation of a role, write access shall not be verified.
Returns:
an Integer wrapping an integer corresponding to possible problems represented as constants in RoleUnresolved:

- 0 if role can be set

- integer corresponding to RoleStatus.NO_ROLE_WITH_NAME

- integer for RoleStatus.ROLE_NOT_WRITABLE

- integer for RoleStatus.LESS_THAN_MIN_ROLE_DEGREE

- integer for RoleStatus.MORE_THAN_MAX_ROLE_DEGREE

- integer for RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS

- integer for RoleStatus.REF_MBEAN_NOT_REGISTERED

Throws:
java.lang.IllegalArgumentException - if null parameter
RelationTypeNotFoundException - if unknown relation type

sendRelationCreationNotification

public void sendRelationCreationNotification(java.lang.String relationId)
                                      throws java.lang.IllegalArgumentException,
                                             RelationNotFoundException
Sends 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.

Parameters:
relationId - relation identifier of the updated relation
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if there is no relation for given relation id

sendRoleUpdateNotification

public void sendRoleUpdateNotification(java.lang.String relationId,
                                       Role newRole,
                                       java.util.List oldRoleValue)
                                throws java.lang.IllegalArgumentException,
                                       RelationNotFoundException
Sends 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.

Parameters:
relationId - relation identifier of the updated relation
newRole - new role (name and new value)
oldRoleValue - old role value (ArrayList of ObjectName objects)
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if there is no relation for given relation id

sendRelationRemovalNotification

public void sendRelationRemovalNotification(java.lang.String relaionId,
                                            java.util.List unregMBeanList)
                                     throws java.lang.IllegalArgumentException,
                                            RelationNotFoundException
Sends 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.

Parameters:
relaionId - relation identifier of the updated relation
unregMBeanList - ArrayList of ObjectNames of MBeans expected to be unregistered due to relation removal (can be null)
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if there is no relation for given relation id

updateRoleMap

public void updateRoleMap(java.lang.String relationId,
                          Role role,
                          java.util.List oldRoleValue)
                   throws java.lang.IllegalArgumentException,
                          RelationServiceNotRegisteredException,
                          RelationNotFoundException
Handles 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.

Parameters:
relationId - relation identifier of the updated relation
role - new role (name and new value)
oldRoleValue - old role value (ArrayList of ObjectName objects)
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
RelationNotFoundException - if no relation for given id.

removeRelation

public void removeRelation(java.lang.String relationId)
                    throws RelationServiceNotRegisteredException,
                           java.lang.IllegalArgumentException,
                           RelationNotFoundException
Removes 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 a MBean.

For MBeans referenced in such relation, nothing will be done,

Parameters:
relationId - relation id of the relation to be removed
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation corresponding to given relation id

purgeRelations

public void purgeRelations()
                    throws RelationServiceNotRegisteredException
Purges the relations.

Depending on the purgeFlag value, this method is either called automatically when a notification is received for the unregistration of a 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 a 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.

Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server.

findReferencingRelations

public java.util.Map findReferencingRelations(ObjectName mbeanObjectName,
                                              java.lang.String relTypeName,
                                              java.lang.String roleName)
                                       throws java.lang.IllegalArgumentException
Retrieves the relations where a given MBean is referenced.

This corresponds to the CIM "References" and "ReferenceNames" operations.

Parameters:
mbeanObjectName - ObjectName of MBean
relTypeName - can be null; if specified, only the relations of that type will be considered in the search. Else all relation types are considered.
roleName - can be null; if specified, only the relations where the MBean is referenced in that role will be returned. Else all roles are considered.
Returns:
an HashMap, where the keys are the relation ids of the relations where the MBean is referenced, and the value is, for each key, an ArrayList of role names (as a MBean can be referenced in several roles in the same relation).
Throws:
java.lang.IllegalArgumentException - if null parameter

findAssociatedMBeans

public java.util.Map findAssociatedMBeans(ObjectName mbeanObjectName,
                                          java.lang.String relTypeName,
                                          java.lang.String roleName)
                                   throws java.lang.IllegalArgumentException
Retrieves the MBeans associated to given one in a relation.

This corresponds to CIM Associators and AssociatorNames operations.

Parameters:
mbeanObjectName - ObjectName of MBean
relTypeName - can be null; if specified, only the relations of that type will be considered in the search. Else all relation types are considered.
roleName - can be null; if specified, only the relations where the MBean is referenced in that role will be considered. Else all roles are considered.
Returns:
an HashMap, where the keys are the ObjectNames of the MBeans associated to given MBean, and the value is, for each key, an ArrayList of the relation ids of the relations where the key MBean is associated to given one (as they can be associated in several different relations).
Throws:
java.lang.IllegalArgumentException - if null parameter

findRelationsOfType

public java.util.List findRelationsOfType(java.lang.String relTypeName)
                                   throws java.lang.IllegalArgumentException,
                                          RelationTypeNotFoundException
Returns the relation ids for relations of the given type.

Parameters:
relTypeName - relation type name
Returns:
an ArrayList of relation ids.
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationTypeNotFoundException - if there is no relation type with that name.

getRole

public java.util.List getRole(java.lang.String relationId,
                              java.lang.String roleName)
                       throws RelationServiceNotRegisteredException,
                              java.lang.IllegalArgumentException,
                              RelationNotFoundException,
                              RoleNotFoundException
Retrieves role value for given role name in given relation.

Parameters:
relationId - relation id
roleName - name of role
Returns:
the ArrayList of ObjectName objects being the role value
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation with given id
RoleNotFoundException - if:

- there is no role with given name

or

- the role is not readable.


getRoles

public RoleResult getRoles(java.lang.String relationId,
                           java.lang.String[] roleNames)
                    throws RelationServiceNotRegisteredException,
                           java.lang.IllegalArgumentException,
                           RelationNotFoundException
Retrieves values of roles with given names in given relation.

Parameters:
relationId - relation id
roleNames - array of names of roles to be retrieved
Returns:
a RoleResult object, including a RoleList (for roles succcessfully retrieved) and a RoleUnresolvedList (for roles not retrieved).
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation with given id

getAllRoles

public RoleResult getAllRoles(java.lang.String relationId)
                       throws java.lang.IllegalArgumentException,
                              RelationNotFoundException,
                              RelationServiceNotRegisteredException
Returns all roles present in the relation

Parameters:
relationId - relation id
Returns:
a RoleResult object, including a RoleList (for roles succcessfully retrieved) and a RoleUnresolvedList (for roles not readable).
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation for given id
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server

getRoleCardinality

public java.lang.Integer getRoleCardinality(java.lang.String relationId,
                                            java.lang.String roleName)
                                     throws java.lang.IllegalArgumentException,
                                            RelationNotFoundException,
                                            RoleNotFoundException
Retrieves the number of MBeans currently referenced in the given role

Parameters:
relationId - relation id
roleName - name of role
Returns:
the number of currently referenced MBeans in that role
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation with given id
RoleNotFoundException - if there is no role with given name

setRole

public void setRole(java.lang.String relationId,
                    Role role)
             throws RelationServiceNotRegisteredException,
                    java.lang.IllegalArgumentException,
                    RelationNotFoundException,
                    RoleNotFoundException,
                    InvalidRoleValueException,
                    RelationTypeNotFoundException
Sets 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.

Parameters:
relationId - relation id
role - role to be set (name and new value)
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation with given id
RoleNotFoundException - if:

- internal relation

and

- the role does not exist or is not writable

InvalidRoleValueException - if internal relation and value provided for role is not valid:

- the number of referenced MBeans in given value is less than expected minimum degree

or

- the number of referenced MBeans in provided value exceeds expected maximum degree

or

- one referenced MBean in the value is not an Object of the MBean class expected for that role

or

- a MBean provided for that role does not exist

RelationTypeNotFoundException - if unknown relation type

setRoles

public RoleResult setRoles(java.lang.String relationId,
                           RoleList roleList)
                    throws RelationServiceNotRegisteredException,
                           java.lang.IllegalArgumentException,
                           RelationNotFoundException
Sets 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.

Parameters:
relationId - relation id
roleList - list of roles to be set
Returns:
a RoleResult object, including a RoleList (for roles succcessfully set) and a RoleUnresolvedList (for roles not set).
Throws:
RelationServiceNotRegisteredException - if the Relation Service is not registered in the MBean Server
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation with given id

getReferencedMBeans

public java.util.Map getReferencedMBeans(java.lang.String relationId)
                                  throws java.lang.IllegalArgumentException,
                                         RelationNotFoundException
Retrieves MBeans referenced in the various roles of the relation.

Parameters:
relationId - relation id
Returns:
a HashMap mapping:

ObjectName -> ArrayList of String (role names)

Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation for given relation id

getRelationTypeName

public java.lang.String getRelationTypeName(java.lang.String relationId)
                                     throws java.lang.IllegalArgumentException,
                                            RelationNotFoundException
Returns name of associated relation type for given relation.

Parameters:
relationId - relation id
Throws:
java.lang.IllegalArgumentException - if null parameter
RelationNotFoundException - if no relation for given relation id