javax.management.relation
Class RelationSupport

java.lang.Object
  extended byjavax.management.relation.RelationSupport
All Implemented Interfaces:
MBeanRegistration (src) , Relation (src) , RelationSupportMBean (src)

public class RelationSupport
extends java.lang.Object
implements RelationSupportMBean (src) , MBeanRegistration (src)

Implements the management interface for a relation created internally within the relation service. The relation can have only roles - no attributes or methods.

The relation support managed bean can be created externally, including extending it, and then registered with the relation service.


Constructor Summary
RelationSupport(java.lang.String relationId, ObjectName (src)  relationService, MBeanServer (src)  mbeanServer, java.lang.String relationTypeName, RoleList (src)  roleList)
          Construct a new relation support object.
RelationSupport(java.lang.String relationId, ObjectName (src)  relationService, java.lang.String relationTypeName, RoleList (src)  roleList)
          Construct a new relation support object.
 
Method Summary
 RoleResult (src) getAllRoles()
          Retrieves all the roles in this relation.
 java.util.Map getReferencedMBeans()
          Retrieves MBeans referenced by roles of this relation.
 java.lang.String getRelationId()
          Retrieves the relation id used to identify the relation within the relation service.
 ObjectName (src) getRelationServiceName()
          Retrieves the object name of the relation service this relation is registered with.
 java.lang.String getRelationTypeName()
          Retrieves the relation type for this relation.
 java.util.List getRole(java.lang.String roleName)
          Retrieves the role for the passed role name.
 java.lang.Integer getRoleCardinality(java.lang.String roleName)
          Retrieves the number of MBeans in a given role.
 RoleResult (src) getRoles(java.lang.String[] roleNames)
          Retrieves the roles in this relation with the passed names.
 void handleMBeanUnregistration(ObjectName (src)  objectName, java.lang.String roleName)
          The relation service will call this service when an MBean referenced in a role is unregistered.
 java.lang.Boolean isInRelationService()
          Check to see whether this relation thinks it is in relation service.
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registered)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 ObjectName (src) preRegister(MBeanServer (src)  server, ObjectName (src)  objectName)
          This method is called by the MBeanServer before registration takes place.
 RoleList (src) retrieveAllRoles()
          Retrieve all the roles in this relation without checking the role mode.
 void setRelationServiceManagementFlag(java.lang.Boolean value)
          Set the flag to specify whether this relation is registered with the relation service.
 void setRole(Role (src)  role)
          Sets the passed role for this relation.
 RoleResult (src) setRoles(RoleList (src)  roleList)
          Sets the roles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelationSupport

public RelationSupport(java.lang.String relationId,
                       ObjectName (src)  relationService,
                       java.lang.String relationTypeName,
                       RoleList (src)  roleList)
                throws java.lang.IllegalArgumentException,
                       InvalidRoleValueException (src) 
Construct a new relation support object.

This constructor is intended for use when manually registrating a relation support object or an class that extends it.

Constructing the object does not register it with the relation service, only the following is validated at this stage.

The relation id is mandatory.
The relation service name is mandatory.
. The relation type name is mandatory.
The same name is used for more than one role.

Parameters:
relationId - the relation Id
relationService - the object name of the relation service
relationTypeName - the name of the relation type
roleList - the roles in this relation
Throws:
java.lang.IllegalArgumentException - for null values.
InvalidRoleValueException (src) - when two roles have the same name.

RelationSupport

public RelationSupport(java.lang.String relationId,
                       ObjectName (src)  relationService,
                       MBeanServer (src)  mbeanServer,
                       java.lang.String relationTypeName,
                       RoleList (src)  roleList)
                throws java.lang.IllegalArgumentException,
                       InvalidRoleValueException (src) 
Construct a new relation support object.

This constructor is intended for use when manually registrating a relation that delegates to relation support.

Constructing the object does not register it with the relation service, only the following is validated at this stage.

The relation id is mandatory.
The relation service name is mandatory.
. The mbean service is mandatory.
. The relation type name is mandatory.
The same name is used for more than one role.

Parameters:
relationId - the relation Id
relationService - the object name of the relation service
mbeanServer - the object name of the relation service
relationTypeName - the name of the relation type
roleList - the roles in this relation
Throws:
java.lang.IllegalArgumentException - for null values.
InvalidRoleValueException (src) - when two roles have the same name.
Method Detail

getAllRoles

public RoleResult (src)  getAllRoles()
                       throws RelationServiceNotRegisteredException (src) 
