A RelationSupport object is used internally by the Relation Service to
represent simple relations (only roles, no properties or methods), with an
unlimited number of roles, of any relation type. As internal representation,
it is not exposed to the user.
RelationSupport class conforms to the design patterns of standard MBean. So
the user can decide to instantiate a RelationSupport object himself as
a MBean (as it follows the MBean design patterns), to register it in the
MBean Server, and then to add it in the Relation Service.
The user can also, when creating his own MBean relation class, have it
extending RelationSupport, to retrieve the implementations of required
interfaces (see below).
It is also possible to have in a user relation MBean class a member
being a RelationSupport object, and to implement the required interfaces by
delegating all to this member.
RelationSupport implements the Relation interface (to be handled by the
Relation Service).
It implements also the MBeanRegistration interface to be able to retrieve
the MBean Server where it is registered (if registered as a MBean) to access
to its Relation Service.
Constructor: |
public RelationSupport(String relationId,
ObjectName relationServiceName,
String relationTypeName,
RoleList list) throws InvalidRoleValueException, IllegalArgumentException {
super();
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"RelationSupport");
// Can throw InvalidRoleValueException and IllegalArgumentException
initMembers(relationId,
relationServiceName,
null,
relationTypeName,
list);
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"RelationSupport");
}
Creates a {@code RelationSupport} object.
This constructor has to be used when the RelationSupport object will
be registered as a MBean by the user, or when creating a user relation
MBean whose class extends RelationSupport.
Nothing is done at the Relation Service level, i.e.
the {@code RelationSupport} object is not added to the
{@code RelationService} and no checks are performed to
see if the provided values are correct.
The object is always created, EXCEPT if:
- any of the required parameters is {@code null}.
- the same name is used for two roles.
To be handled as a relation, the {@code RelationSupport} object has
to be added to the Relation Service using the Relation Service method
addRelation(). Parameters:
relationId - relation identifier, to identify the relation in the
Relation Service.
Expected to be unique in the given Relation Service.
relationServiceName - ObjectName of the Relation Service where
the relation will be registered.
This parameter is required as it is the Relation Service that is
aware of the definition of the relation type of the given relation,
so that will be able to check update operations (set).
relationTypeName - Name of relation type.
Expected to have been created in the given Relation Service.
list - list of roles (Role objects) to initialize the
relation. Can be {@code null}.
Expected to conform to relation info in associated relation type.
Throws:
InvalidRoleValueException - if the same name is used for two
roles.
IllegalArgumentException - if any of the required parameters
(relation id, relation service ObjectName, or relation type name) is
{@code null}.
- exception:
InvalidRoleValueException - if the same name is used for two
roles.
- exception:
IllegalArgumentException - if any of the required parameters
(relation id, relation service ObjectName, or relation type name) is
{@code null}.
|
public RelationSupport(String relationId,
ObjectName relationServiceName,
MBeanServer relationServiceMBeanServer,
String relationTypeName,
RoleList list) throws InvalidRoleValueException, IllegalArgumentException {
super();
if (relationServiceMBeanServer == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"RelationSupport");
// Can throw InvalidRoleValueException and
// IllegalArgumentException
initMembers(relationId,
relationServiceName,
relationServiceMBeanServer,
relationTypeName,
list);
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"RelationSupport");
}
Creates a {@code RelationSupport} object.
This constructor has to be used when the user relation MBean
implements the interfaces expected to be supported by a relation by
delegating to a RelationSupport object.
This object needs to know the Relation Service expected to handle the
relation. So it has to know the MBean Server where the Relation Service
is registered.
According to a limitation, a relation MBean must be registered in the
same MBean Server as the Relation Service expected to handle it. So the
user relation MBean has to be created and registered, and then the
wrapped RelationSupport object can be created within the identified MBean
Server.
Nothing is done at the Relation Service level, i.e.
the {@code RelationSupport} object is not added to the
{@code RelationService} and no checks are performed to
see if the provided values are correct.
The object is always created, EXCEPT if:
- any of the required parameters is {@code null}.
- the same name is used for two roles.
To be handled as a relation, the {@code RelationSupport} object has
to be added to the Relation Service using the Relation Service method
addRelation(). Parameters:
relationId - relation identifier, to identify the relation in the
Relation Service.
Expected to be unique in the given Relation Service.
relationServiceName - ObjectName of the Relation Service where
the relation will be registered.
This parameter is required as it is the Relation Service that is
aware of the definition of the relation type of the given relation,
so that will be able to check update operations (set).
relationServiceMBeanServer - MBean Server where the wrapping MBean
is or will be registered.
Expected to be the MBean Server where the Relation Service is or will
be registered.
relationTypeName - Name of relation type.
Expected to have been created in the given Relation Service.
list - list of roles (Role objects) to initialize the
relation. Can be {@code null}.
Expected to conform to relation info in associated relation type.
Throws:
InvalidRoleValueException - if the same name is used for two
roles.
IllegalArgumentException - if any of the required parameters
(relation id, relation service ObjectName, relation service MBeanServer,
or relation type name) is {@code null}.
- exception:
InvalidRoleValueException - if the same name is used for two
roles.
- exception:
IllegalArgumentException - if any of the required parameters
(relation id, relation service ObjectName, relation service MBeanServer,
or relation type name) is {@code null}.
|
Method from javax.management.relation.RelationSupport Detail: |
public RoleResult getAllRoles() throws RelationServiceNotRegisteredException {
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getAllRoles");
RoleResult result = null;
try {
result = getAllRolesInt(false, null);
} catch (IllegalArgumentException exc) {
// OK : Invalid parameters, ignore...
}
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getAllRoles");
return result;
}
Returns all roles present in the relation. |
RoleResult getAllRolesInt(boolean relationServCallFlg,
RelationService relationServ) throws IllegalArgumentException, RelationServiceNotRegisteredException {
if (relationServCallFlg && relationServ == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getAllRolesInt");
List< String > roleNameList;
synchronized(myRoleName2ValueMap) {
roleNameList =
new ArrayList< String >(myRoleName2ValueMap.keySet());
}
String[] roleNames = new String[roleNameList.size()];
roleNameList.toArray(roleNames);
RoleResult result = getRolesInt(roleNames,
relationServCallFlg,
relationServ);
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"getAllRolesInt");
return result;
}
|
public Map<String> getReferencedMBeans() {
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getReferencedMBeans");
Map< ObjectName,List< String > > refMBeanMap =
new HashMap< ObjectName,List< String > >();
synchronized(myRoleName2ValueMap) {
for (Role currRole : myRoleName2ValueMap.values()) {
String currRoleName = currRole.getRoleName();
// Retrieves ObjectNames of MBeans referenced in current role
List< ObjectName > currRefMBeanList = currRole.getRoleValue();
for (ObjectName currRoleObjName : currRefMBeanList) {
// Sees if current MBean has been already referenced in
// roles already seen
List< String > mbeanRoleNameList =
refMBeanMap.get(currRoleObjName);
boolean newRefFlg = false;
if (mbeanRoleNameList == null) {
newRefFlg = true;
mbeanRoleNameList = new ArrayList< String >();
}
mbeanRoleNameList.add(currRoleName);
if (newRefFlg) {
refMBeanMap.put(currRoleObjName, mbeanRoleNameList);
}
}
}
}
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"getReferencedMBeans");
return refMBeanMap;
}
Retrieves MBeans referenced in the various roles of the relation. |
public String getRelationId() {
return myRelId;
}
Returns relation identifier (used to uniquely identify the relation
inside the Relation Service). |
public ObjectName getRelationServiceName() {
return myRelServiceName;
}
Returns ObjectName of the Relation Service handling the relation. |
public String getRelationTypeName() {
return myRelTypeName;
}
Returns name of associated relation type. |
public List<ObjectName> getRole(String roleName) throws IllegalArgumentException, RoleNotFoundException, RelationServiceNotRegisteredException {
if (roleName == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getRole", roleName);
// Can throw RoleNotFoundException and
// RelationServiceNotRegisteredException
List< ObjectName > result = cast(
getRoleInt(roleName, false, null, false));
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRole");
return result;
}
|
public Integer getRoleCardinality(String roleName) throws IllegalArgumentException, RoleNotFoundException {
if (roleName == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getRoleCardinality", roleName);
// Try to retrieve the role
Role role;
synchronized(myRoleName2ValueMap) {
// No null Role is allowed, so direct use of get()
role = (myRoleName2ValueMap.get(roleName));
}
if (role == null) {
int pbType = RoleStatus.NO_ROLE_WITH_NAME;
// Will throw a RoleNotFoundException
//
// Will not throw InvalidRoleValueException, so catch it for the
// compiler
try {
RelationService.throwRoleProblemException(pbType,
roleName);
} catch (InvalidRoleValueException exc) {
// OK : Do not throw InvalidRoleValueException as
// a RoleNotFoundException will be thrown.
}
}
List< ObjectName > roleValue = role.getRoleValue();
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"getRoleCardinality");
return roleValue.size();
}
Returns the number of MBeans currently referenced in the given role. |
Object getRoleInt(String roleName,
boolean relationServCallFlg,
RelationService relationServ,
boolean multiRoleFlg) throws IllegalArgumentException, RoleNotFoundException, RelationServiceNotRegisteredException {
if (roleName == null ||
(relationServCallFlg && relationServ == null)) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getRoleInt", roleName);
int pbType = 0;
Role role;
synchronized(myRoleName2ValueMap) {
// No null Role is allowed, so direct use of get()
role = (myRoleName2ValueMap.get(roleName));
}
if (role == null) {
pbType = RoleStatus.NO_ROLE_WITH_NAME;
} else {
// Checks if the role is readable
Integer status;
if (relationServCallFlg) {
// Call from the Relation Service, so direct access to it,
// avoiding MBean Server
// Shall not throw a RelationTypeNotFoundException
try {
status = relationServ.checkRoleReading(roleName,
myRelTypeName);
} catch (RelationTypeNotFoundException exc) {
throw new RuntimeException(exc.getMessage());
}
} else {
// Call from getRole() method above
// So we have a MBean. We must access the Relation Service
// via the MBean Server.
Object[] params = new Object[2];
params[0] = roleName;
params[1] = myRelTypeName;
String[] signature = new String[2];
signature[0] = "java.lang.String";
signature[1] = "java.lang.String";
// Can throw InstanceNotFoundException if the Relation
// Service is not registered (to be catched in any case and
// transformed into RelationServiceNotRegisteredException).
//
// Shall not throw a MBeanException, or a ReflectionException
// or an InstanceNotFoundException
try {
status = (Integer)
(myRelServiceMBeanServer.invoke(myRelServiceName,
"checkRoleReading",
params,
signature));
} catch (MBeanException exc1) {
throw new RuntimeException("incorrect relation type");
} catch (ReflectionException exc2) {
throw new RuntimeException(exc2.getMessage());
} catch (InstanceNotFoundException exc3) {
throw new RelationServiceNotRegisteredException(
exc3.getMessage());
}
}
pbType = status.intValue();
}
Object result;
if (pbType == 0) {
// Role can be retrieved
if (!(multiRoleFlg)) {
// Single role retrieved: returns its value
// Note: no need to test if role value (list) not null before
// cloning, null value not allowed, empty list if
// nothing.
result = new ArrayList< ObjectName >(role.getRoleValue());
} else {
// Role retrieved during multi-role retrieval: returns the
// role
result = (Role)(role.clone());
}
} else {
// Role not retrieved
if (!(multiRoleFlg)) {
// Problem when retrieving a simple role: either role not
// found or not readable, so raises a RoleNotFoundException.
try {
RelationService.throwRoleProblemException(pbType,
roleName);
// To keep compiler happy :)
return null;
} catch (InvalidRoleValueException exc) {
throw new RuntimeException(exc.getMessage());
}
} else {
// Problem when retrieving a role in a multi-role retrieval:
// returns a RoleUnresolved object
result = new RoleUnresolved(roleName, null, pbType);
}
}
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoleInt");
return result;
}
|
public RoleResult getRoles(String[] roleNameArray) throws IllegalArgumentException, RelationServiceNotRegisteredException {
if (roleNameArray == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(), "getRoles");
// Can throw RelationServiceNotRegisteredException
RoleResult result = getRolesInt(roleNameArray, false, null);
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoles");
return result;
}
|
RoleResult getRolesInt(String[] roleNameArray,
boolean relationServCallFlg,
RelationService relationServ) throws IllegalArgumentException, RelationServiceNotRegisteredException {
if (roleNameArray == null ||
(relationServCallFlg && relationServ == null)) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"getRolesInt");
RoleList roleList = new RoleList();
RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
for (int i = 0; i < roleNameArray.length; i++) {
String currRoleName = roleNameArray[i];
Object currResult;
// Can throw RelationServiceNotRegisteredException
//
// RoleNotFoundException: not possible but catch it for compiler :)
try {
currResult = getRoleInt(currRoleName,
relationServCallFlg,
relationServ,
true);
} catch (RoleNotFoundException exc) {
return null; // :)
}
if (currResult instanceof Role) {
// Can throw IllegalArgumentException if role is null
// (normally should not happen :(
try {
roleList.add((Role)currResult);
} catch (IllegalArgumentException exc) {
throw new RuntimeException(exc.getMessage());
}
} else if (currResult instanceof RoleUnresolved) {
// Can throw IllegalArgumentException if role is null
// (normally should not happen :(
try {
roleUnresList.add((RoleUnresolved)currResult);
} catch (IllegalArgumentException exc) {
throw new RuntimeException(exc.getMessage());
}
}
}
RoleResult result = new RoleResult(roleList, roleUnresList);
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"getRolesInt");
return result;
}
|
public void handleMBeanUnregistration(ObjectName objectName,
String roleName) throws IllegalArgumentException, RoleNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException {
if (objectName == null || roleName == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"handleMBeanUnregistration",
new Object[]{objectName, roleName});
// Can throw RoleNotFoundException, InvalidRoleValueException,
// or RelationTypeNotFoundException
handleMBeanUnregistrationInt(objectName,
roleName,
false,
null);
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"handleMBeanUnregistration");
return;
}
Callback used by the Relation Service when a MBean referenced in a role
is unregistered.
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. |
void handleMBeanUnregistrationInt(ObjectName objectName,
String roleName,
boolean relationServCallFlg,
RelationService relationServ) throws IllegalArgumentException, RoleNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException {
if (objectName == null ||
roleName == null ||
(relationServCallFlg && relationServ == null)) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"handleMBeanUnregistrationInt", new Object[] {objectName,
roleName, relationServCallFlg, relationServ});
// Retrieves current role value
Role role;
synchronized(myRoleName2ValueMap) {
role = (myRoleName2ValueMap.get(roleName));
}
if (role == null) {
StringBuilder excMsgStrB = new StringBuilder();
String excMsg = "No role with name ";
excMsgStrB.append(excMsg);
excMsgStrB.append(roleName);
throw new RoleNotFoundException(excMsgStrB.toString());
}
List< ObjectName > currRoleValue = role.getRoleValue();
// Note: no need to test if list not null before cloning, null value
// not allowed for role value.
List< ObjectName > newRoleValue = new ArrayList< ObjectName >(currRoleValue);
newRoleValue.remove(objectName);
Role newRole = new Role(roleName, newRoleValue);
// Can throw InvalidRoleValueException,
// RelationTypeNotFoundException
// (RoleNotFoundException already detected)
Object result =
setRoleInt(newRole, relationServCallFlg, relationServ, false);
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"handleMBeanUnregistrationInt");
return;
}
|
public Boolean isInRelationService() {
return myInRelServFlg.get();
}
Returns an internal flag specifying if the object is still handled by
the Relation Service. |
public void postDeregister() {
return;
}
|
public void postRegister(Boolean registrationDone) {
return;
}
|
public void preDeregister() throws Exception {
return;
}
|
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
myRelServiceMBeanServer = server;
return name;
}
|
public RoleList retrieveAllRoles() {
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"retrieveAllRoles");
RoleList result;
synchronized(myRoleName2ValueMap) {
result =
new RoleList(new ArrayList< Role >(myRoleName2ValueMap.values()));
}
RELATION_LOGGER.exiting(RelationSupport.class.getName(),
"retrieveAllRoles");
return result;
}
Returns all roles in the relation without checking read mode. |
public void setRelationServiceManagementFlag(Boolean flag) throws IllegalArgumentException {
if (flag == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
myInRelServFlg.set(flag);
}
|
public void setRole(Role role) throws IllegalArgumentException, RoleNotFoundException, RelationTypeNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationNotFoundException {
if (role == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"setRole", role);
// Will return null :)
Object result = setRoleInt(role, false, null, false);
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRole");
return;
}
Sets the given role.
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). |
Object setRoleInt(Role aRole,
boolean relationServCallFlg,
RelationService relationServ,
boolean multiRoleFlg) throws IllegalArgumentException, RoleNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException {
if (aRole == null ||
(relationServCallFlg && relationServ == null)) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"setRoleInt", new Object[] {aRole, relationServCallFlg,
relationServ, multiRoleFlg});
String roleName = aRole.getRoleName();
int pbType = 0;
// Checks if role exists in the relation
// No error if the role does not exist in the relation, to be able to
// handle initialization of role when creating the relation
// (roles provided in the RoleList parameter are directly set but
// roles automatically initialized are set using setRole())
Role role;
synchronized(myRoleName2ValueMap) {
role = (myRoleName2ValueMap.get(roleName));
}
List< ObjectName > oldRoleValue;
Boolean initFlg;
if (role == null) {
initFlg = true;
oldRoleValue = new ArrayList< ObjectName >();
} else {
initFlg = false;
oldRoleValue = role.getRoleValue();
}
// Checks if the role can be set: is writable (except if
// initialization) and correct value
try {
Integer status;
if (relationServCallFlg) {
// Call from the Relation Service, so direct access to it,
// avoiding MBean Server
//
// Shall not raise a RelationTypeNotFoundException
status = relationServ.checkRoleWriting(aRole,
myRelTypeName,
initFlg);
} else {
// Call from setRole() method above
// So we have a MBean. We must access the Relation Service
// via the MBean Server.
Object[] params = new Object[3];
params[0] = aRole;
params[1] = myRelTypeName;
params[2] = initFlg;
String[] signature = new String[3];
signature[0] = "javax.management.relation.Role";
signature[1] = "java.lang.String";
signature[2] = "java.lang.Boolean";
// Can throw InstanceNotFoundException if the Relation Service
// is not registered (to be transformed into
// RelationServiceNotRegisteredException in any case).
//
// Can throw a MBeanException wrapping a
// RelationTypeNotFoundException:
// throw wrapped exception.
//
// Shall not throw a ReflectionException
status = (Integer)
(myRelServiceMBeanServer.invoke(myRelServiceName,
"checkRoleWriting",
params,
signature));
}
pbType = status.intValue();
} catch (MBeanException exc2) {
// Retrieves underlying exception
Exception wrappedExc = exc2.getTargetException();
if (wrappedExc instanceof RelationTypeNotFoundException) {
throw ((RelationTypeNotFoundException)wrappedExc);
} else {
throw new RuntimeException(wrappedExc.getMessage());
}
} catch (ReflectionException exc3) {
throw new RuntimeException(exc3.getMessage());
} catch (RelationTypeNotFoundException exc4) {
throw new RuntimeException(exc4.getMessage());
} catch (InstanceNotFoundException exc5) {
throw new RelationServiceNotRegisteredException(exc5.getMessage());
}
Object result = null;
if (pbType == 0) {
// Role can be set
if (!(initFlg.booleanValue())) {
// Not initializing the role
// If role being initialized:
// - do not send an update notification
// - do not try to update internal map of Relation Service
// listing referenced MBeans, as role is initialized to an
// empty list
// Sends a notification (RelationNotification)
// Can throw a RelationNotFoundException
sendRoleUpdateNotification(aRole,
oldRoleValue,
relationServCallFlg,
relationServ);
// Updates the role map of the Relation Service
// Can throw RelationNotFoundException
updateRelationServiceMap(aRole,
oldRoleValue,
relationServCallFlg,
relationServ);
}
// Sets the role
synchronized(myRoleName2ValueMap) {
myRoleName2ValueMap.put(roleName,
(Role)(aRole.clone()));
}
// Single role set: returns null: nothing to set in result
if (multiRoleFlg) {
// Multi-roles retrieval: returns the role
result = aRole;
}
} else {
// Role not set
if (!(multiRoleFlg)) {
// Problem when setting a simple role: either role not
// found, not writable, or incorrect value:
// raises appropriate exception, RoleNotFoundException or
// InvalidRoleValueException
RelationService.throwRoleProblemException(pbType,
roleName);
// To keep compiler happy :)
return null;
} else {
// Problem when retrieving a role in a multi-role retrieval:
// returns a RoleUnresolved object
result = new RoleUnresolved(roleName,
aRole.getRoleValue(),
pbType);
}
}
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoleInt");
return result;
}
|
public RoleResult setRoles(RoleList list) throws IllegalArgumentException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException {
if (list == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"setRoles", list);
RoleResult result = setRolesInt(list, false, null);
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoles");
return result;
}
Sets the given roles.
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. |
RoleResult setRolesInt(RoleList list,
boolean relationServCallFlg,
RelationService relationServ) throws IllegalArgumentException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException {
if (list == null ||
(relationServCallFlg && relationServ == null)) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(RelationSupport.class.getName(),
"setRolesInt",
new Object[] {list, relationServCallFlg, relationServ});
RoleList roleList = new RoleList();
RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
for (Role currRole : list.asList()) {
Object currResult = null;
// Can throw:
// RelationServiceNotRegisteredException,
// RelationTypeNotFoundException
//
// Will not throw, due to parameters, RoleNotFoundException or
// InvalidRoleValueException, but catch them to keep compiler
// happy
try {
currResult = setRoleInt(currRole,
relationServCallFlg,
relationServ,
true);
} catch (RoleNotFoundException exc1) {
// OK : Do not throw a RoleNotFoundException.
} catch (InvalidRoleValueException exc2) {
// OK : Do not throw an InvalidRoleValueException.
}
if (currResult instanceof Role) {
// Can throw IllegalArgumentException if role is null
// (normally should not happen :(
try {
roleList.add((Role)currResult);
} catch (IllegalArgumentException exc) {
throw new RuntimeException(exc.getMessage());
}
} else if (currResult instanceof RoleUnresolved) {
// Can throw IllegalArgumentException if role is null
// (normally should not happen :(
try {
roleUnresList.add((RoleUnresolved)currResult);
} catch (IllegalArgumentException exc) {
throw new RuntimeException(exc.getMessage());
}
}
}
RoleResult result = new RoleResult(roleList, roleUnresList);
RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRolesInt");
return result;
}
|