Top Description Fields Constructors Methods
javax.management.relation

public Class RelationService

extends NotificationBroadcasterSupport
implements RelationServiceMBean, MBeanRegistration, NotificationListener
Class Inheritance
All Implemented Interfaces
javax.management.NotificationListener, java.util.EventListener, javax.management.MBeanRegistration, javax.management.relation.RelationServiceMBean
Static Imports
com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER, com.sun.jmx.mbeanserver.Util.cast

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

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.

Since
1.5

Field Summary

Modifier and TypeField and Description
private final AtomicLong
private MBeanServer
private ObjectName
private boolean
private final Map<ObjectName, Map<String, List<String>>>
private Map<String, Object>
private Map<String, String>
private Map<ObjectName, String>
private Map<String, RelationType>
private Map<String, List<String>>
private MBeanServerNotificationFilter
private List<MBeanServerNotification>

Constructor Summary

AccessConstructor and Description
public
RelationService(boolean
flag to indicate 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.

immediatePurgeFlag
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private boolean
addNewMBeanReference(ObjectName objectName, String relationId, String roleName)

public void
addRelation(ObjectName
ObjectName of the relation MBean to be added.
relationObjectName
)

Implements javax.management.relation.RelationServiceMBean.addRelation.

Adds an MBean created by the user (and registered by him in the MBean Server) as a relation in the Relation Service.

private void
addRelationInt(boolean relationBaseFlag, RelationSupport relationObj, ObjectName relationObjName, String relationId, String relationTypeName, RoleList roleList)

public void
addRelationType(RelationType
relation type object (implementing the RelationType interface)
relationTypeObj
)

Implements javax.management.relation.RelationServiceMBean.addRelationType.

Adds given object as a relation type.

private void
private Integer
checkRoleInt(int chkType, String roleName, List<ObjectName> roleValue, RoleInfo roleInfo, boolean writeChkFlag)

public Integer

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

checkRoleReading
(String
name of role to be checked
roleName
,
String
name of the relation type
relationTypeName
)

Implements javax.management.relation.RelationServiceMBean.checkRoleReading.

Checks if given Role can be read in a relation of the given type.

public Integer

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

checkRoleWriting
(Role
role to be checked
role
,
String
name of relation type
relationTypeName
,
Boolean
flag to specify that the checking is done for the initialization of a role, write access shall not be verified.
initFlag
)

Implements javax.management.relation.RelationServiceMBean.checkRoleWriting.

Checks if given Role can be set in a relation of given type.

public void
createRelation(String
relation identifier, to identify uniquely the relation inside the Relation Service
relationId
,
String
name of the relation type (has to be created in the Relation Service)
relationTypeName
,
RoleList
role list to initialize roles of the relation (can be null).
roleList
)

Implements javax.management.relation.RelationServiceMBean.createRelation.

Creates a simple relation (represented by a RelationSupport object) of given relation type, and adds it in the Relation Service.

public void
createRelationType(String
name of the relation type
relationTypeName
,
RoleInfo[]
array of role infos
roleInfoArray
)

Implements javax.management.relation.RelationServiceMBean.createRelationType.

Creates a relation type (a RelationTypeSupport object) with given role infos (provided by the RoleInfo objects), and adds it in the Relation Service.

public Map<ObjectName, List<String>>

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).
findAssociatedMBeans
(ObjectName
ObjectName of MBean
mbeanName
,
String
can be null; if specified, only the relations of that type will be considered in the search. Else all relation types are considered.
relationTypeName
,
String
can be null; if specified, only the relations where the MBean is referenced in that role will be considered. Else all roles are considered.
roleName
)

Implements javax.management.relation.RelationServiceMBean.findAssociatedMBeans.

Retrieves the MBeans associated to given one in a relation.

public Map<String, List<String>>

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 an MBean can be referenced in several roles in the same relation).
findReferencingRelations
(ObjectName
ObjectName of MBean
mbeanName
,
String
can be null; if specified, only the relations of that type will be considered in the search. Else all relation types are considered.
relationTypeName
,
String
can be null; if specified, only the relations where the MBean is referenced in that role will be returned. Else all roles are considered.
roleName
)

Implements javax.management.relation.RelationServiceMBean.findReferencingRelations.

Retrieves the relations where a given MBean is referenced.

public List<String>