Description copied from interface: Relation (src)
Retrieves all the roles in this relation.

Specified by:
getAllRoles in interface Relation (src)
Returns:
the roles both resolved and unresolved.
Throws:
RelationServiceNotRegisteredException (src) - when the relation service is not registered with an MBeanServer.

getReferencedMBeans

public java.util.Map getReferencedMBeans()
Description copied from interface: Relation (src)
Retrieves MBeans referenced by roles of this relation.

The return value is a map keyed by MBean object names. The objects are associated with an ArrayList that contains all the role names the MBean has within this relation.

Specified by:
getReferencedMBeans in interface Relation (src)
Returns:
the map of object names and their roles.

getRelationId

public java.lang.String getRelationId()
Description copied from interface: Relation (src)
Retrieves the relation id used to identify the relation within the relation service.

Specified by:
getRelationId in interface Relation (src)
Returns:
the unique id.

getRelationServiceName

public ObjectName (src)  getRelationServiceName()
Description copied from interface: Relation (src)
Retrieves the object name of the relation service this relation is registered with.

Specified by:
getRelationServiceName in interface Relation (src)
Returns:
the relation service object name.

getRelationTypeName

public java.lang.String getRelationTypeName()
Description copied from interface: Relation (src)
Retrieves the relation type for this relation.

Specified by:
getRelationTypeName in interface Relation (src)
Returns:
the relation type.

getRole

public java.util.List getRole(java.lang.String roleName)
                       throws java.lang.IllegalArgumentException,
                              RoleNotFoundException (src) ,
                              RelationServiceNotRegisteredException (src) 
Description copied from interface: Relation (src)
Retrieves the role for the passed role name. The role must exist and be readable.

The return value is an ArrayList of object names in the role.

Specified by:
getRole in interface Relation (src)
Parameters:
roleName - the role name.
Returns:
the role.
Throws:
java.lang.IllegalArgumentException - for a null role name.
RelationServiceNotRegisteredException (src) - when the relation service is not registered with an MBeanServer.
RoleNotFoundException (src) - when there is no such role or it is not readable.

getRoleCardinality

public java.lang.Integer getRoleCardinality(java.lang.String roleName)
                                     throws java.lang.IllegalArgumentException,
                                            RoleNotFoundException (src) 
Description copied from interface: Relation (src)
Retrieves the number of MBeans in a given role.

Specified by:
getRoleCardinality in interface Relation (src)
Parameters:
roleName - the role name.
Returns:
the number of MBeans.
Throws:
RoleNotFoundException (src) - when there is no such role.
java.lang.IllegalArgumentException - for a null role name.

getRoles

public RoleResult (src)  getRoles(java.lang.String[] roleNames)
                    throws java.lang.IllegalArgumentException,
                           RelationServiceNotRegisteredException (src) 
Description copied from interface: Relation (src)
Retrieves the roles in this relation with the passed names.

Specified by:
getRoles in interface Relation (src)
Parameters:
roleNames - an array of role names
Returns:
the roles both resolved and unresolved.
Throws:
java.lang.IllegalArgumentException - for a null role names.
RelationServiceNotRegisteredException (src) - when the relation service is not registered with an MBeanServer.

handleMBeanUnregistration

public void handleMBeanUnregistration(ObjectName (src)  objectName,
                                      java.lang.String roleName)
                               throws java.lang.IllegalArgumentException,
                                      RoleNotFoundException (src) ,
                                      InvalidRoleValueException (src) ,
                                      RelationServiceNotRegisteredException (src) ,
                                      RelationTypeNotFoundException (src) ,
                                      RelationNotFoundException (src) 
Description copied from interface: Relation (src)
The relation service will call this service when an MBean referenced in a role is unregistered.

The object name should be removed from the role.

Calling this method manually may result in incorrect behaviour

Specified by:
handleMBeanUnregistration in interface Relation (src)
Parameters:
objectName - the object name unregistered.
roleName - the role the containing the object.
Throws:
RelationTypeNotFoundException (src) - when the relation type has not been registered in the relation service.
RoleNotFoundException (src) - if the role does exist or it is not writable.
RelationServiceNotRegisteredException (src) - when the relation service is not registered with an MBeanServer.
InvalidRoleValueException (src) - when the role does not conform to the associated role info.
RelationNotFoundException (src) - when this method is called for for an MBean not registered with the relation service.
java.lang.IllegalArgumentException

retrieveAllRoles

public RoleList (src)  retrieveAllRoles()
Description copied from interface: Relation (src)
Retrieve all the roles in this relation without checking the role mode.

Specified by:
retrieveAllRoles in interface Relation (src)
Returns:
the list of roles.

setRole

public void setRole(Role (src)  role)
             throws java.lang.IllegalArgumentException,
                    RoleNotFoundException (src) ,
                    RelationTypeNotFoundException (src) ,
                    InvalidRoleValueException (src) ,
                    RelationServiceNotRegisteredException (src) ,
                    RelationNotFoundException (src) 
Description copied from interface: Relation (src)
Sets the passed role for this relation.

The role is checked according to its role definition in the relation type. The role is not valid if there are the wrong number of MBeans, an MBean is of an incorrect class or an MBean does not exist.

The notification RELATION_BASIC_UPDATE is sent when the relation is not an MBean or RELATION_MBEAN_UPDATE when it is.

Specified by:
setRole in interface Relation (src)
Parameters:
role - the new role.
Throws:
RoleNotFoundException (src) - if the role is not writable. This test is not performed at initialisation.
InvalidRoleValueException (src) - if the role is not valid.
RelationServiceNotRegisteredException (src) - when the relation service is not registered with an MBeanServer.
RelationTypeNotFoundException (src) - when the relation type has not been registered in the relation service.
RelationNotFoundException (src) - when this method is called for for an MBean not registered with the relation service.
java.lang.IllegalArgumentException - for a null role.

setRoles

public RoleResult (src)  setRoles(RoleList (src)  roleList)
                    throws java.lang.IllegalArgumentException,
                           RelationServiceNotRegisteredException (src) ,
                           RelationTypeNotFoundException (src) ,
                           RelationNotFoundException (src) 
Description copied from interface: Relation (src)
Sets the roles.

The roles are checked according to its role definition in the relation type. The role is not valid if there are the wrong number of MBeans, an MBean is of an incorrect class or an MBean does not exist.

A notification RELATION_BASIC_UPDATE is sent when the relation is not an MBean or RELATION_MBEAN_UPDATE when it is for every updated role.

The return role result has a role list for successfully updated roles and an unresolved list for roles not set.

Specified by:
setRoles in interface Relation (src)
Parameters:
roleList - the new roles.
Returns:
the resulting role result.
Throws:
RelationTypeNotFoundException (src) - when the relation type has not been registered in the relation service.
java.lang.IllegalArgumentException - for a null role name.
RelationServiceNotRegisteredException (src) - when the relation service is not registered with an MBeanServer.
RelationNotFoundException (src) - when this method is called for for an MBean not registered with the relation service.

isInRelationService

public java.lang.Boolean isInRelationService()
Description copied from interface: RelationSupportMBean (src)
Check to see whether this relation thinks it is in relation service.

WARNING: This is not a dynamic check. The flag is set within the relation support object by the relation service, malicious programs may modifiy it to an incorrect value.

Specified by:
isInRelationService in interface RelationSupportMBean (src)
Returns:
true when it is registered.

setRelationServiceManagementFlag

public void setRelationServiceManagementFlag(java.lang.Boolean value)
                                      throws java.lang.IllegalArgumentException
Description copied from interface: RelationSupportMBean (src)
Set the flag to specify whether this relation is registered with the relation service.

WARNING: This method is exposed for management by the relation service. Using this method outside of the relation service does not affect the registration with the relation service.

Specified by:
setRelationServiceManagementFlag in interface RelationSupportMBean (src)
Parameters:
value - pass true for managed by the relation service, false otherwise.
Throws:
java.lang.IllegalArgumentException - for a null value

preRegister

public ObjectName (src)  preRegister(MBeanServer (src)  server,
                              ObjectName (src)  objectName)
                       throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before registration takes place. The MBean is passed a reference of the MBeanServer it is about to be registered with. The MBean must return the ObjectName it will be registered with. The MBeanServer can pass a suggested object depending upon how the MBean is registered.

The MBean can stop the registration by throwing an exception.The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preRegister in interface MBeanRegistration (src)
Returns:
the actual ObjectName to register this MBean with.
Throws:
java.lang.Exception - for any error, the MBean is not registered.

postRegister

public void postRegister(java.lang.Boolean registered)
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface MBeanRegistration (src)
Parameters:
registered - the MBeanServer passes true when the MBean was registered, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface MBeanRegistration (src)
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface MBeanRegistration (src)