Returns:

an ArrayList of relation ids.
findRelationsOfType
(String
relation type name
relationTypeName
)

Implements javax.management.relation.RelationServiceMBean.findRelationsOfType.

Returns the relation ids for relations of the given type.

public List<String>

Returns:

ArrayList of String
getAllRelationIds
()

Implements javax.management.relation.RelationServiceMBean.getAllRelationIds.

Returns all the relation ids for all the relations handled by the Relation Service.

public List<String>

Returns:

ArrayList of relation type names (Strings)
getAllRelationTypeNames
()

Implements javax.management.relation.RelationServiceMBean.getAllRelationTypeNames.

Retrieves names of all known relation types.

public RoleResult

Returns:

a RoleResult object, including a RoleList (for roles successfully retrieved) and a RoleUnresolvedList (for roles not readable).
getAllRoles
(String
relation id
relationId
)

Implements javax.management.relation.RelationServiceMBean.getAllRoles.

Returns all roles present in the relation.

public MBeanNotificationInfo[]
getNotificationInfo()

Overrides javax.management.NotificationBroadcasterSupport.getNotificationInfo.

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Returns a NotificationInfo object containing the name of the Java class of the notification and the notification types sent.

public boolean

Returns:

true if purges are automatic.
getPurgeFlag
()

Implements javax.management.relation.RelationServiceMBean.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.

public Map<ObjectName, List<String>>

Returns:

a HashMap mapping:

ObjectName -> ArrayList of String (role names)

getReferencedMBeans
(String
relation id
relationId
)

Implements javax.management.relation.RelationServiceMBean.getReferencedMBeans.

Retrieves MBeans referenced in the various roles of the relation.

pack-priv Object
getRelation(String relationId)

pack-priv RelationType
getRelationType(String relationTypeName)

public String

Returns:

the name of the associated relation type.
getRelationTypeName
(String
relation id
relationId
)

Implements javax.management.relation.RelationServiceMBean.getRelationTypeName.

Returns name of associated relation type for given relation.

public List<ObjectName>

Returns:

the ArrayList of ObjectName objects being the role value
getRole
(String
relation id
relationId
,
String
name of role
roleName
)

Implements javax.management.relation.RelationServiceMBean.getRole.

Retrieves role value for given role name in given relation.

public Integer

Returns:

the number of currently referenced MBeans in that role
getRoleCardinality
(String
relation id
relationId
,
String
name of role
roleName
)

Implements javax.management.relation.RelationServiceMBean.getRoleCardinality.

Retrieves the number of MBeans currently referenced in the given role.

public RoleInfo

Returns:

RoleInfo object.
getRoleInfo
(String
name of relation type
relationTypeName
,
String
name of role
roleInfoName
)

Implements javax.management.relation.RelationServiceMBean.getRoleInfo.

Retrieves role info for given role name of a given relation type.

public List<RoleInfo>

Returns:

ArrayList of RoleInfo.
getRoleInfos
(String
name of relation type
relationTypeName
)

Implements javax.management.relation.RelationServiceMBean.getRoleInfos.

Retrieves list of role infos (RoleInfo objects) of a given relation type.

public RoleResult

Returns:

a RoleResult object, including a RoleList (for roles successfully retrieved) and a RoleUnresolvedList (for roles not retrieved).
getRoles
(String
relation id
relationId
,
String[]
array of names of roles to be retrieved
roleNameArray
)

Implements javax.management.relation.RelationServiceMBean.getRoles.

Retrieves values of roles with given names in given relation.

public void
handleNotification(Notification
The notification.
notif
,
Object
An opaque object which helps the listener to associate information regarding the MBean emitter (can be null).
handback
)

Implements javax.management.NotificationListener.handleNotification.

Invoked when a JMX notification occurs.

private void
handleReferenceUnregistration(String relationId, ObjectName objectName, List<String> roleNameList)

public Boolean

Returns:

boolean: true if there is a relation, false else
hasRelation
(String
relation id identifying the relation
relationId
)

Implements javax.management.relation.RelationServiceMBean.hasRelation.

Checks if there is a relation identified in Relation Service with given relation id.

private void
initializeMissingRoles(boolean relationBaseFlag, RelationSupport relationObj, ObjectName relationObjName, String relationId, String relationTypeName, List<RoleInfo> roleInfoList)

public void
isActive()

Implements javax.management.relation.RelationServiceMBean.isActive.

Checks if the Relation Service is active.

public String

Returns:

relation id (String) or null (if the ObjectName is not a relation handled by the Relation Service)
isRelation
(ObjectName
ObjectName of supposed relation
objectName
)

Implements javax.management.relation.RelationServiceMBean.isRelation.

Returns the relation id associated to the given ObjectName if the MBean has been added as a relation in the Relation Service.

public ObjectName

Returns:

ObjectName of the corresponding relation MBean, or null if the relation is not an MBean.
isRelationMBean
(String
relation id identifying the relation
relationId
)

Implements javax.management.relation.RelationServiceMBean.isRelationMBean.

If 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.

public void
postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

Allows the MBean to perform any operations needed after having been unregistered in the MBean server.

public void
postRegister(Boolean
Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.
registrationDone
)

Implements javax.management.MBeanRegistration.postRegister.

Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

public void
preDeregister()

Implements javax.management.MBeanRegistration.preDeregister.

Allows the MBean to perform any operations it needs before being unregistered by the MBean server.

public ObjectName
preRegister(MBeanServer
The MBean Server in which the MBean will be registered.
server
,
ObjectName
The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.
name
)

Implements javax.management.MBeanRegistration.preRegister.

Allows the MBean to perform any operations it needs before being registered in the MBean Server.

public void
private boolean
removeMBeanReference(ObjectName objectName, String relationId, String roleName, boolean allRolesFlag)

public void
removeRelation(String
relation id of the relation to be removed
relationId
)

Implements javax.management.relation.RelationServiceMBean.removeRelation.

Removes given relation from the Relation Service.

public void
removeRelationType(String
name of the relation type to be removed
relationTypeName
)

Implements javax.management.relation.RelationServiceMBean.removeRelationType.

Removes given relation type from Relation Service.

private void
sendNotificationInt(int intNtfType, String message, String relationId, List<ObjectName> unregMBeanList, String roleName, List<ObjectName> roleNewValue, List<ObjectName> oldValue)

public void
sendRelationCreationNotification(String
relation identifier of the updated relation
relationId
)

Implements javax.management.relation.RelationServiceMBean.sendRelationCreationNotification.

Sends a notification (RelationNotification) for a relation creation.

public void
sendRelationRemovalNotification(String
relation identifier of the updated relation
relationId
,
List<ObjectName>
List of ObjectNames of MBeans expected to be unregistered due to relation removal (can be null)
unregMBeanList
)

Implements javax.management.relation.RelationServiceMBean.sendRelationRemovalNotification.

Sends a notification (RelationNotification) for a relation removal.

public void
sendRoleUpdateNotification(String
relation identifier of the updated relation
relationId
,
Role
new role (name and new value)
newRole
,
List<ObjectName>
old role value (List of ObjectName objects)
oldValue
)

Implements javax.management.relation.RelationServiceMBean.sendRoleUpdateNotification.

Sends a notification (RelationNotification) for a role update in the given relation.

public void
setPurgeFlag(boolean
flag
purgeFlag
)

Implements javax.management.relation.RelationServiceMBean.setPurgeFlag.

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.

public void
setRole(String
relation id
relationId
,
Role
role to be set (name and new value)
role
)

Implements javax.management.relation.RelationServiceMBean.setRole.

Sets the given role in given relation.

public RoleResult

Returns:

a RoleResult object, including a RoleList (for roles successfully set) and a RoleUnresolvedList (for roles not set).
setRoles
(String
relation id
relationId
,
RoleList
list of roles to be set
roleList
)

Implements javax.management.relation.RelationServiceMBean.setRoles.

Sets the given roles in given relation.

pack-priv static void
throwRoleProblemException(int pbType, String roleName)

public void
updateRoleMap(String
relation identifier of the updated relation
relationId
,
Role
new role (name and new value)
newRole
,
List<ObjectName>
old role value (List of ObjectName objects)
oldValue
)

Implements javax.management.relation.RelationServiceMBean.updateRoleMap.

Handles update of the Relation Service role map for the update of given role in given relation.

private void
Inherited from javax.management.NotificationBroadcasterSupport:
addNotificationListenerhandleNotificationremoveNotificationListenerremoveNotificationListenersendNotification