0N/A/*
2362N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.management.relation;
0N/A
0N/Aimport static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER;
0N/Aimport static com.sun.jmx.mbeanserver.Util.cast;
0N/A
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Date;
0N/Aimport java.util.HashMap;
0N/Aimport java.util.Iterator;
0N/Aimport java.util.List;
0N/Aimport java.util.Map;
0N/Aimport java.util.Set;
277N/Aimport java.util.concurrent.atomic.AtomicLong;
0N/Aimport java.util.logging.Level;
0N/A
0N/Aimport javax.management.Attribute;
0N/Aimport javax.management.AttributeNotFoundException;
0N/Aimport javax.management.InstanceNotFoundException;
0N/Aimport javax.management.InvalidAttributeValueException;
0N/Aimport javax.management.MBeanException;
0N/Aimport javax.management.MBeanNotificationInfo;
0N/Aimport javax.management.MBeanRegistration;
0N/Aimport javax.management.MBeanServer;
0N/Aimport javax.management.MBeanServerDelegate;
0N/Aimport javax.management.MBeanServerNotification;
0N/Aimport javax.management.Notification;
0N/Aimport javax.management.NotificationBroadcasterSupport;
0N/Aimport javax.management.NotificationListener;
0N/Aimport javax.management.ObjectName;
0N/Aimport javax.management.ReflectionException;
0N/A
0N/A/**
0N/A * The Relation Service is in charge of creating and deleting relation types
0N/A * and relations, of handling the consistency and of providing query
0N/A * mechanisms.
0N/A * <P>It implements the NotificationBroadcaster by extending
0N/A * NotificationBroadcasterSupport to send notifications when a relation is
0N/A * removed from it.
0N/A * <P>It implements the NotificationListener interface to be able to receive
0N/A * notifications concerning unregistration of MBeans referenced in relation
0N/A * roles and of relation MBeans.
0N/A * <P>It implements the MBeanRegistration interface to be able to retrieve
0N/A * its ObjectName and MBean Server.
0N/A *
0N/A * @since 1.5
0N/A */
0N/Apublic class RelationService extends NotificationBroadcasterSupport
0N/A implements RelationServiceMBean, MBeanRegistration, NotificationListener {
0N/A
0N/A //
0N/A // Private members
0N/A //
0N/A
0N/A // Map associating:
0N/A // <relation id> -> <RelationSupport object/ObjectName>
0N/A // depending if the relation has been created using createRelation()
0N/A // method (so internally handled) or is an MBean added as a relation by the
0N/A // user
0N/A private Map<String,Object> myRelId2ObjMap = new HashMap<String,Object>();
0N/A
0N/A // Map associating:
0N/A // <relation id> -> <relation type name>
0N/A private Map<String,String> myRelId2RelTypeMap = new HashMap<String,String>();
0N/A
0N/A // Map associating:
0N/A // <relation MBean Object Name> -> <relation id>
0N/A private Map<ObjectName,String> myRelMBeanObjName2RelIdMap =
0N/A new HashMap<ObjectName,String>();
0N/A
0N/A // Map associating:
0N/A // <relation type name> -> <RelationType object>
0N/A private Map<String,RelationType> myRelType2ObjMap =
0N/A new HashMap<String,RelationType>();
0N/A
0N/A // Map associating:
0N/A // <relation type name> -> ArrayList of <relation id>
0N/A // to list all the relations of a given type
0N/A private Map<String,List<String>> myRelType2RelIdsMap =
0N/A new HashMap<String,List<String>>();
0N/A
0N/A // Map associating:
0N/A // <ObjectName> -> HashMap
0N/A // the value HashMap mapping:
0N/A // <relation id> -> ArrayList of <role name>
0N/A // to track where a given MBean is referenced.
469N/A private final Map<ObjectName,Map<String,List<String>>>
0N/A myRefedMBeanObjName2RelIdsMap =
0N/A new HashMap<ObjectName,Map<String,List<String>>>();
0N/A
0N/A // Flag to indicate if, when a notification is received for the
0N/A // unregistration of an MBean referenced in a relation, if an immediate
0N/A // "purge" of the relations (look for the relations no
0N/A // longer valid) has to be performed , or if that will be performed only
0N/A // when the purgeRelations method will be explicitly called.
0N/A // true is immediate purge.
0N/A private boolean myPurgeFlag = true;
0N/A
0N/A // Internal counter to provide sequence numbers for notifications sent by:
0N/A // - the Relation Service
0N/A // - a relation handled by the Relation Service
277N/A private final AtomicLong atomicSeqNo = new AtomicLong();
0N/A
0N/A // ObjectName used to register the Relation Service in the MBean Server
0N/A private ObjectName myObjName = null;
0N/A
0N/A // MBean Server where the Relation Service is registered
0N/A private MBeanServer myMBeanServer = null;
0N/A
0N/A // Filter registered in the MBean Server with the Relation Service to be
0N/A // informed of referenced MBean unregistrations
0N/A private MBeanServerNotificationFilter myUnregNtfFilter = null;
0N/A
0N/A // List of unregistration notifications received (storage used if purge
0N/A // of relations when unregistering a referenced MBean is not immediate but
0N/A // on user request)
0N/A private List<MBeanServerNotification> myUnregNtfList =
0N/A new ArrayList<MBeanServerNotification>();
0N/A
0N/A //
0N/A // Constructor
0N/A //
0N/A
0N/A /**
0N/A * Constructor.
0N/A *
0N/A * @param immediatePurgeFlag flag to indicate when a notification is
0N/A * received for the unregistration of an MBean referenced in a relation, if
0N/A * an immediate "purge" of the relations (look for the relations no
0N/A * longer valid) has to be performed , or if that will be performed only
0N/A * when the purgeRelations method will be explicitly called.
0N/A * <P>true is immediate purge.
0N/A */
0N/A public RelationService(boolean immediatePurgeFlag) {
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "RelationService");
0N/A
0N/A setPurgeFlag(immediatePurgeFlag);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "RelationService");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Checks if the Relation Service is active.
0N/A * Current condition is that the Relation Service must be registered in the
0N/A * MBean Server
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if it is not
0N/A * registered
0N/A */
0N/A public void isActive()
0N/A throws RelationServiceNotRegisteredException {
0N/A if (myMBeanServer == null) {
0N/A // MBean Server not set by preRegister(): relation service not
0N/A // registered
0N/A String excMsg =
0N/A "Relation Service not registered in the MBean Server.";
0N/A throw new RelationServiceNotRegisteredException(excMsg);
0N/A }
0N/A return;
0N/A }
0N/A
0N/A //
0N/A // MBeanRegistration interface
0N/A //
0N/A
0N/A // Pre-registration: retrieves its ObjectName and MBean Server
0N/A //
0N/A // No exception thrown.
0N/A public ObjectName preRegister(MBeanServer server,
0N/A ObjectName name)
0N/A throws Exception {
0N/A
0N/A myMBeanServer = server;
0N/A myObjName = name;
0N/A return name;
0N/A }
0N/A
0N/A // Post-registration: does nothing
0N/A public void postRegister(Boolean registrationDone) {
0N/A return;
0N/A }
0N/A
0N/A // Pre-unregistration: does nothing
0N/A public void preDeregister()
0N/A throws Exception {
0N/A return;
0N/A }
0N/A
0N/A // Post-unregistration: does nothing
0N/A public void postDeregister() {
0N/A return;
0N/A }
0N/A
0N/A //
0N/A // Accessors
0N/A //
0N/A
0N/A /**
0N/A * Returns the flag to indicate if when a notification is received for the
0N/A * unregistration of an MBean referenced in a relation, if an immediate
0N/A * "purge" of the relations (look for the relations no longer valid)
0N/A * has to be performed , or if that will be performed only when the
0N/A * purgeRelations method will be explicitly called.
0N/A * <P>true is immediate purge.
0N/A *
0N/A * @return true if purges are automatic.
0N/A *
0N/A * @see #setPurgeFlag
0N/A */
0N/A public boolean getPurgeFlag() {
0N/A return myPurgeFlag;
0N/A }
0N/A
0N/A /**
0N/A * Sets the flag to indicate if when a notification is received for the
0N/A * unregistration of an MBean referenced in a relation, if an immediate
0N/A * "purge" of the relations (look for the relations no longer valid)
0N/A * has to be performed , or if that will be performed only when the
0N/A * purgeRelations method will be explicitly called.
0N/A * <P>true is immediate purge.
0N/A *
0N/A * @param purgeFlag flag
0N/A *
0N/A * @see #getPurgeFlag
0N/A */
0N/A public void setPurgeFlag(boolean purgeFlag) {
0N/A
0N/A myPurgeFlag = purgeFlag;
0N/A return;
0N/A }
0N/A
0N/A //
0N/A // Relation type handling
0N/A //
0N/A
0N/A /**
0N/A * Creates a relation type (a RelationTypeSupport object) with given
0N/A * role infos (provided by the RoleInfo objects), and adds it in the
0N/A * Relation Service.
0N/A *
0N/A * @param relationTypeName name of the relation type
0N/A * @param roleInfoArray array of role infos
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception InvalidRelationTypeException If:
0N/A * <P>- there is already a relation type with that name
0N/A * <P>- the same name has been used for two different role infos
0N/A * <P>- no role info provided
0N/A * <P>- one null role info provided
0N/A */
0N/A public void createRelationType(String relationTypeName,
0N/A RoleInfo[] roleInfoArray)
0N/A throws IllegalArgumentException,
0N/A InvalidRelationTypeException {
0N/A
0N/A if (relationTypeName == null || roleInfoArray == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "createRelationType", relationTypeName);
0N/A
0N/A // Can throw an InvalidRelationTypeException
0N/A RelationType relType =
0N/A new RelationTypeSupport(relationTypeName, roleInfoArray);
0N/A
0N/A addRelationTypeInt(relType);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "createRelationType");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Adds given object as a relation type. The object is expected to
0N/A * implement the RelationType interface.
0N/A *
0N/A * @param relationTypeObj relation type object (implementing the
0N/A * RelationType interface)
0N/A *
0N/A * @exception IllegalArgumentException if null parameter or if
0N/A * {@link RelationType#getRelationTypeName
0N/A * relationTypeObj.getRelationTypeName()} returns null.
0N/A * @exception InvalidRelationTypeException if:
0N/A * <P>- the same name has been used for two different roles
0N/A * <P>- no role info provided
0N/A * <P>- one null role info provided
0N/A * <P>- there is already a relation type with that name
0N/A */
0N/A public void addRelationType(RelationType relationTypeObj)
0N/A throws IllegalArgumentException,
0N/A InvalidRelationTypeException {
0N/A
0N/A if (relationTypeObj == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "addRelationType");
0N/A
0N/A // Checks the role infos
0N/A List<RoleInfo> roleInfoList = relationTypeObj.getRoleInfos();
0N/A if (roleInfoList == null) {
0N/A String excMsg = "No role info provided.";
0N/A throw new InvalidRelationTypeException(excMsg);
0N/A }
0N/A
0N/A RoleInfo[] roleInfoArray = new RoleInfo[roleInfoList.size()];
0N/A int i = 0;
0N/A for (RoleInfo currRoleInfo : roleInfoList) {
0N/A roleInfoArray[i] = currRoleInfo;
0N/A i++;
0N/A }
0N/A // Can throw InvalidRelationTypeException
0N/A RelationTypeSupport.checkRoleInfos(roleInfoArray);
0N/A
0N/A addRelationTypeInt(relationTypeObj);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "addRelationType");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves names of all known relation types.
0N/A *
0N/A * @return ArrayList of relation type names (Strings)
0N/A */
0N/A public List<String> getAllRelationTypeNames() {
277N/A ArrayList<String> result;
0N/A synchronized(myRelType2ObjMap) {
0N/A result = new ArrayList<String>(myRelType2ObjMap.keySet());
0N/A }
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves list of role infos (RoleInfo objects) of a given relation
0N/A * type.
0N/A *
0N/A * @param relationTypeName name of relation type
0N/A *
0N/A * @return ArrayList of RoleInfo.
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationTypeNotFoundException if there is no relation type
0N/A * with that name.
0N/A */
0N/A public List<RoleInfo> getRoleInfos(String relationTypeName)
0N/A throws IllegalArgumentException,
0N/A RelationTypeNotFoundException {
0N/A
0N/A if (relationTypeName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRoleInfos", relationTypeName);
0N/A
0N/A // Can throw a RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getRoleInfos");
0N/A return relType.getRoleInfos();
0N/A }
0N/A
0N/A /**
0N/A * Retrieves role info for given role name of a given relation type.
0N/A *
0N/A * @param relationTypeName name of relation type
0N/A * @param roleInfoName name of role
0N/A *
0N/A * @return RoleInfo object.
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationTypeNotFoundException if the relation type is not
0N/A * known in the Relation Service
0N/A * @exception RoleInfoNotFoundException if the role is not part of the
0N/A * relation type.
0N/A */
0N/A public RoleInfo getRoleInfo(String relationTypeName,
0N/A String roleInfoName)
0N/A throws IllegalArgumentException,
0N/A RelationTypeNotFoundException,
0N/A RoleInfoNotFoundException {
0N/A
0N/A if (relationTypeName == null || roleInfoName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRoleInfo", new Object[] {relationTypeName, roleInfoName});
0N/A
0N/A // Can throw a RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A // Can throw a RoleInfoNotFoundException
0N/A RoleInfo roleInfo = relType.getRoleInfo(roleInfoName);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getRoleInfo");
0N/A return roleInfo;
0N/A }
0N/A
0N/A /**
0N/A * Removes given relation type from Relation Service.
0N/A * <P>The relation objects of that type will be removed from the
0N/A * Relation Service.
0N/A *
0N/A * @param relationTypeName name of the relation type to be removed
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationTypeNotFoundException If there is no relation type
0N/A * with that name
0N/A */
0N/A public void removeRelationType(String relationTypeName)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RelationTypeNotFoundException {
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A if (relationTypeName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "removeRelationType", relationTypeName);
0N/A
0N/A // Checks if the relation type to be removed exists
0N/A // Can throw a RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A // Retrieves the relation ids for relations of that type
0N/A List<String> relIdList = null;
0N/A synchronized(myRelType2RelIdsMap) {
0N/A // Note: take a copy of the list as it is a part of a map that
0N/A // will be updated by removeRelation() below.
0N/A List<String> relIdList1 =
0N/A myRelType2RelIdsMap.get(relationTypeName);
0N/A if (relIdList1 != null) {
0N/A relIdList = new ArrayList<String>(relIdList1);
0N/A }
0N/A }
0N/A
0N/A // Removes the relation type from all maps
0N/A synchronized(myRelType2ObjMap) {
0N/A myRelType2ObjMap.remove(relationTypeName);
0N/A }
0N/A synchronized(myRelType2RelIdsMap) {
0N/A myRelType2RelIdsMap.remove(relationTypeName);
0N/A }
0N/A
0N/A // Removes all relations of that type
0N/A if (relIdList != null) {
0N/A for (String currRelId : relIdList) {
0N/A // Note: will remove it from myRelId2RelTypeMap :)
0N/A //
0N/A // Can throw RelationServiceNotRegisteredException (detected
0N/A // above)
0N/A // Shall not throw a RelationNotFoundException
0N/A try {
0N/A removeRelation(currRelId);
0N/A } catch (RelationNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "removeRelationType");
0N/A return;
0N/A }
0N/A
0N/A //
0N/A // Relation handling
0N/A //
0N/A
0N/A /**
0N/A * Creates a simple relation (represented by a RelationSupport object) of
0N/A * given relation type, and adds it in the Relation Service.
0N/A * <P>Roles are initialized according to the role list provided in
0N/A * parameter. The ones not initialized in this way are set to an empty
0N/A * ArrayList of ObjectNames.
0N/A * <P>A RelationNotification, with type RELATION_BASIC_CREATION, is sent.
0N/A *
0N/A * @param relationId relation identifier, to identify uniquely the relation
0N/A * inside the Relation Service
0N/A * @param relationTypeName name of the relation type (has to be created
0N/A * in the Relation Service)
0N/A * @param roleList role list to initialize roles of the relation (can
0N/A * be null).
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception IllegalArgumentException if null parameter, except the role
0N/A * list which can be null if no role initialization
0N/A * @exception RoleNotFoundException if a value is provided for a role
0N/A * that does not exist in the relation type
0N/A * @exception InvalidRelationIdException if relation id already used
0N/A * @exception RelationTypeNotFoundException if relation type not known in
0N/A * Relation Service
0N/A * @exception InvalidRoleValueException if:
0N/A * <P>- the same role name is used for two different roles
0N/A * <P>- the number of referenced MBeans in given value is less than
0N/A * expected minimum degree
0N/A * <P>- the number of referenced MBeans in provided value exceeds expected
0N/A * maximum degree
0N/A * <P>- one referenced MBean in the value is not an Object of the MBean
0N/A * class expected for that role
0N/A * <P>- an MBean provided for that role does not exist
0N/A */
0N/A public void createRelation(String relationId,
0N/A String relationTypeName,
0N/A RoleList roleList)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RoleNotFoundException,
0N/A InvalidRelationIdException,
0N/A RelationTypeNotFoundException,
0N/A InvalidRoleValueException {
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A if (relationId == null ||
0N/A relationTypeName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "createRelation",
0N/A new Object[] {relationId, relationTypeName, roleList});
0N/A
0N/A // Creates RelationSupport object
0N/A // Can throw InvalidRoleValueException
0N/A RelationSupport relObj = new RelationSupport(relationId,
0N/A myObjName,
0N/A relationTypeName,
0N/A roleList);
0N/A
0N/A // Adds relation object as a relation into the Relation Service
0N/A // Can throw RoleNotFoundException, InvalidRelationId,
0N/A // RelationTypeNotFoundException, InvalidRoleValueException
0N/A //
0N/A // Cannot throw MBeanException
0N/A addRelationInt(true,
0N/A relObj,
0N/A null,
0N/A relationId,
0N/A relationTypeName,
0N/A roleList);
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "createRelation");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Adds an MBean created by the user (and registered by him in the MBean
0N/A * Server) as a relation in the Relation Service.
0N/A * <P>To be added as a relation, the MBean must conform to the
0N/A * following:
0N/A * <P>- implement the Relation interface
0N/A * <P>- have for RelationService ObjectName the ObjectName of current
0N/A * Relation Service
0N/A * <P>- have a relation id unique and unused in current Relation Service
0N/A * <P>- have for relation type a relation type created in the Relation
0N/A * Service
0N/A * <P>- have roles conforming to the role info provided in the relation
0N/A * type.
0N/A *
0N/A * @param relationObjectName ObjectName of the relation MBean to be added.
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception NoSuchMethodException If the MBean does not implement the
0N/A * Relation interface
0N/A * @exception InvalidRelationIdException if:
0N/A * <P>- no relation identifier in MBean
0N/A * <P>- the relation identifier is already used in the Relation Service
0N/A * @exception InstanceNotFoundException if the MBean for given ObjectName
0N/A * has not been registered
0N/A * @exception InvalidRelationServiceException if:
0N/A * <P>- no Relation Service name in MBean
0N/A * <P>- the Relation Service name in the MBean is not the one of the
0N/A * current Relation Service
0N/A * @exception RelationTypeNotFoundException if:
0N/A * <P>- no relation type name in MBean
0N/A * <P>- the relation type name in MBean does not correspond to a relation
0N/A * type created in the Relation Service
0N/A * @exception InvalidRoleValueException if:
0N/A * <P>- the number of referenced MBeans in a role is less than
0N/A * expected minimum degree
0N/A * <P>- the number of referenced MBeans in a role exceeds expected
0N/A * maximum degree
0N/A * <P>- one referenced MBean in the value is not an Object of the MBean
0N/A * class expected for that role
0N/A * <P>- an MBean provided for a role does not exist
0N/A * @exception RoleNotFoundException if a value is provided for a role
0N/A * that does not exist in the relation type
0N/A */
0N/A public void addRelation(ObjectName relationObjectName)
0N/A throws IllegalArgumentException,
0N/A RelationServiceNotRegisteredException,
0N/A NoSuchMethodException,
0N/A InvalidRelationIdException,
0N/A InstanceNotFoundException,
0N/A InvalidRelationServiceException,
0N/A RelationTypeNotFoundException,
0N/A RoleNotFoundException,
0N/A InvalidRoleValueException {
0N/A
0N/A if (relationObjectName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "addRelation", relationObjectName);
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Checks that the relation MBean implements the Relation interface.
0N/A // It will also check that the provided ObjectName corresponds to a
0N/A // registered MBean (else will throw an InstanceNotFoundException)
0N/A if ((!(myMBeanServer.isInstanceOf(relationObjectName, "javax.management.relation.Relation")))) {
0N/A String excMsg = "This MBean does not implement the Relation interface.";
0N/A throw new NoSuchMethodException(excMsg);
0N/A }
0N/A // Checks there is a relation id in the relation MBean (its uniqueness
0N/A // is checked in addRelationInt())
0N/A // Can throw InstanceNotFoundException (but detected above)
0N/A // No MBeanException as no exception raised by this method, and no
0N/A // ReflectionException
277N/A String relId;
0N/A try {
0N/A relId = (String)(myMBeanServer.getAttribute(relationObjectName,
0N/A "RelationId"));
0N/A
0N/A } catch (MBeanException exc1) {
0N/A throw new RuntimeException(
0N/A (exc1.getTargetException()).getMessage());
0N/A } catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (AttributeNotFoundException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A }
0N/A
0N/A if (relId == null) {
0N/A String excMsg = "This MBean does not provide a relation id.";
0N/A throw new InvalidRelationIdException(excMsg);
0N/A }
0N/A // Checks that the Relation Service where the relation MBean is
0N/A // expected to be added is the current one
0N/A // Can throw InstanceNotFoundException (but detected above)
0N/A // No MBeanException as no exception raised by this method, no
0N/A // ReflectionException
277N/A ObjectName relServObjName;
0N/A try {
0N/A relServObjName = (ObjectName)
0N/A (myMBeanServer.getAttribute(relationObjectName,
0N/A "RelationServiceName"));
0N/A
0N/A } catch (MBeanException exc1) {
0N/A throw new RuntimeException(
0N/A (exc1.getTargetException()).getMessage());
0N/A } catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (AttributeNotFoundException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A }
0N/A
0N/A boolean badRelServFlag = false;
0N/A if (relServObjName == null) {
0N/A badRelServFlag = true;
0N/A
0N/A } else if (!(relServObjName.equals(myObjName))) {
0N/A badRelServFlag = true;
0N/A }
0N/A if (badRelServFlag) {
0N/A String excMsg = "The Relation Service referenced in the MBean is not the current one.";
0N/A throw new InvalidRelationServiceException(excMsg);
0N/A }
0N/A // Checks that a relation type has been specified for the relation
0N/A // Can throw InstanceNotFoundException (but detected above)
0N/A // No MBeanException as no exception raised by this method, no
0N/A // ReflectionException
277N/A String relTypeName;
0N/A try {
0N/A relTypeName = (String)(myMBeanServer.getAttribute(relationObjectName,
0N/A "RelationTypeName"));
0N/A
0N/A } catch (MBeanException exc1) {
0N/A throw new RuntimeException(
0N/A (exc1.getTargetException()).getMessage());
0N/A }catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (AttributeNotFoundException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A }
0N/A if (relTypeName == null) {
0N/A String excMsg = "No relation type provided.";
0N/A throw new RelationTypeNotFoundException(excMsg);
0N/A }
0N/A // Retrieves all roles without considering read mode
0N/A // Can throw InstanceNotFoundException (but detected above)
0N/A // No MBeanException as no exception raised by this method, no
0N/A // ReflectionException
277N/A RoleList roleList;
0N/A try {
0N/A roleList = (RoleList)(myMBeanServer.invoke(relationObjectName,
0N/A "retrieveAllRoles",
0N/A null,
0N/A null));
0N/A } catch (MBeanException exc1) {
0N/A throw new RuntimeException(
0N/A (exc1.getTargetException()).getMessage());
0N/A } catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A }
0N/A
0N/A // Can throw RoleNotFoundException, InvalidRelationIdException,
0N/A // RelationTypeNotFoundException, InvalidRoleValueException
0N/A addRelationInt(false,
0N/A null,
0N/A relationObjectName,
0N/A relId,
0N/A relTypeName,
0N/A roleList);
0N/A // Adds relation MBean ObjectName in map
0N/A synchronized(myRelMBeanObjName2RelIdMap) {
0N/A myRelMBeanObjName2RelIdMap.put(relationObjectName, relId);
0N/A }
0N/A
0N/A // Updates flag to specify that the relation is managed by the Relation
0N/A // Service
0N/A // This flag and setter are inherited from RelationSupport and not parts
0N/A // of the Relation interface, so may be not supported.
0N/A try {
0N/A myMBeanServer.setAttribute(relationObjectName,
0N/A new Attribute(
0N/A "RelationServiceManagementFlag",
0N/A Boolean.TRUE));
0N/A } catch (Exception exc) {
0N/A // OK : The flag is not supported.
0N/A }
0N/A
0N/A // Updates listener information to received notification for
0N/A // unregistration of this MBean
0N/A List<ObjectName> newRefList = new ArrayList<ObjectName>();
0N/A newRefList.add(relationObjectName);
0N/A updateUnregistrationListener(newRefList, null);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "addRelation");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * If the relation is represented by an MBean (created by the user and
0N/A * added as a relation in the Relation Service), returns the ObjectName of
0N/A * the MBean.
0N/A *
0N/A * @param relationId relation id identifying the relation
0N/A *
0N/A * @return ObjectName of the corresponding relation MBean, or null if
0N/A * the relation is not an MBean.
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException there is no relation associated
0N/A * to that id
0N/A */
0N/A public ObjectName isRelationMBean(String relationId)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException{
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "isRelationMBean", relationId);
0N/A
0N/A // Can throw RelationNotFoundException
0N/A Object result = getRelation(relationId);
0N/A if (result instanceof ObjectName) {
0N/A return ((ObjectName)result);
0N/A } else {
0N/A return null;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns the relation id associated to the given ObjectName if the
0N/A * MBean has been added as a relation in the Relation Service.
0N/A *
0N/A * @param objectName ObjectName of supposed relation
0N/A *
0N/A * @return relation id (String) or null (if the ObjectName is not a
0N/A * relation handled by the Relation Service)
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A */
0N/A public String isRelation(ObjectName objectName)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (objectName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "isRelation", objectName);
0N/A
0N/A String result = null;
0N/A synchronized(myRelMBeanObjName2RelIdMap) {
0N/A String relId = myRelMBeanObjName2RelIdMap.get(objectName);
0N/A if (relId != null) {
0N/A result = relId;
0N/A }
0N/A }
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Checks if there is a relation identified in Relation Service with given
0N/A * relation id.
0N/A *
0N/A * @param relationId relation id identifying the relation
0N/A *
0N/A * @return boolean: true if there is a relation, false else
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A */
0N/A public Boolean hasRelation(String relationId)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "hasRelation", relationId);
0N/A
0N/A try {
0N/A // Can throw RelationNotFoundException
0N/A Object result = getRelation(relationId);
0N/A return true;
0N/A } catch (RelationNotFoundException exc) {
0N/A return false;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns all the relation ids for all the relations handled by the
0N/A * Relation Service.
0N/A *
0N/A * @return ArrayList of String
0N/A */
0N/A public List<String> getAllRelationIds() {
277N/A List<String> result;
0N/A synchronized(myRelId2ObjMap) {
0N/A result = new ArrayList<String>(myRelId2ObjMap.keySet());
0N/A }
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Checks if given Role can be read in a relation of the given type.
0N/A *
0N/A * @param roleName name of role to be checked
0N/A * @param relationTypeName name of the relation type
0N/A *
0N/A * @return an Integer wrapping an integer corresponding to possible
0N/A * problems represented as constants in RoleUnresolved:
0N/A * <P>- 0 if role can be read
0N/A * <P>- integer corresponding to RoleStatus.NO_ROLE_WITH_NAME
0N/A * <P>- integer corresponding to RoleStatus.ROLE_NOT_READABLE
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationTypeNotFoundException if the relation type is not
0N/A * known in the Relation Service
0N/A */
0N/A public Integer checkRoleReading(String roleName,
0N/A String relationTypeName)
0N/A throws IllegalArgumentException,
0N/A RelationTypeNotFoundException {
0N/A
0N/A if (roleName == null || relationTypeName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "checkRoleReading", new Object[] {roleName, relationTypeName});
0N/A
277N/A Integer result;
0N/A
0N/A // Can throw a RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A try {
0N/A // Can throw a RoleInfoNotFoundException to be transformed into
0N/A // returned value RoleStatus.NO_ROLE_WITH_NAME
0N/A RoleInfo roleInfo = relType.getRoleInfo(roleName);
0N/A
0N/A result = checkRoleInt(1,
0N/A roleName,
0N/A null,
0N/A roleInfo,
0N/A false);
0N/A
0N/A } catch (RoleInfoNotFoundException exc) {
277N/A result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleReading");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Checks if given Role can be set in a relation of given type.
0N/A *
0N/A * @param role role to be checked
0N/A * @param relationTypeName name of relation type
0N/A * @param initFlag flag to specify that the checking is done for the
0N/A * initialization of a role, write access shall not be verified.
0N/A *
0N/A * @return an Integer wrapping an integer corresponding to possible
0N/A * problems represented as constants in RoleUnresolved:
0N/A * <P>- 0 if role can be set
0N/A * <P>- integer corresponding to RoleStatus.NO_ROLE_WITH_NAME
0N/A * <P>- integer for RoleStatus.ROLE_NOT_WRITABLE
0N/A * <P>- integer for RoleStatus.LESS_THAN_MIN_ROLE_DEGREE
0N/A * <P>- integer for RoleStatus.MORE_THAN_MAX_ROLE_DEGREE
0N/A * <P>- integer for RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS
0N/A * <P>- integer for RoleStatus.REF_MBEAN_NOT_REGISTERED
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationTypeNotFoundException if unknown relation type
0N/A */
0N/A public Integer checkRoleWriting(Role role,
0N/A String relationTypeName,
0N/A Boolean initFlag)
0N/A throws IllegalArgumentException,
0N/A RelationTypeNotFoundException {
0N/A
0N/A if (role == null ||
0N/A relationTypeName == null ||
0N/A initFlag == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "checkRoleWriting",
0N/A new Object[] {role, relationTypeName, initFlag});
0N/A
0N/A // Can throw a RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A String roleName = role.getRoleName();
0N/A List<ObjectName> roleValue = role.getRoleValue();
0N/A boolean writeChkFlag = true;
0N/A if (initFlag.booleanValue()) {
0N/A writeChkFlag = false;
0N/A }
0N/A
277N/A RoleInfo roleInfo;
0N/A try {
0N/A roleInfo = relType.getRoleInfo(roleName);
0N/A } catch (RoleInfoNotFoundException exc) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleWriting");
277N/A return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
0N/A }
0N/A
0N/A Integer result = checkRoleInt(2,
0N/A roleName,
0N/A roleValue,
0N/A roleInfo,
0N/A writeChkFlag);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleWriting");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Sends a notification (RelationNotification) for a relation creation.
0N/A * The notification type is:
0N/A * <P>- RelationNotification.RELATION_BASIC_CREATION if the relation is an
0N/A * object internal to the Relation Service
0N/A * <P>- RelationNotification.RELATION_MBEAN_CREATION if the relation is a
0N/A * MBean added as a relation.
0N/A * <P>The source object is the Relation Service itself.
0N/A * <P>It is called in Relation Service createRelation() and
0N/A * addRelation() methods.
0N/A *
0N/A * @param relationId relation identifier of the updated relation
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if there is no relation for given
0N/A * relation id
0N/A */
0N/A public void sendRelationCreationNotification(String relationId)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "sendRelationCreationNotification", relationId);
0N/A
0N/A // Message
0N/A StringBuilder ntfMsg = new StringBuilder("Creation of relation ");
0N/A ntfMsg.append(relationId);
0N/A
0N/A // Can throw RelationNotFoundException
0N/A sendNotificationInt(1,
0N/A ntfMsg.toString(),
0N/A relationId,
0N/A null,
0N/A null,
0N/A null,
0N/A null);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "sendRelationCreationNotification");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Sends a notification (RelationNotification) for a role update in the
0N/A * given relation. The notification type is:
0N/A * <P>- RelationNotification.RELATION_BASIC_UPDATE if the relation is an
0N/A * object internal to the Relation Service
0N/A * <P>- RelationNotification.RELATION_MBEAN_UPDATE if the relation is a
0N/A * MBean added as a relation.
0N/A * <P>The source object is the Relation Service itself.
0N/A * <P>It is called in relation MBean setRole() (for given role) and
0N/A * setRoles() (for each role) methods (implementation provided in
0N/A * RelationSupport class).
0N/A * <P>It is also called in Relation Service setRole() (for given role) and
0N/A * setRoles() (for each role) methods.
0N/A *
0N/A * @param relationId relation identifier of the updated relation
0N/A * @param newRole new role (name and new value)
0N/A * @param oldValue old role value (List of ObjectName objects)
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if there is no relation for given
0N/A * relation id
0N/A */
0N/A public void sendRoleUpdateNotification(String relationId,
0N/A Role newRole,
0N/A List<ObjectName> oldValue)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null ||
0N/A newRole == null ||
0N/A oldValue == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
686N/A if (!(oldValue instanceof ArrayList<?>))
0N/A oldValue = new ArrayList<ObjectName>(oldValue);
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "sendRoleUpdateNotification",
0N/A new Object[] {relationId, newRole, oldValue});
0N/A
0N/A String roleName = newRole.getRoleName();
0N/A List<ObjectName> newRoleVal = newRole.getRoleValue();
0N/A
0N/A // Message
0N/A String newRoleValString = Role.roleValueToString(newRoleVal);
0N/A String oldRoleValString = Role.roleValueToString(oldValue);
0N/A StringBuilder ntfMsg = new StringBuilder("Value of role ");
0N/A ntfMsg.append(roleName);
0N/A ntfMsg.append(" has changed\nOld value:\n");
0N/A ntfMsg.append(oldRoleValString);
0N/A ntfMsg.append("\nNew value:\n");
0N/A ntfMsg.append(newRoleValString);
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A sendNotificationInt(2,
0N/A ntfMsg.toString(),
0N/A relationId,
0N/A null,
0N/A roleName,
0N/A newRoleVal,
0N/A oldValue);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "sendRoleUpdateNotification");
0N/A }
0N/A
0N/A /**
0N/A * Sends a notification (RelationNotification) for a relation removal.
0N/A * The notification type is:
0N/A * <P>- RelationNotification.RELATION_BASIC_REMOVAL if the relation is an
0N/A * object internal to the Relation Service
0N/A * <P>- RelationNotification.RELATION_MBEAN_REMOVAL if the relation is a
0N/A * MBean added as a relation.
0N/A * <P>The source object is the Relation Service itself.
0N/A * <P>It is called in Relation Service removeRelation() method.
0N/A *
0N/A * @param relationId relation identifier of the updated relation
0N/A * @param unregMBeanList List of ObjectNames of MBeans expected
0N/A * to be unregistered due to relation removal (can be null)
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if there is no relation for given
0N/A * relation id
0N/A */
0N/A public void sendRelationRemovalNotification(String relationId,
0N/A List<ObjectName> unregMBeanList)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "sendRelationRemovalNotification",
0N/A new Object[] {relationId, unregMBeanList});
0N/A
0N/A // Can throw RelationNotFoundException
0N/A sendNotificationInt(3,
0N/A "Removal of relation " + relationId,
0N/A relationId,
0N/A unregMBeanList,
0N/A null,
0N/A null,
0N/A null);
0N/A
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "sendRelationRemovalNotification");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Handles update of the Relation Service role map for the update of given
0N/A * role in given relation.
0N/A * <P>It is called in relation MBean setRole() (for given role) and
0N/A * setRoles() (for each role) methods (implementation provided in
0N/A * RelationSupport class).
0N/A * <P>It is also called in Relation Service setRole() (for given role) and
0N/A * setRoles() (for each role) methods.
0N/A * <P>To allow the Relation Service to maintain the consistency (in case
0N/A * of MBean unregistration) and to be able to perform queries, this method
0N/A * must be called when a role is updated.
0N/A *
0N/A * @param relationId relation identifier of the updated relation
0N/A * @param newRole new role (name and new value)
0N/A * @param oldValue old role value (List of ObjectName objects)
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception RelationNotFoundException if no relation for given id.
0N/A */
0N/A public void updateRoleMap(String relationId,
0N/A Role newRole,
0N/A List<ObjectName> oldValue)
0N/A throws IllegalArgumentException,
0N/A RelationServiceNotRegisteredException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null ||
0N/A newRole == null ||
0N/A oldValue == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "updateRoleMap", new Object[] {relationId, newRole, oldValue});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Verifies the relation has been added in the Relation Service
0N/A // Can throw a RelationNotFoundException
0N/A Object result = getRelation(relationId);
0N/A
0N/A String roleName = newRole.getRoleName();
0N/A List<ObjectName> newRoleValue = newRole.getRoleValue();
0N/A // Note: no need to test if oldValue not null before cloning,
0N/A // tested above.
0N/A List<ObjectName> oldRoleValue =
0N/A new ArrayList<ObjectName>(oldValue);
0N/A
0N/A // List of ObjectNames of new referenced MBeans
0N/A List<ObjectName> newRefList = new ArrayList<ObjectName>();
0N/A
0N/A for (ObjectName currObjName : newRoleValue) {
0N/A
0N/A // Checks if this ObjectName was already present in old value
0N/A // Note: use copy (oldRoleValue) instead of original
0N/A // oldValue to speed up, as oldRoleValue is decreased
0N/A // by removing unchanged references :)
0N/A int currObjNamePos = oldRoleValue.indexOf(currObjName);
0N/A
0N/A if (currObjNamePos == -1) {
0N/A // New reference to an ObjectName
0N/A
0N/A // Stores this reference into map
0N/A // Returns true if new reference, false if MBean already
0N/A // referenced
0N/A boolean isNewFlag = addNewMBeanReference(currObjName,
0N/A relationId,
0N/A roleName);
0N/A
0N/A if (isNewFlag) {
0N/A // Adds it into list of new reference
0N/A newRefList.add(currObjName);
0N/A }
0N/A
0N/A } else {
0N/A // MBean was already referenced in old value
0N/A
0N/A // Removes it from old value (local list) to ignore it when
0N/A // looking for remove MBean references
0N/A oldRoleValue.remove(currObjNamePos);
0N/A }
0N/A }
0N/A
0N/A // List of ObjectNames of MBeans no longer referenced
0N/A List<ObjectName> obsRefList = new ArrayList<ObjectName>();
0N/A
0N/A // Each ObjectName remaining in oldRoleValue is an ObjectName no longer
0N/A // referenced in new value
0N/A for (ObjectName currObjName : oldRoleValue) {
0N/A // Removes MBean reference from map
0N/A // Returns true if the MBean is no longer referenced in any
0N/A // relation
0N/A boolean noLongerRefFlag = removeMBeanReference(currObjName,
0N/A relationId,
0N/A roleName,
0N/A false);
0N/A
0N/A if (noLongerRefFlag) {
0N/A // Adds it into list of references to be removed
0N/A obsRefList.add(currObjName);
0N/A }
0N/A }
0N/A
0N/A // To avoid having one listener per ObjectName of referenced MBean,
0N/A // and to increase performances, there is only one listener recording
0N/A // all ObjectNames of interest
0N/A updateUnregistrationListener(newRefList, obsRefList);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "updateRoleMap");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Removes given relation from the Relation Service.
0N/A * <P>A RelationNotification notification is sent, its type being:
0N/A * <P>- RelationNotification.RELATION_BASIC_REMOVAL if the relation was
0N/A * only internal to the Relation Service
0N/A * <P>- RelationNotification.RELATION_MBEAN_REMOVAL if the relation is
0N/A * registered as an MBean.
0N/A * <P>For MBeans referenced in such relation, nothing will be done,
0N/A *
0N/A * @param relationId relation id of the relation to be removed
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation corresponding to
0N/A * given relation id
0N/A */
0N/A public void removeRelation(String relationId)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "removeRelation", relationId);
0N/A
0N/A // Checks there is a relation with this id
0N/A // Can throw RelationNotFoundException
0N/A Object result = getRelation(relationId);
0N/A
0N/A // Removes it from listener filter
0N/A if (result instanceof ObjectName) {
0N/A List<ObjectName> obsRefList = new ArrayList<ObjectName>();
0N/A obsRefList.add((ObjectName)result);
0N/A // Can throw a RelationServiceNotRegisteredException
0N/A updateUnregistrationListener(null, obsRefList);
0N/A }
0N/A
0N/A // Sends a notification
0N/A // Note: has to be done FIRST as needs the relation to be still in the
0N/A // Relation Service
0N/A // No RelationNotFoundException as checked above
0N/A
0N/A // Revisit [cebro] Handle CIM "Delete" and "IfDeleted" qualifiers:
0N/A // deleting the relation can mean to delete referenced MBeans. In
0N/A // that case, MBeans to be unregistered are put in a list sent along
0N/A // with the notification below
0N/A
0N/A // Can throw a RelationNotFoundException (but detected above)
0N/A sendRelationRemovalNotification(relationId, null);
0N/A
0N/A // Removes the relation from various internal maps
0N/A
0N/A // - MBean reference map
0N/A // Retrieves the MBeans referenced in this relation
0N/A // Note: here we cannot use removeMBeanReference() because it would
0N/A // require to know the MBeans referenced in the relation. For
0N/A // that it would be necessary to call 'getReferencedMBeans()'
0N/A // on the relation itself. Ok if it is an internal one, but if
0N/A // it is an MBean, it is possible it is already unregistered, so
0N/A // not available through the MBean Server.
0N/A List<ObjectName> refMBeanList = new ArrayList<ObjectName>();
0N/A // List of MBeans no longer referenced in any relation, to be
0N/A // removed fom the map
0N/A List<ObjectName> nonRefObjNameList = new ArrayList<ObjectName>();
0N/A
0N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A
0N/A for (ObjectName currRefObjName :
0N/A myRefedMBeanObjName2RelIdsMap.keySet()) {
0N/A
0N/A // Retrieves relations where the MBean is referenced
0N/A Map<String,List<String>> relIdMap =
0N/A myRefedMBeanObjName2RelIdsMap.get(currRefObjName);
0N/A
0N/A if (relIdMap.containsKey(relationId)) {
0N/A relIdMap.remove(relationId);
0N/A refMBeanList.add(currRefObjName);
0N/A }
0N/A
0N/A if (relIdMap.isEmpty()) {
0N/A // MBean no longer referenced
0N/A // Note: do not remove it here because pointed by the
0N/A // iterator!
0N/A nonRefObjNameList.add(currRefObjName);
0N/A }
0N/A }
0N/A
0N/A // Cleans MBean reference map by removing MBeans no longer
0N/A // referenced
0N/A for (ObjectName currRefObjName : nonRefObjNameList) {
0N/A myRefedMBeanObjName2RelIdsMap.remove(currRefObjName);
0N/A }
0N/A }
0N/A
0N/A // - Relation id to object map
0N/A synchronized(myRelId2ObjMap) {
0N/A myRelId2ObjMap.remove(relationId);
0N/A }
0N/A
0N/A if (result instanceof ObjectName) {
0N/A // - ObjectName to relation id map
0N/A synchronized(myRelMBeanObjName2RelIdMap) {
0N/A myRelMBeanObjName2RelIdMap.remove((ObjectName)result);
0N/A }
0N/A }
0N/A
0N/A // Relation id to relation type name map
0N/A // First retrieves the relation type name
277N/A String relTypeName;
0N/A synchronized(myRelId2RelTypeMap) {
0N/A relTypeName = myRelId2RelTypeMap.get(relationId);
0N/A myRelId2RelTypeMap.remove(relationId);
0N/A }
0N/A // - Relation type name to relation id map
0N/A synchronized(myRelType2RelIdsMap) {
0N/A List<String> relIdList = myRelType2RelIdsMap.get(relTypeName);
0N/A if (relIdList != null) {
0N/A // Can be null if called from removeRelationType()
0N/A relIdList.remove(relationId);
0N/A if (relIdList.isEmpty()) {
0N/A // No other relation of that type
0N/A myRelType2RelIdsMap.remove(relTypeName);
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "removeRelation");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Purges the relations.
0N/A *
0N/A * <P>Depending on the purgeFlag value, this method is either called
0N/A * automatically when a notification is received for the unregistration of
0N/A * an MBean referenced in a relation (if the flag is set to true), or not
0N/A * (if the flag is set to false).
0N/A * <P>In that case it is up to the user to call it to maintain the
0N/A * consistency of the relations. To be kept in mind that if an MBean is
0N/A * unregistered and the purge not done immediately, if the ObjectName is
0N/A * reused and assigned to another MBean referenced in a relation, calling
0N/A * manually this purgeRelations() method will cause trouble, as will
0N/A * consider the ObjectName as corresponding to the unregistered MBean, not
0N/A * seeing the new one.
0N/A *
0N/A * <P>The behavior depends on the cardinality of the role where the
0N/A * unregistered MBean is referenced:
0N/A * <P>- if removing one MBean reference in the role makes its number of
0N/A * references less than the minimum degree, the relation has to be removed.
0N/A * <P>- if the remaining number of references after removing the MBean
0N/A * reference is still in the cardinality range, keep the relation and
0N/A * update it calling its handleMBeanUnregistration() callback.
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server.
0N/A */
0N/A public void purgeRelations()
0N/A throws RelationServiceNotRegisteredException {
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "purgeRelations");
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Revisit [cebro] Handle the CIM "Delete" and "IfDeleted" qualifier:
0N/A // if the unregistered MBean has the "IfDeleted" qualifier,
0N/A // possible that the relation itself or other referenced MBeans
0N/A // have to be removed (then a notification would have to be sent
0N/A // to inform that they should be unregistered.
0N/A
0N/A
0N/A // Clones the list of notifications to be able to still receive new
0N/A // notifications while proceeding those ones
0N/A List<MBeanServerNotification> localUnregNtfList;
469N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A localUnregNtfList =
0N/A new ArrayList<MBeanServerNotification>(myUnregNtfList);
0N/A // Resets list
0N/A myUnregNtfList = new ArrayList<MBeanServerNotification>();
0N/A }
0N/A
0N/A
0N/A // Updates the listener filter to avoid receiving notifications for
0N/A // those MBeans again
0N/A // Makes also a local "myRefedMBeanObjName2RelIdsMap" map, mapping
0N/A // ObjectName -> relId -> roles, to remove the MBean from the global
0N/A // map
0N/A // List of references to be removed from the listener filter
0N/A List<ObjectName> obsRefList = new ArrayList<ObjectName>();
0N/A // Map including ObjectNames for unregistered MBeans, with
0N/A // referencing relation ids and roles
0N/A Map<ObjectName,Map<String,List<String>>> localMBean2RelIdMap =
0N/A new HashMap<ObjectName,Map<String,List<String>>>();
0N/A
0N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A for (MBeanServerNotification currNtf : localUnregNtfList) {
0N/A
0N/A ObjectName unregMBeanName = currNtf.getMBeanName();
0N/A
0N/A // Adds the unregsitered MBean in the list of references to
0N/A // remove from the listener filter
0N/A obsRefList.add(unregMBeanName);
0N/A
0N/A // Retrieves the associated map of relation ids and roles
0N/A Map<String,List<String>> relIdMap =
0N/A myRefedMBeanObjName2RelIdsMap.get(unregMBeanName);
0N/A localMBean2RelIdMap.put(unregMBeanName, relIdMap);
0N/A
0N/A myRefedMBeanObjName2RelIdsMap.remove(unregMBeanName);
0N/A }
0N/A }
0N/A
0N/A // Updates the listener
0N/A // Can throw RelationServiceNotRegisteredException
0N/A updateUnregistrationListener(null, obsRefList);
0N/A
0N/A for (MBeanServerNotification currNtf : localUnregNtfList) {
0N/A
0N/A ObjectName unregMBeanName = currNtf.getMBeanName();
0N/A
0N/A // Retrieves the relations where the MBean is referenced
0N/A Map<String,List<String>> localRelIdMap =
0N/A localMBean2RelIdMap.get(unregMBeanName);
0N/A
0N/A // List of relation ids where the unregistered MBean is
0N/A // referenced
0N/A for (Map.Entry<String,List<String>> currRel :
0N/A localRelIdMap.entrySet()) {
0N/A final String currRelId = currRel.getKey();
0N/A // List of roles of the relation where the MBean is
0N/A // referenced
0N/A List<String> localRoleNameList = currRel.getValue();
0N/A
0N/A // Checks if the relation has to be removed or not,
0N/A // regarding expected minimum role cardinality and current
0N/A // number of references after removal of the current one
0N/A // If the relation is kept, calls
0N/A // handleMBeanUnregistration() callback of the relation to
0N/A // update it
0N/A //
0N/A // Can throw RelationServiceNotRegisteredException
0N/A //
0N/A // Shall not throw RelationNotFoundException,
0N/A // RoleNotFoundException, MBeanException
0N/A try {
0N/A handleReferenceUnregistration(currRelId,
0N/A unregMBeanName,
0N/A localRoleNameList);
0N/A } catch (RelationNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (RoleNotFoundException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "purgeRelations");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the relations where a given MBean is referenced.
0N/A * <P>This corresponds to the CIM "References" and "ReferenceNames"
0N/A * operations.
0N/A *
0N/A * @param mbeanName ObjectName of MBean
0N/A * @param relationTypeName can be null; if specified, only the relations
0N/A * of that type will be considered in the search. Else all relation types
0N/A * are considered.
0N/A * @param roleName can be null; if specified, only the relations
0N/A * where the MBean is referenced in that role will be returned. Else all
0N/A * roles are considered.
0N/A *
0N/A * @return an HashMap, where the keys are the relation ids of the relations
0N/A * where the MBean is referenced, and the value is, for each key,
0N/A * an ArrayList of role names (as an MBean can be referenced in several
0N/A * roles in the same relation).
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A */
0N/A public Map<String,List<String>>
0N/A findReferencingRelations(ObjectName mbeanName,
0N/A String relationTypeName,
0N/A String roleName)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (mbeanName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "findReferencingRelations",
0N/A new Object[] {mbeanName, relationTypeName, roleName});
0N/A
0N/A Map<String,List<String>> result = new HashMap<String,List<String>>();
0N/A
0N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A
0N/A // Retrieves the relations referencing the MBean
0N/A Map<String,List<String>> relId2RoleNamesMap =
0N/A myRefedMBeanObjName2RelIdsMap.get(mbeanName);
0N/A
0N/A if (relId2RoleNamesMap != null) {
0N/A
0N/A // Relation Ids where the MBean is referenced
0N/A Set<String> allRelIdSet = relId2RoleNamesMap.keySet();
0N/A
0N/A // List of relation ids of interest regarding the selected
0N/A // relation type
277N/A List<String> relIdList;
0N/A if (relationTypeName == null) {
0N/A // Considers all relations
0N/A relIdList = new ArrayList<String>(allRelIdSet);
0N/A
0N/A } else {
0N/A
0N/A relIdList = new ArrayList<String>();
0N/A
0N/A // Considers only the relation ids for relations of given
0N/A // type
0N/A for (String currRelId : allRelIdSet) {
0N/A
0N/A // Retrieves its relation type
277N/A String currRelTypeName;
0N/A synchronized(myRelId2RelTypeMap) {
0N/A currRelTypeName =
0N/A myRelId2RelTypeMap.get(currRelId);
0N/A }
0N/A
0N/A if (currRelTypeName.equals(relationTypeName)) {
0N/A
0N/A relIdList.add(currRelId);
0N/A
0N/A }
0N/A }
0N/A }
0N/A
0N/A // Now looks at the roles where the MBean is expected to be
0N/A // referenced
0N/A
0N/A for (String currRelId : relIdList) {
0N/A // Retrieves list of role names where the MBean is
0N/A // referenced
0N/A List<String> currRoleNameList =
0N/A relId2RoleNamesMap.get(currRelId);
0N/A
0N/A if (roleName == null) {
0N/A // All roles to be considered
0N/A // Note: no need to test if list not null before
0N/A // cloning, MUST be not null else bug :(
0N/A result.put(currRelId,
0N/A new ArrayList<String>(currRoleNameList));
0N/A
0N/A } else if (currRoleNameList.contains(roleName)) {
0N/A // Filters only the relations where the MBean is
0N/A // referenced in // given role
0N/A List<String> dummyList = new ArrayList<String>();
0N/A dummyList.add(roleName);
0N/A result.put(currRelId, dummyList);
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "findReferencingRelations");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the MBeans associated to given one in a relation.
0N/A * <P>This corresponds to CIM Associators and AssociatorNames operations.
0N/A *
0N/A * @param mbeanName ObjectName of MBean
0N/A * @param relationTypeName can be null; if specified, only the relations
0N/A * of that type will be considered in the search. Else all
0N/A * relation types are considered.
0N/A * @param roleName can be null; if specified, only the relations
0N/A * where the MBean is referenced in that role will be considered. Else all
0N/A * roles are considered.
0N/A *
0N/A * @return an HashMap, where the keys are the ObjectNames of the MBeans
0N/A * associated to given MBean, and the value is, for each key, an ArrayList
0N/A * of the relation ids of the relations where the key MBean is
0N/A * associated to given one (as they can be associated in several different
0N/A * relations).
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A */
0N/A public Map<ObjectName,List<String>>
0N/A findAssociatedMBeans(ObjectName mbeanName,
0N/A String relationTypeName,
0N/A String roleName)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (mbeanName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "findAssociatedMBeans",
0N/A new Object[] {mbeanName, relationTypeName, roleName});
0N/A
0N/A // Retrieves the map <relation id> -> <role names> for those
0N/A // criterias
0N/A Map<String,List<String>> relId2RoleNamesMap =
0N/A findReferencingRelations(mbeanName,
0N/A relationTypeName,
0N/A roleName);
0N/A
0N/A Map<ObjectName,List<String>> result =
0N/A new HashMap<ObjectName,List<String>>();
0N/A
0N/A for (String currRelId : relId2RoleNamesMap.keySet()) {
0N/A
0N/A // Retrieves ObjectNames of MBeans referenced in this relation
0N/A //
0N/A // Shall not throw a RelationNotFoundException if incorrect status
0N/A // of maps :(
0N/A Map<ObjectName,List<String>> objName2RoleNamesMap;
0N/A try {
0N/A objName2RoleNamesMap = getReferencedMBeans(currRelId);
0N/A } catch (RelationNotFoundException exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A
0N/A // For each MBean associated to given one in a relation, adds the
0N/A // association <ObjectName> -> <relation id> into result map
0N/A for (ObjectName currObjName : objName2RoleNamesMap.keySet()) {
0N/A
0N/A if (!(currObjName.equals(mbeanName))) {
0N/A
0N/A // Sees if this MBean is already associated to the given
0N/A // one in another relation
0N/A List<String> currRelIdList = result.get(currObjName);
0N/A if (currRelIdList == null) {
0N/A
0N/A currRelIdList = new ArrayList<String>();
0N/A currRelIdList.add(currRelId);
0N/A result.put(currObjName, currRelIdList);
0N/A
0N/A } else {
0N/A currRelIdList.add(currRelId);
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "findAssociatedMBeans");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Returns the relation ids for relations of the given type.
0N/A *
0N/A * @param relationTypeName relation type name
0N/A *
0N/A * @return an ArrayList of relation ids.
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationTypeNotFoundException if there is no relation type
0N/A * with that name.
0N/A */
0N/A public List<String> findRelationsOfType(String relationTypeName)
0N/A throws IllegalArgumentException,
0N/A RelationTypeNotFoundException {
0N/A
0N/A if (relationTypeName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "findRelationsOfType");
0N/A
0N/A // Can throw RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A List<String> result;
0N/A synchronized(myRelType2RelIdsMap) {
0N/A List<String> result1 = myRelType2RelIdsMap.get(relationTypeName);
0N/A if (result1 == null)
0N/A result = new ArrayList<String>();
0N/A else
0N/A result = new ArrayList<String>(result1);
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "findRelationsOfType");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves role value for given role name in given relation.
0N/A *
0N/A * @param relationId relation id
0N/A * @param roleName name of role
0N/A *
0N/A * @return the ArrayList of ObjectName objects being the role value
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation with given id
0N/A * @exception RoleNotFoundException if:
0N/A * <P>- there is no role with given name
0N/A * <P>or
0N/A * <P>- the role is not readable.
0N/A *
0N/A * @see #setRole
0N/A */
0N/A public List<ObjectName> getRole(String relationId,
0N/A String roleName)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RelationNotFoundException,
0N/A RoleNotFoundException {
0N/A
0N/A if (relationId == null || roleName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRole", new Object[] {relationId, roleName});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
0N/A List<ObjectName> result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A // Can throw RoleNotFoundException
0N/A result = cast(
0N/A ((RelationSupport)relObj).getRoleInt(roleName,
0N/A true,
0N/A this,
0N/A false));
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A Object[] params = new Object[1];
0N/A params[0] = roleName;
0N/A String[] signature = new String[1];
0N/A signature[0] = "java.lang.String";
0N/A // Can throw MBeanException wrapping a RoleNotFoundException:
0N/A // throw wrapped exception
0N/A //
0N/A // Shall not throw InstanceNotFoundException or ReflectionException
0N/A try {
0N/A List<ObjectName> invokeResult = cast(
0N/A myMBeanServer.invoke(((ObjectName)relObj),
0N/A "getRole",
0N/A params,
0N/A signature));
686N/A if (invokeResult == null || invokeResult instanceof ArrayList<?>)
0N/A result = invokeResult;
0N/A else
0N/A result = new ArrayList<ObjectName>(invokeResult);
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (MBeanException exc3) {
0N/A Exception wrappedExc = exc3.getTargetException();
0N/A if (wrappedExc instanceof RoleNotFoundException) {
0N/A throw ((RoleNotFoundException)wrappedExc);
0N/A } else {
0N/A throw new RuntimeException(wrappedExc.getMessage());
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves values of roles with given names in given relation.
0N/A *
0N/A * @param relationId relation id
0N/A * @param roleNameArray array of names of roles to be retrieved
0N/A *
0N/A * @return a RoleResult object, including a RoleList (for roles
0N/A * successfully retrieved) and a RoleUnresolvedList (for roles not
0N/A * retrieved).
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation with given id
0N/A *
0N/A * @see #setRoles
0N/A */
0N/A public RoleResult getRoles(String relationId,
0N/A String[] roleNameArray)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null || roleNameArray == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRoles", relationId);
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
277N/A RoleResult result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A result = ((RelationSupport)relObj).getRolesInt(roleNameArray,
0N/A true,
0N/A this);
0N/A } else {
0N/A // Relation MBean
0N/A Object[] params = new Object[1];
0N/A params[0] = roleNameArray;
0N/A String[] signature = new String[1];
0N/A try {
0N/A signature[0] = (roleNameArray.getClass()).getName();
0N/A } catch (Exception exc) {
0N/A // OK : This is an array of java.lang.String
0N/A // so this should never happen...
0N/A }
0N/A // Shall not throw InstanceNotFoundException, ReflectionException
0N/A // or MBeanException
0N/A try {
0N/A result = (RoleResult)
0N/A (myMBeanServer.invoke(((ObjectName)relObj),
0N/A "getRoles",
0N/A params,
0N/A signature));
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (MBeanException exc3) {
0N/A throw new
0N/A RuntimeException((exc3.getTargetException()).getMessage());
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Returns all roles present in the relation.
0N/A *
0N/A * @param relationId relation id
0N/A *
0N/A * @return a RoleResult object, including a RoleList (for roles
0N/A * successfully retrieved) and a RoleUnresolvedList (for roles not
0N/A * readable).
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation for given id
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A */
0N/A public RoleResult getAllRoles(String relationId)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException,
0N/A RelationServiceNotRegisteredException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRoles", relationId);
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
277N/A RoleResult result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A result = ((RelationSupport)relObj).getAllRolesInt(true, this);
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A // Shall not throw any Exception
0N/A try {
0N/A result = (RoleResult)
0N/A (myMBeanServer.getAttribute(((ObjectName)relObj),
0N/A "AllRoles"));
0N/A } catch (Exception exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the number of MBeans currently referenced in the given role.
0N/A *
0N/A * @param relationId relation id
0N/A * @param roleName name of role
0N/A *
0N/A * @return the number of currently referenced MBeans in that role
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation with given id
0N/A * @exception RoleNotFoundException if there is no role with given name
0N/A */
0N/A public Integer getRoleCardinality(String relationId,
0N/A String roleName)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException,
0N/A RoleNotFoundException {
0N/A
0N/A if (relationId == null || roleName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRoleCardinality", new Object[] {relationId, roleName});
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
277N/A Integer result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A // Can throw RoleNotFoundException
0N/A result = ((RelationSupport)relObj).getRoleCardinality(roleName);
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A Object[] params = new Object[1];
0N/A params[0] = roleName;
0N/A String[] signature = new String[1];
0N/A signature[0] = "java.lang.String";
0N/A // Can throw MBeanException wrapping RoleNotFoundException:
0N/A // throw wrapped exception
0N/A //
0N/A // Shall not throw InstanceNotFoundException or ReflectionException
0N/A try {
0N/A result = (Integer)
0N/A (myMBeanServer.invoke(((ObjectName)relObj),
0N/A "getRoleCardinality",
0N/A params,
0N/A signature));
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (MBeanException exc3) {
0N/A Exception wrappedExc = exc3.getTargetException();
0N/A if (wrappedExc instanceof RoleNotFoundException) {
0N/A throw ((RoleNotFoundException)wrappedExc);
0N/A } else {
0N/A throw new RuntimeException(wrappedExc.getMessage());
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getRoleCardinality");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Sets the given role in given relation.
0N/A * <P>Will check the role according to its corresponding role definition
0N/A * provided in relation's relation type
0N/A * <P>The Relation Service will keep track of the change to keep the
0N/A * consistency of relations by handling referenced MBean unregistrations.
0N/A *
0N/A * @param relationId relation id
0N/A * @param role role to be set (name and new value)
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation with given id
0N/A * @exception RoleNotFoundException if the role does not exist or is not
0N/A * writable
0N/A * @exception InvalidRoleValueException if value provided for role is not
0N/A * valid:
0N/A * <P>- the number of referenced MBeans in given value is less than
0N/A * expected minimum degree
0N/A * <P>or
0N/A * <P>- the number of referenced MBeans in provided value exceeds expected
0N/A * maximum degree
0N/A * <P>or
0N/A * <P>- one referenced MBean in the value is not an Object of the MBean
0N/A * class expected for that role
0N/A * <P>or
0N/A * <P>- an MBean provided for that role does not exist
0N/A *
0N/A * @see #getRole
0N/A */
0N/A public void setRole(String relationId,
0N/A Role role)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RelationNotFoundException,
0N/A RoleNotFoundException,
0N/A InvalidRoleValueException {
0N/A
0N/A if (relationId == null || role == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "setRole", new Object[] {relationId, role});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A // Can throw RoleNotFoundException,
0N/A // InvalidRoleValueException and
0N/A // RelationServiceNotRegisteredException
0N/A //
0N/A // Shall not throw RelationTypeNotFoundException
0N/A // (as relation exists in the RS, its relation type is known)
0N/A try {
0N/A ((RelationSupport)relObj).setRoleInt(role,
0N/A true,
0N/A this,
0N/A false);
0N/A
0N/A } catch (RelationTypeNotFoundException exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A Object[] params = new Object[1];
0N/A params[0] = role;
0N/A String[] signature = new String[1];
0N/A signature[0] = "javax.management.relation.Role";
0N/A // Can throw MBeanException wrapping RoleNotFoundException,
0N/A // InvalidRoleValueException
0N/A //
0N/A // Shall not MBeanException wrapping an MBeanException wrapping
0N/A // RelationTypeNotFoundException, or ReflectionException, or
0N/A // InstanceNotFoundException
0N/A try {
0N/A myMBeanServer.setAttribute(((ObjectName)relObj),
0N/A new Attribute("Role", role));
0N/A
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A } catch (MBeanException exc2) {
0N/A Exception wrappedExc = exc2.getTargetException();
0N/A if (wrappedExc instanceof RoleNotFoundException) {
0N/A throw ((RoleNotFoundException)wrappedExc);
0N/A } else if (wrappedExc instanceof InvalidRoleValueException) {
0N/A throw ((InvalidRoleValueException)wrappedExc);
0N/A } else {
0N/A throw new RuntimeException(wrappedExc.getMessage());
0N/A
0N/A }
0N/A } catch (AttributeNotFoundException exc4) {
0N/A throw new RuntimeException(exc4.getMessage());
0N/A } catch (InvalidAttributeValueException exc5) {
0N/A throw new RuntimeException(exc5.getMessage());
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(), "setRole");
0N/A return;
0N/A }
0N/A
0N/A /**
0N/A * Sets the given roles in given relation.
0N/A * <P>Will check the role according to its corresponding role definition
0N/A * provided in relation's relation type
0N/A * <P>The Relation Service keeps track of the changes to keep the
0N/A * consistency of relations by handling referenced MBean unregistrations.
0N/A *
0N/A * @param relationId relation id
0N/A * @param roleList list of roles to be set
0N/A *
0N/A * @return a RoleResult object, including a RoleList (for roles
0N/A * successfully set) and a RoleUnresolvedList (for roles not
0N/A * set).
0N/A *
0N/A * @exception RelationServiceNotRegisteredException if the Relation
0N/A * Service is not registered in the MBean Server
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation with given id
0N/A *
0N/A * @see #getRoles
0N/A */
0N/A public RoleResult setRoles(String relationId,
0N/A RoleList roleList)
0N/A throws RelationServiceNotRegisteredException,
0N/A IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null || roleList == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "setRoles", new Object[] {relationId, roleList});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
277N/A RoleResult result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A // Can throw RelationServiceNotRegisteredException
0N/A //
0N/A // Shall not throw RelationTypeNotFoundException (as relation is
0N/A // known, its relation type exists)
0N/A try {
0N/A result = ((RelationSupport)relObj).setRolesInt(roleList,
0N/A true,
0N/A this);
0N/A } catch (RelationTypeNotFoundException exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A Object[] params = new Object[1];
0N/A params[0] = roleList;
0N/A String[] signature = new String[1];
0N/A signature[0] = "javax.management.relation.RoleList";
0N/A // Shall not throw InstanceNotFoundException or an MBeanException
0N/A // or ReflectionException
0N/A try {
0N/A result = (RoleResult)
0N/A (myMBeanServer.invoke(((ObjectName)relObj),
0N/A "setRoles",
0N/A params,
0N/A signature));
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A } catch (MBeanException exc2) {
0N/A throw new
0N/A RuntimeException((exc2.getTargetException()).getMessage());
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(), "setRoles");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Retrieves MBeans referenced in the various roles of the relation.
0N/A *
0N/A * @param relationId relation id
0N/A *
0N/A * @return a HashMap mapping:
0N/A * <P> ObjectName -> ArrayList of String (role
0N/A * names)
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation for given
0N/A * relation id
0N/A */
0N/A public Map<ObjectName,List<String>>
0N/A getReferencedMBeans(String relationId)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getReferencedMBeans", relationId);
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
0N/A Map<ObjectName,List<String>> result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A result = ((RelationSupport)relObj).getReferencedMBeans();
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A // No Exception
0N/A try {
0N/A result = cast(
0N/A myMBeanServer.getAttribute(((ObjectName)relObj),
0N/A "ReferencedMBeans"));
0N/A } catch (Exception exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getReferencedMBeans");
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Returns name of associated relation type for given relation.
0N/A *
0N/A * @param relationId relation id
0N/A *
0N/A * @return the name of the associated relation type.
0N/A *
0N/A * @exception IllegalArgumentException if null parameter
0N/A * @exception RelationNotFoundException if no relation for given
0N/A * relation id
0N/A */
0N/A public String getRelationTypeName(String relationId)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRelationTypeName", relationId);
0N/A
0N/A // Can throw a RelationNotFoundException
0N/A Object relObj = getRelation(relationId);
0N/A
277N/A String result;
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A result = ((RelationSupport)relObj).getRelationTypeName();
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A // No Exception
0N/A try {
0N/A result = (String)
0N/A (myMBeanServer.getAttribute(((ObjectName)relObj),
0N/A "RelationTypeName"));
0N/A } catch (Exception exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getRelationTypeName");
0N/A return result;
0N/A }
0N/A
0N/A //
0N/A // NotificationListener Interface
0N/A //
0N/A
0N/A /**
0N/A * Invoked when a JMX notification occurs.
0N/A * Currently handles notifications for unregistration of MBeans, either
0N/A * referenced in a relation role or being a relation itself.
0N/A *
0N/A * @param notif The notification.
0N/A * @param handback An opaque object which helps the listener to
0N/A * associate information regarding the MBean emitter (can be null).
0N/A */
0N/A public void handleNotification(Notification notif,
0N/A Object handback) {
0N/A
0N/A if (notif == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "handleNotification", notif);
0N/A
0N/A if (notif instanceof MBeanServerNotification) {
0N/A
0N/A MBeanServerNotification mbsNtf = (MBeanServerNotification) notif;
0N/A String ntfType = notif.getType();
0N/A
0N/A if (ntfType.equals(
0N/A MBeanServerNotification.UNREGISTRATION_NOTIFICATION )) {
0N/A ObjectName mbeanName =
0N/A ((MBeanServerNotification)notif).getMBeanName();
0N/A
0N/A // Note: use a flag to block access to
0N/A // myRefedMBeanObjName2RelIdsMap only for a quick access
0N/A boolean isRefedMBeanFlag = false;
0N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A
0N/A if (myRefedMBeanObjName2RelIdsMap.containsKey(mbeanName)) {
0N/A // Unregistration of a referenced MBean
0N/A synchronized(myUnregNtfList) {
0N/A myUnregNtfList.add(mbsNtf);
0N/A }
0N/A isRefedMBeanFlag = true;
0N/A }
0N/A if (isRefedMBeanFlag && myPurgeFlag) {
0N/A // Immediate purge
0N/A // Can throw RelationServiceNotRegisteredException
0N/A // but assume that will be fine :)
0N/A try {
0N/A purgeRelations();
0N/A } catch (Exception exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A }
0N/A }
0N/A
0N/A // Note: do both tests as a relation can be an MBean and be
0N/A // itself referenced in another relation :)
277N/A String relId;
0N/A synchronized(myRelMBeanObjName2RelIdMap){
0N/A relId = myRelMBeanObjName2RelIdMap.get(mbeanName);
0N/A }
0N/A if (relId != null) {
0N/A // Unregistration of a relation MBean
0N/A // Can throw RelationTypeNotFoundException,
0N/A // RelationServiceNotRegisteredException
0N/A //
0N/A // Shall not throw RelationTypeNotFoundException or
0N/A // InstanceNotFoundException
0N/A try {
0N/A removeRelation(relId);
0N/A } catch (Exception exc) {
0N/A throw new RuntimeException(exc.getMessage());
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "handleNotification");
0N/A return;
0N/A }
0N/A
0N/A //
0N/A // NotificationBroadcaster interface
0N/A //
0N/A
0N/A /**
0N/A * Returns a NotificationInfo object containing the name of the Java class
0N/A * of the notification and the notification types sent.
0N/A */
0N/A public MBeanNotificationInfo[] getNotificationInfo() {
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getNotificationInfo");
0N/A
0N/A String ntfClass = "javax.management.relation.RelationNotification";
0N/A
0N/A String[] ntfTypes = new String[] {
0N/A RelationNotification.RELATION_BASIC_CREATION,
0N/A RelationNotification.RELATION_MBEAN_CREATION,
0N/A RelationNotification.RELATION_BASIC_UPDATE,
0N/A RelationNotification.RELATION_MBEAN_UPDATE,
0N/A RelationNotification.RELATION_BASIC_REMOVAL,
0N/A RelationNotification.RELATION_MBEAN_REMOVAL,
0N/A };
0N/A
0N/A String ntfDesc = "Sent when a relation is created, updated or deleted.";
0N/A
0N/A MBeanNotificationInfo ntfInfo =
0N/A new MBeanNotificationInfo(ntfTypes, ntfClass, ntfDesc);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getNotificationInfo");
0N/A return new MBeanNotificationInfo[] {ntfInfo};
0N/A }
0N/A
0N/A //
0N/A // Misc
0N/A //
0N/A
0N/A // Adds given object as a relation type.
0N/A //
0N/A // -param relationTypeObj relation type object
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A // -exception InvalidRelationTypeException if there is already a relation
0N/A // type with that name
0N/A private void addRelationTypeInt(RelationType relationTypeObj)
0N/A throws IllegalArgumentException,
0N/A InvalidRelationTypeException {
0N/A
0N/A if (relationTypeObj == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "addRelationTypeInt");
0N/A
0N/A String relTypeName = relationTypeObj.getRelationTypeName();
0N/A
0N/A // Checks that there is not already a relation type with that name
0N/A // existing in the Relation Service
0N/A try {
0N/A // Can throw a RelationTypeNotFoundException (in fact should ;)
0N/A RelationType relType = getRelationType(relTypeName);
0N/A
0N/A if (relType != null) {
0N/A String excMsg = "There is already a relation type in the Relation Service with name ";
0N/A StringBuilder excMsgStrB = new StringBuilder(excMsg);
0N/A excMsgStrB.append(relTypeName);
0N/A throw new InvalidRelationTypeException(excMsgStrB.toString());
0N/A }
0N/A
0N/A } catch (RelationTypeNotFoundException exc) {
0N/A // OK : The RelationType could not be found.
0N/A }
0N/A
0N/A // Adds the relation type
0N/A synchronized(myRelType2ObjMap) {
0N/A myRelType2ObjMap.put(relTypeName, relationTypeObj);
0N/A }
0N/A
0N/A if (relationTypeObj instanceof RelationTypeSupport) {
0N/A ((RelationTypeSupport)relationTypeObj).setRelationServiceFlag(true);
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "addRelationTypeInt");
0N/A return;
0N/A }
0N/A
0N/A // Retrieves relation type with given name
0N/A //
0N/A // -param relationTypeName expected name of a relation type created in the
0N/A // Relation Service
0N/A //
0N/A // -return RelationType object corresponding to given name
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A // -exception RelationTypeNotFoundException if no relation type for that
0N/A // name created in Relation Service
0N/A //
0N/A RelationType getRelationType(String relationTypeName)
0N/A throws IllegalArgumentException,
0N/A RelationTypeNotFoundException {
0N/A
0N/A if (relationTypeName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRelationType", relationTypeName);
0N/A
0N/A // No null relation type accepted, so can use get()
277N/A RelationType relType;
0N/A synchronized(myRelType2ObjMap) {
0N/A relType = (myRelType2ObjMap.get(relationTypeName));
0N/A }
0N/A
0N/A if (relType == null) {
0N/A String excMsg = "No relation type created in the Relation Service with the name ";
0N/A StringBuilder excMsgStrB = new StringBuilder(excMsg);
0N/A excMsgStrB.append(relationTypeName);
0N/A throw new RelationTypeNotFoundException(excMsgStrB.toString());
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getRelationType");
0N/A return relType;
0N/A }
0N/A
0N/A // Retrieves relation corresponding to given relation id.
0N/A // Returns either:
0N/A // - a RelationSupport object if the relation is internal
0N/A // or
0N/A // - the ObjectName of the corresponding MBean
0N/A //
0N/A // -param relationId expected relation id
0N/A //
0N/A // -return RelationSupport object or ObjectName of relation with given id
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A // -exception RelationNotFoundException if no relation for that
0N/A // relation id created in Relation Service
0N/A //
0N/A Object getRelation(String relationId)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (relationId == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "getRelation", relationId);
0N/A
0N/A // No null relation accepted, so can use get()
277N/A Object rel;
0N/A synchronized(myRelId2ObjMap) {
0N/A rel = myRelId2ObjMap.get(relationId);
0N/A }
0N/A
0N/A if (rel == null) {
0N/A String excMsg = "No relation associated to relation id " + relationId;
0N/A throw new RelationNotFoundException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "getRelation");
0N/A return rel;
0N/A }
0N/A
0N/A // Adds a new MBean reference (reference to an ObjectName) in the
0N/A // referenced MBean map (myRefedMBeanObjName2RelIdsMap).
0N/A //
0N/A // -param objectName ObjectName of new referenced MBean
0N/A // -param relationId relation id of the relation where the MBean is
0N/A // referenced
0N/A // -param roleName name of the role where the MBean is referenced
0N/A //
0N/A // -return boolean:
0N/A // - true if the MBean was not referenced before, so really a new
0N/A // reference
0N/A // - false else
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A private boolean addNewMBeanReference(ObjectName objectName,
0N/A String relationId,
0N/A String roleName)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (objectName == null ||
0N/A relationId == null ||
0N/A roleName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "addNewMBeanReference",
0N/A new Object[] {objectName, relationId, roleName});
0N/A
0N/A boolean isNewFlag = false;
0N/A
0N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A
0N/A // Checks if the MBean was already referenced
0N/A // No null value allowed, use get() directly
0N/A Map<String,List<String>> mbeanRefMap =
0N/A myRefedMBeanObjName2RelIdsMap.get(objectName);
0N/A
0N/A if (mbeanRefMap == null) {
0N/A // MBean not referenced in any relation yet
0N/A
0N/A isNewFlag = true;
0N/A
0N/A // List of roles where the MBean is referenced in given
0N/A // relation
0N/A List<String> roleNames = new ArrayList<String>();
0N/A roleNames.add(roleName);
0N/A
0N/A // Map of relations where the MBean is referenced
0N/A mbeanRefMap = new HashMap<String,List<String>>();
0N/A mbeanRefMap.put(relationId, roleNames);
0N/A
0N/A myRefedMBeanObjName2RelIdsMap.put(objectName, mbeanRefMap);
0N/A
0N/A } else {
0N/A // MBean already referenced in at least another relation
0N/A // Checks if already referenced in another role in current
0N/A // relation
0N/A List<String> roleNames = mbeanRefMap.get(relationId);
0N/A
0N/A if (roleNames == null) {
0N/A // MBean not referenced in current relation
0N/A
0N/A // List of roles where the MBean is referenced in given
0N/A // relation
0N/A roleNames = new ArrayList<String>();
0N/A roleNames.add(roleName);
0N/A
0N/A // Adds new reference done in current relation
0N/A mbeanRefMap.put(relationId, roleNames);
0N/A
0N/A } else {
0N/A // MBean already referenced in current relation in another
0N/A // role
0N/A // Adds new reference done
0N/A roleNames.add(roleName);
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "addNewMBeanReference");
0N/A return isNewFlag;
0N/A }
0N/A
0N/A // Removes an obsolete MBean reference (reference to an ObjectName) in
0N/A // the referenced MBean map (myRefedMBeanObjName2RelIdsMap).
0N/A //
0N/A // -param objectName ObjectName of MBean no longer referenced
0N/A // -param relationId relation id of the relation where the MBean was
0N/A // referenced
0N/A // -param roleName name of the role where the MBean was referenced
0N/A // -param allRolesFlag flag, if true removes reference to MBean for all
0N/A // roles in the relation, not only for the one above
0N/A //
0N/A // -return boolean:
0N/A // - true if the MBean is no longer reference in any relation
0N/A // - false else
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A private boolean removeMBeanReference(ObjectName objectName,
0N/A String relationId,
0N/A String roleName,
0N/A boolean allRolesFlag)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (objectName == null ||
0N/A relationId == null ||
0N/A roleName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "removeMBeanReference",
0N/A new Object[] {objectName, relationId, roleName, allRolesFlag});
0N/A
0N/A boolean noLongerRefFlag = false;
0N/A
0N/A synchronized(myRefedMBeanObjName2RelIdsMap) {
0N/A
0N/A // Retrieves the set of relations (designed via their relation ids)
0N/A // where the MBean is referenced
0N/A // Note that it is possible that the MBean has already been removed
0N/A // from the internal map: this is the case when the MBean is
0N/A // unregistered, the role is updated, then we arrive here.
686N/A Map<String,List<String>> mbeanRefMap =
0N/A (myRefedMBeanObjName2RelIdsMap.get(objectName));
0N/A
0N/A if (mbeanRefMap == null) {
0N/A // The MBean is no longer referenced
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "removeMBeanReference");
0N/A return true;
0N/A }
0N/A
686N/A List<String> roleNames = null;
0N/A if (!allRolesFlag) {
0N/A // Now retrieves the roles of current relation where the MBean
0N/A // was referenced
686N/A roleNames = mbeanRefMap.get(relationId);
0N/A
0N/A // Removes obsolete reference to role
0N/A int obsRefIdx = roleNames.indexOf(roleName);
0N/A if (obsRefIdx != -1) {
0N/A roleNames.remove(obsRefIdx);
0N/A }
0N/A }
0N/A
0N/A // Checks if there is still at least one role in current relation
0N/A // where the MBean is referenced
0N/A if (roleNames.isEmpty() || allRolesFlag) {
0N/A // MBean no longer referenced in current relation: removes
0N/A // entry
0N/A mbeanRefMap.remove(relationId);
0N/A }
0N/A
0N/A // Checks if the MBean is still referenced in at least on relation
0N/A if (mbeanRefMap.isEmpty()) {
0N/A // MBean no longer referenced in any relation: removes entry
0N/A myRefedMBeanObjName2RelIdsMap.remove(objectName);
0N/A noLongerRefFlag = true;
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "removeMBeanReference");
0N/A return noLongerRefFlag;
0N/A }
0N/A
0N/A // Updates the listener registered to the MBean Server to be informed of
0N/A // referenced MBean unregistrations
0N/A //
0N/A // -param newRefList ArrayList of ObjectNames for new references done
0N/A // to MBeans (can be null)
0N/A // -param obsoleteRefList ArrayList of ObjectNames for obsolete references
0N/A // to MBeans (can be null)
0N/A //
0N/A // -exception RelationServiceNotRegisteredException if the Relation
0N/A // Service is not registered in the MBean Server.
686N/A private void updateUnregistrationListener(List<ObjectName> newRefList,
686N/A List<ObjectName> obsoleteRefList)
0N/A throws RelationServiceNotRegisteredException {
0N/A
0N/A if (newRefList != null && obsoleteRefList != null) {
0N/A if (newRefList.isEmpty() && obsoleteRefList.isEmpty()) {
0N/A // Nothing to do :)
0N/A return;
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "updateUnregistrationListener",
0N/A new Object[] {newRefList, obsoleteRefList});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A if (newRefList != null || obsoleteRefList != null) {
0N/A
0N/A boolean newListenerFlag = false;
0N/A if (myUnregNtfFilter == null) {
0N/A // Initialize it to be able to synchronise it :)
0N/A myUnregNtfFilter = new MBeanServerNotificationFilter();
0N/A newListenerFlag = true;
0N/A }
0N/A
0N/A synchronized(myUnregNtfFilter) {
0N/A
0N/A // Enables ObjectNames in newRefList
0N/A if (newRefList != null) {
686N/A for (ObjectName newObjName : newRefList)
0N/A myUnregNtfFilter.enableObjectName(newObjName);
0N/A }
0N/A
0N/A if (obsoleteRefList != null) {
0N/A // Disables ObjectNames in obsoleteRefList
686N/A for (ObjectName obsObjName : obsoleteRefList)
0N/A myUnregNtfFilter.disableObjectName(obsObjName);
0N/A }
0N/A
0N/A// Under test
0N/A if (newListenerFlag) {
0N/A try {
0N/A myMBeanServer.addNotificationListener(
0N/A MBeanServerDelegate.DELEGATE_NAME,
0N/A this,
0N/A myUnregNtfFilter,
0N/A null);
0N/A } catch (InstanceNotFoundException exc) {
0N/A throw new
0N/A RelationServiceNotRegisteredException(exc.getMessage());
0N/A }
0N/A }
0N/A// End test
0N/A
0N/A
0N/A// if (!newListenerFlag) {
0N/A // The Relation Service was already registered as a
0N/A // listener:
0N/A // removes it
0N/A // Shall not throw InstanceNotFoundException (as the
0N/A // MBean Server Delegate is expected to exist) or
0N/A // ListenerNotFoundException (as it has been checked above
0N/A // that the Relation Service is registered)
0N/A// try {
0N/A// myMBeanServer.removeNotificationListener(
0N/A// MBeanServerDelegate.DELEGATE_NAME,
0N/A// this);
0N/A// } catch (InstanceNotFoundException exc1) {
0N/A// throw new RuntimeException(exc1.getMessage());
0N/A// } catch (ListenerNotFoundException exc2) {
0N/A// throw new
0N/A// RelationServiceNotRegisteredException(exc2.getMessage());
0N/A// }
0N/A// }
0N/A
0N/A // Adds Relation Service with current filter
0N/A // Can throw InstanceNotFoundException if the Relation
0N/A // Service is not registered, to be transformed into
0N/A // RelationServiceNotRegisteredException
0N/A //
0N/A // Assume that there will not be any InstanceNotFoundException
0N/A // for the MBean Server Delegate :)
0N/A// try {
0N/A// myMBeanServer.addNotificationListener(
0N/A// MBeanServerDelegate.DELEGATE_NAME,
0N/A// this,
0N/A// myUnregNtfFilter,
0N/A// null);
0N/A// } catch (InstanceNotFoundException exc) {
0N/A// throw new
0N/A// RelationServiceNotRegisteredException(exc.getMessage());
0N/A// }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "updateUnregistrationListener");
0N/A return;
0N/A }
0N/A
0N/A // Adds a relation (being either a RelationSupport object or an MBean
0N/A // referenced using its ObjectName) in the Relation Service.
0N/A // Will send a notification RelationNotification with type:
0N/A // - RelationNotification.RELATION_BASIC_CREATION for internal relation
0N/A // creation
0N/A // - RelationNotification.RELATION_MBEAN_CREATION for an MBean being added
0N/A // as a relation.
0N/A //
0N/A // -param relationBaseFlag flag true if the relation is a RelationSupport
0N/A // object, false if it is an MBean
0N/A // -param relationObj RelationSupport object (if relation is internal)
0N/A // -param relationObjName ObjectName of the MBean to be added as a relation
0N/A // (only for the relation MBean)
0N/A // -param relationId relation identifier, to uniquely identify the relation
0N/A // inside the Relation Service
0N/A // -param relationTypeName name of the relation type (has to be created
0N/A // in the Relation Service)
0N/A // -param roleList role list to initialize roles of the relation
0N/A // (can be null)
0N/A //
0N/A // -exception IllegalArgumentException if null paramater
0N/A // -exception RelationServiceNotRegisteredException if the Relation
0N/A // Service is not registered in the MBean Server
0N/A // -exception RoleNotFoundException if a value is provided for a role
0N/A // that does not exist in the relation type
0N/A // -exception InvalidRelationIdException if relation id already used
0N/A // -exception RelationTypeNotFoundException if relation type not known in
0N/A // Relation Service
0N/A // -exception InvalidRoleValueException if:
0N/A // - the same role name is used for two different roles
0N/A // - the number of referenced MBeans in given value is less than
0N/A // expected minimum degree
0N/A // - the number of referenced MBeans in provided value exceeds expected
0N/A // maximum degree
0N/A // - one referenced MBean in the value is not an Object of the MBean
0N/A // class expected for that role
0N/A // - an MBean provided for that role does not exist
0N/A private void addRelationInt(boolean relationBaseFlag,
0N/A RelationSupport relationObj,
0N/A ObjectName relationObjName,
0N/A String relationId,
0N/A String relationTypeName,
0N/A RoleList roleList)
0N/A throws IllegalArgumentException,
0N/A RelationServiceNotRegisteredException,
0N/A RoleNotFoundException,
0N/A InvalidRelationIdException,
0N/A RelationTypeNotFoundException,
0N/A InvalidRoleValueException {
0N/A
0N/A if (relationId == null ||
0N/A relationTypeName == null ||
0N/A (relationBaseFlag &&
0N/A (relationObj == null ||
0N/A relationObjName != null)) ||
0N/A (!relationBaseFlag &&
0N/A (relationObjName == null ||
0N/A relationObj != null))) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "addRelationInt", new Object[] {relationBaseFlag, relationObj,
0N/A relationObjName, relationId, relationTypeName, roleList});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Checks if there is already a relation with given id
0N/A try {
0N/A // Can throw a RelationNotFoundException (in fact should :)
0N/A Object rel = getRelation(relationId);
0N/A
0N/A if (rel != null) {
0N/A // There is already a relation with that id
0N/A String excMsg = "There is already a relation with id ";
0N/A StringBuilder excMsgStrB = new StringBuilder(excMsg);
0N/A excMsgStrB.append(relationId);
0N/A throw new InvalidRelationIdException(excMsgStrB.toString());
0N/A }
0N/A } catch (RelationNotFoundException exc) {
0N/A // OK : The Relation could not be found.
0N/A }
0N/A
0N/A // Retrieves the relation type
0N/A // Can throw RelationTypeNotFoundException
0N/A RelationType relType = getRelationType(relationTypeName);
0N/A
0N/A // Checks that each provided role conforms to its role info provided in
0N/A // the relation type
0N/A // First retrieves a local list of the role infos of the relation type
0N/A // to see which roles have not been initialized
0N/A // Note: no need to test if list not null before cloning, not allowed
0N/A // to have an empty relation type.
686N/A List<RoleInfo> roleInfoList = new ArrayList<RoleInfo>(relType.getRoleInfos());
0N/A
0N/A if (roleList != null) {
0N/A
686N/A for (Role currRole : roleList.asList()) {
0N/A String currRoleName = currRole.getRoleName();
686N/A List<ObjectName> currRoleValue = currRole.getRoleValue();
0N/A // Retrieves corresponding role info
0N/A // Can throw a RoleInfoNotFoundException to be converted into a
0N/A // RoleNotFoundException
277N/A RoleInfo roleInfo;
0N/A try {
0N/A roleInfo = relType.getRoleInfo(currRoleName);
0N/A } catch (RoleInfoNotFoundException exc) {
0N/A throw new RoleNotFoundException(exc.getMessage());
0N/A }
0N/A
0N/A // Checks that role conforms to role info,
0N/A Integer status = checkRoleInt(2,
0N/A currRoleName,
0N/A currRoleValue,
0N/A roleInfo,
0N/A false);
0N/A int pbType = status.intValue();
0N/A if (pbType != 0) {
0N/A // A problem has occurred: throws appropriate exception
0N/A // here InvalidRoleValueException
0N/A throwRoleProblemException(pbType, currRoleName);
0N/A }
0N/A
0N/A // Removes role info for that list from list of role infos for
0N/A // roles to be defaulted
0N/A int roleInfoIdx = roleInfoList.indexOf(roleInfo);
0N/A // Note: no need to check if != -1, MUST be there :)
0N/A roleInfoList.remove(roleInfoIdx);
0N/A }
0N/A }
0N/A
0N/A // Initializes roles not initialized by roleList
0N/A // Can throw InvalidRoleValueException
0N/A initializeMissingRoles(relationBaseFlag,
0N/A relationObj,
0N/A relationObjName,
0N/A relationId,
0N/A relationTypeName,
0N/A roleInfoList);
0N/A
0N/A // Creation of relation successfull!!!!
0N/A
0N/A // Updates internal maps
0N/A // Relation id to object map
0N/A synchronized(myRelId2ObjMap) {
0N/A if (relationBaseFlag) {
0N/A // Note: do not clone relation object, created by us :)
0N/A myRelId2ObjMap.put(relationId, relationObj);
0N/A } else {
0N/A myRelId2ObjMap.put(relationId, relationObjName);
0N/A }
0N/A }
0N/A
0N/A // Relation id to relation type name map
0N/A synchronized(myRelId2RelTypeMap) {
0N/A myRelId2RelTypeMap.put(relationId,
0N/A relationTypeName);
0N/A }
0N/A
0N/A // Relation type to relation id map
0N/A synchronized(myRelType2RelIdsMap) {
0N/A List<String> relIdList =
0N/A myRelType2RelIdsMap.get(relationTypeName);
0N/A boolean firstRelFlag = false;
0N/A if (relIdList == null) {
0N/A firstRelFlag = true;
0N/A relIdList = new ArrayList<String>();
0N/A }
0N/A relIdList.add(relationId);
0N/A if (firstRelFlag) {
0N/A myRelType2RelIdsMap.put(relationTypeName, relIdList);
0N/A }
0N/A }
0N/A
0N/A // Referenced MBean to relation id map
0N/A // Only role list parameter used, as default initialization of roles
0N/A // done automatically in initializeMissingRoles() sets each
0N/A // uninitialized role to an empty value.
686N/A for (Role currRole : roleList.asList()) {
0N/A // Creates a dummy empty ArrayList of ObjectNames to be the old
0N/A // role value :)
0N/A List<ObjectName> dummyList = new ArrayList<ObjectName>();
0N/A // Will not throw a RelationNotFoundException (as the RelId2Obj map
0N/A // has been updated above) so catch it :)
0N/A try {
0N/A updateRoleMap(relationId, currRole, dummyList);
0N/A
0N/A } catch (RelationNotFoundException exc) {
0N/A // OK : The Relation could not be found.
0N/A }
0N/A }
0N/A
0N/A // Sends a notification for relation creation
0N/A // Will not throw RelationNotFoundException so catch it :)
0N/A try {
0N/A sendRelationCreationNotification(relationId);
0N/A
0N/A } catch (RelationNotFoundException exc) {
0N/A // OK : The Relation could not be found.
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "addRelationInt");
0N/A return;
0N/A }
0N/A
0N/A // Checks that given role conforms to given role info.
0N/A //
0N/A // -param chkType type of check:
0N/A // - 1: read, just check read access
0N/A // - 2: write, check value and write access if writeChkFlag
0N/A // -param roleName role name
0N/A // -param roleValue role value
0N/A // -param roleInfo corresponding role info
0N/A // -param writeChkFlag boolean to specify a current write access and
0N/A // to check it
0N/A //
0N/A // -return Integer with value:
0N/A // - 0: ok
0N/A // - RoleStatus.NO_ROLE_WITH_NAME
0N/A // - RoleStatus.ROLE_NOT_READABLE
0N/A // - RoleStatus.ROLE_NOT_WRITABLE
0N/A // - RoleStatus.LESS_THAN_MIN_ROLE_DEGREE
0N/A // - RoleStatus.MORE_THAN_MAX_ROLE_DEGREE
0N/A // - RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS
0N/A // - RoleStatus.REF_MBEAN_NOT_REGISTERED
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A private Integer checkRoleInt(int chkType,
0N/A String roleName,
686N/A List<ObjectName> roleValue,
0N/A RoleInfo roleInfo,
0N/A boolean writeChkFlag)
0N/A throws IllegalArgumentException {
0N/A
0N/A if (roleName == null ||
0N/A roleInfo == null ||
0N/A (chkType == 2 && roleValue == null)) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "checkRoleInt", new Object[] {chkType, roleName,
0N/A roleValue, roleInfo, writeChkFlag});
0N/A
0N/A // Compares names
0N/A String expName = roleInfo.getName();
0N/A if (!(roleName.equals(expName))) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
277N/A return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
0N/A }
0N/A
0N/A // Checks read access if required
0N/A if (chkType == 1) {
0N/A boolean isReadable = roleInfo.isReadable();
0N/A if (!isReadable) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
278N/A return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE);
0N/A } else {
0N/A // End of check :)
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(0);
0N/A }
0N/A }
0N/A
0N/A // Checks write access if required
0N/A if (writeChkFlag) {
0N/A boolean isWritable = roleInfo.isWritable();
0N/A if (!isWritable) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(RoleStatus.ROLE_NOT_WRITABLE);
0N/A }
0N/A }
0N/A
0N/A int refNbr = roleValue.size();
0N/A
0N/A // Checks minimum cardinality
0N/A boolean chkMinFlag = roleInfo.checkMinDegree(refNbr);
0N/A if (!chkMinFlag) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(RoleStatus.LESS_THAN_MIN_ROLE_DEGREE);
0N/A }
0N/A
0N/A // Checks maximum cardinality
0N/A boolean chkMaxFlag = roleInfo.checkMaxDegree(refNbr);
0N/A if (!chkMaxFlag) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(RoleStatus.MORE_THAN_MAX_ROLE_DEGREE);
0N/A }
0N/A
0N/A // Verifies that each referenced MBean is registered in the MBean
0N/A // Server and that it is an instance of the class specified in the
0N/A // role info, or of a subclass of it
0N/A // Note that here again this is under the assumption that
0N/A // referenced MBeans, relation MBeans and the Relation Service are
0N/A // registered in the same MBean Server.
0N/A String expClassName = roleInfo.getRefMBeanClassName();
0N/A
686N/A for (ObjectName currObjName : roleValue) {
0N/A
0N/A // Checks it is registered
0N/A if (currObjName == null) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(RoleStatus.REF_MBEAN_NOT_REGISTERED);
0N/A }
0N/A
0N/A // Checks if it is of the correct class
0N/A // Can throw an InstanceNotFoundException, if MBean not registered
0N/A try {
0N/A boolean classSts = myMBeanServer.isInstanceOf(currObjName,
0N/A expClassName);
0N/A if (!classSts) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS);
0N/A }
0N/A
0N/A } catch (InstanceNotFoundException exc) {
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(RoleStatus.REF_MBEAN_NOT_REGISTERED);
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "checkRoleInt");
0N/A return new Integer(0);
0N/A }
0N/A
0N/A
0N/A // Initializes roles associated to given role infos to default value (empty
0N/A // ArrayList of ObjectNames) in given relation.
0N/A // It will succeed for every role except if the role info has a minimum
0N/A // cardinality greater than 0. In that case, an InvalidRoleValueException
0N/A // will be raised.
0N/A //
0N/A // -param relationBaseFlag flag true if the relation is a RelationSupport
0N/A // object, false if it is an MBean
0N/A // -param relationObj RelationSupport object (if relation is internal)
0N/A // -param relationObjName ObjectName of the MBean to be added as a relation
0N/A // (only for the relation MBean)
0N/A // -param relationId relation id
0N/A // -param relationTypeName name of the relation type (has to be created
0N/A // in the Relation Service)
0N/A // -param roleInfoList list of role infos for roles to be defaulted
0N/A //
0N/A // -exception IllegalArgumentException if null paramater
0N/A // -exception RelationServiceNotRegisteredException if the Relation
0N/A // Service is not registered in the MBean Server
0N/A // -exception InvalidRoleValueException if role must have a non-empty
0N/A // value
0N/A
0N/A // Revisit [cebro] Handle CIM qualifiers as REQUIRED to detect roles which
0N/A // should have been initialized by the user
0N/A private void initializeMissingRoles(boolean relationBaseFlag,
0N/A RelationSupport relationObj,
0N/A ObjectName relationObjName,
0N/A String relationId,
0N/A String relationTypeName,
686N/A List<RoleInfo> roleInfoList)
0N/A throws IllegalArgumentException,
0N/A RelationServiceNotRegisteredException,
0N/A InvalidRoleValueException {
0N/A
0N/A if ((relationBaseFlag &&
0N/A (relationObj == null ||
0N/A relationObjName != null)) ||
0N/A (!relationBaseFlag &&
0N/A (relationObjName == null ||
0N/A relationObj != null)) ||
0N/A relationId == null ||
0N/A relationTypeName == null ||
0N/A roleInfoList == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "initializeMissingRoles", new Object[] {relationBaseFlag,
0N/A relationObj, relationObjName, relationId, relationTypeName,
0N/A roleInfoList});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // For each role info (corresponding to a role not initialized by the
0N/A // role list provided by the user), try to set in the relation a role
0N/A // with an empty list of ObjectNames.
0N/A // A check is performed to verify that the role can be set to an
0N/A // empty value, according to its minimum cardinality
686N/A for (RoleInfo currRoleInfo : roleInfoList) {
686N/A
0N/A String roleName = currRoleInfo.getName();
0N/A
0N/A // Creates an empty value
0N/A List<ObjectName> emptyValue = new ArrayList<ObjectName>();
0N/A // Creates a role
0N/A Role role = new Role(roleName, emptyValue);
0N/A
0N/A if (relationBaseFlag) {
0N/A
0N/A // Internal relation
0N/A // Can throw InvalidRoleValueException
0N/A //
0N/A // Will not throw RoleNotFoundException (role to be
0N/A // initialized), or RelationNotFoundException, or
0N/A // RelationTypeNotFoundException
0N/A try {
0N/A relationObj.setRoleInt(role, true, this, false);
0N/A
0N/A } catch (RoleNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (RelationNotFoundException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A } catch (RelationTypeNotFoundException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A }
0N/A
0N/A } else {
0N/A
0N/A // Relation is an MBean
0N/A // Use standard setRole()
0N/A Object[] params = new Object[1];
0N/A params[0] = role;
0N/A String[] signature = new String[1];
0N/A signature[0] = "javax.management.relation.Role";
0N/A // Can throw MBeanException wrapping
0N/A // InvalidRoleValueException. Returns the target exception to
0N/A // be homogeneous.
0N/A //
0N/A // Will not throw MBeanException (wrapping
0N/A // RoleNotFoundException or MBeanException) or
0N/A // InstanceNotFoundException, or ReflectionException
0N/A //
0N/A // Again here the assumption is that the Relation Service and
0N/A // the relation MBeans are registered in the same MBean Server.
0N/A try {
0N/A myMBeanServer.setAttribute(relationObjName,
0N/A new Attribute("Role", role));
0N/A
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A } catch (MBeanException exc2) {
0N/A Exception wrappedExc = exc2.getTargetException();
0N/A if (wrappedExc instanceof InvalidRoleValueException) {
0N/A throw ((InvalidRoleValueException)wrappedExc);
0N/A } else {
0N/A throw new RuntimeException(wrappedExc.getMessage());
0N/A }
0N/A } catch (AttributeNotFoundException exc4) {
0N/A throw new RuntimeException(exc4.getMessage());
0N/A } catch (InvalidAttributeValueException exc5) {
0N/A throw new RuntimeException(exc5.getMessage());
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "initializeMissingRoles");
0N/A return;
0N/A }
0N/A
0N/A // Throws an exception corresponding to a given problem type
0N/A //
0N/A // -param pbType possible problem, defined in RoleUnresolved
0N/A // -param roleName role name
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A // -exception RoleNotFoundException for problems:
0N/A // - NO_ROLE_WITH_NAME
0N/A // - ROLE_NOT_READABLE
0N/A // - ROLE_NOT_WRITABLE
0N/A // -exception InvalidRoleValueException for problems:
0N/A // - LESS_THAN_MIN_ROLE_DEGREE
0N/A // - MORE_THAN_MAX_ROLE_DEGREE
0N/A // - REF_MBEAN_OF_INCORRECT_CLASS
0N/A // - REF_MBEAN_NOT_REGISTERED
0N/A static void throwRoleProblemException(int pbType,
0N/A String roleName)
0N/A throws IllegalArgumentException,
0N/A RoleNotFoundException,
0N/A InvalidRoleValueException {
0N/A
0N/A if (roleName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A // Exception type: 1 = RoleNotFoundException
0N/A // 2 = InvalidRoleValueException
0N/A int excType = 0;
0N/A
0N/A String excMsgPart = null;
0N/A
0N/A switch (pbType) {
0N/A case RoleStatus.NO_ROLE_WITH_NAME:
0N/A excMsgPart = " does not exist in relation.";
0N/A excType = 1;
0N/A break;
0N/A case RoleStatus.ROLE_NOT_READABLE:
0N/A excMsgPart = " is not readable.";
0N/A excType = 1;
0N/A break;
0N/A case RoleStatus.ROLE_NOT_WRITABLE:
0N/A excMsgPart = " is not writable.";
0N/A excType = 1;
0N/A break;
0N/A case RoleStatus.LESS_THAN_MIN_ROLE_DEGREE:
0N/A excMsgPart = " has a number of MBean references less than the expected minimum degree.";
0N/A excType = 2;
0N/A break;
0N/A case RoleStatus.MORE_THAN_MAX_ROLE_DEGREE:
0N/A excMsgPart = " has a number of MBean references greater than the expected maximum degree.";
0N/A excType = 2;
0N/A break;
0N/A case RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS:
0N/A excMsgPart = " has an MBean reference to an MBean not of the expected class of references for that role.";
0N/A excType = 2;
0N/A break;
0N/A case RoleStatus.REF_MBEAN_NOT_REGISTERED:
0N/A excMsgPart = " has a reference to null or to an MBean not registered.";
0N/A excType = 2;
0N/A break;
0N/A }
0N/A // No default as we must have been in one of those cases
0N/A
0N/A StringBuilder excMsgStrB = new StringBuilder(roleName);
0N/A excMsgStrB.append(excMsgPart);
0N/A String excMsg = excMsgStrB.toString();
0N/A if (excType == 1) {
0N/A throw new RoleNotFoundException(excMsg);
0N/A
0N/A } else if (excType == 2) {
0N/A throw new InvalidRoleValueException(excMsg);
0N/A }
0N/A }
0N/A
0N/A // Sends a notification of given type, with given parameters
0N/A //
0N/A // -param intNtfType integer to represent notification type:
0N/A // - 1 : create
0N/A // - 2 : update
0N/A // - 3 : delete
0N/A // -param message human-readable message
0N/A // -param relationId relation id of the created/updated/deleted relation
0N/A // -param unregMBeanList list of ObjectNames of referenced MBeans
0N/A // expected to be unregistered due to relation removal (only for removal,
0N/A // due to CIM qualifiers, can be null)
0N/A // -param roleName role name
0N/A // -param roleNewValue role new value (ArrayList of ObjectNames)
0N/A // -param oldValue old role value (ArrayList of ObjectNames)
0N/A //
0N/A // -exception IllegalArgument if null parameter
0N/A // -exception RelationNotFoundException if no relation for given id
0N/A private void sendNotificationInt(int intNtfType,
0N/A String message,
0N/A String relationId,
0N/A List<ObjectName> unregMBeanList,
0N/A String roleName,
0N/A List<ObjectName> roleNewValue,
0N/A List<ObjectName> oldValue)
0N/A throws IllegalArgumentException,
0N/A RelationNotFoundException {
0N/A
0N/A if (message == null ||
0N/A relationId == null ||
0N/A (intNtfType != 3 && unregMBeanList != null) ||
0N/A (intNtfType == 2 &&
0N/A (roleName == null ||
0N/A roleNewValue == null ||
0N/A oldValue == null))) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "sendNotificationInt", new Object[] {intNtfType, message,
0N/A relationId, unregMBeanList, roleName, roleNewValue, oldValue});
0N/A
0N/A // Relation type name
0N/A // Note: do not use getRelationTypeName() as if it is a relation MBean
0N/A // it is already unregistered.
277N/A String relTypeName;
0N/A synchronized(myRelId2RelTypeMap) {
0N/A relTypeName = (myRelId2RelTypeMap.get(relationId));
0N/A }
0N/A
0N/A // ObjectName (for a relation MBean)
0N/A // Can also throw a RelationNotFoundException, but detected above
0N/A ObjectName relObjName = isRelationMBean(relationId);
0N/A
0N/A String ntfType = null;
0N/A if (relObjName != null) {
0N/A switch (intNtfType) {
0N/A case 1:
0N/A ntfType = RelationNotification.RELATION_MBEAN_CREATION;
0N/A break;
0N/A case 2:
0N/A ntfType = RelationNotification.RELATION_MBEAN_UPDATE;
0N/A break;
0N/A case 3:
0N/A ntfType = RelationNotification.RELATION_MBEAN_REMOVAL;
0N/A break;
0N/A }
0N/A } else {
0N/A switch (intNtfType) {
0N/A case 1:
0N/A ntfType = RelationNotification.RELATION_BASIC_CREATION;
0N/A break;
0N/A case 2:
0N/A ntfType = RelationNotification.RELATION_BASIC_UPDATE;
0N/A break;
0N/A case 3:
0N/A ntfType = RelationNotification.RELATION_BASIC_REMOVAL;
0N/A break;
0N/A }
0N/A }
0N/A
0N/A // Sequence number
277N/A Long seqNo = atomicSeqNo.incrementAndGet();
0N/A
0N/A // Timestamp
0N/A Date currDate = new Date();
0N/A long timeStamp = currDate.getTime();
0N/A
0N/A RelationNotification ntf = null;
0N/A
0N/A if (ntfType.equals(RelationNotification.RELATION_BASIC_CREATION) ||
0N/A ntfType.equals(RelationNotification.RELATION_MBEAN_CREATION) ||
0N/A ntfType.equals(RelationNotification.RELATION_BASIC_REMOVAL) ||
0N/A ntfType.equals(RelationNotification.RELATION_MBEAN_REMOVAL))
0N/A
0N/A // Creation or removal
0N/A ntf = new RelationNotification(ntfType,
0N/A this,
277N/A seqNo.longValue(),
0N/A timeStamp,
0N/A message,
0N/A relationId,
0N/A relTypeName,
0N/A relObjName,
0N/A unregMBeanList);
0N/A
0N/A else if (ntfType.equals(RelationNotification.RELATION_BASIC_UPDATE)
0N/A ||
0N/A ntfType.equals(RelationNotification.RELATION_MBEAN_UPDATE))
0N/A {
0N/A // Update
0N/A ntf = new RelationNotification(ntfType,
0N/A this,
277N/A seqNo.longValue(),
0N/A timeStamp,
0N/A message,
0N/A relationId,
0N/A relTypeName,
0N/A relObjName,
0N/A roleName,
0N/A roleNewValue,
0N/A oldValue);
0N/A }
0N/A
0N/A sendNotification(ntf);
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "sendNotificationInt");
0N/A return;
0N/A }
0N/A
0N/A // Checks, for the unregistration of an MBean referenced in the roles given
0N/A // in parameter, if the relation has to be removed or not, regarding
0N/A // expected minimum role cardinality and current number of
0N/A // references in each role after removal of the current one.
0N/A // If the relation is kept, calls handleMBeanUnregistration() callback of
0N/A // the relation to update it.
0N/A //
0N/A // -param relationId relation id
0N/A // -param objectName ObjectName of the unregistered MBean
0N/A // -param roleNameList list of names of roles where the unregistered
0N/A // MBean is referenced.
0N/A //
0N/A // -exception IllegalArgumentException if null parameter
0N/A // -exception RelationServiceNotRegisteredException if the Relation
0N/A // Service is not registered in the MBean Server
0N/A // -exception RelationNotFoundException if unknown relation id
0N/A // -exception RoleNotFoundException if one role given as parameter does
0N/A // not exist in the relation
0N/A private void handleReferenceUnregistration(String relationId,
0N/A ObjectName objectName,
686N/A List<String> roleNameList)
0N/A throws IllegalArgumentException,
0N/A RelationServiceNotRegisteredException,
0N/A RelationNotFoundException,
0N/A RoleNotFoundException {
0N/A
0N/A if (relationId == null ||
0N/A roleNameList == null ||
0N/A objectName == null) {
0N/A String excMsg = "Invalid parameter.";
0N/A throw new IllegalArgumentException(excMsg);
0N/A }
0N/A
0N/A RELATION_LOGGER.entering(RelationService.class.getName(),
0N/A "handleReferenceUnregistration",
0N/A new Object[] {relationId, objectName, roleNameList});
0N/A
0N/A // Can throw RelationServiceNotRegisteredException
0N/A isActive();
0N/A
0N/A // Retrieves the relation type name of the relation
0N/A // Can throw RelationNotFoundException
0N/A String currRelTypeName = getRelationTypeName(relationId);
0N/A
0N/A // Retrieves the relation
0N/A // Can throw RelationNotFoundException, but already detected above
0N/A Object relObj = getRelation(relationId);
0N/A
0N/A // Flag to specify if the relation has to be deleted
0N/A boolean deleteRelFlag = false;
0N/A
686N/A for (String currRoleName : roleNameList) {
0N/A
0N/A if (deleteRelFlag) {
0N/A break;
0N/A }
0N/A
0N/A // Retrieves number of MBeans currently referenced in role
0N/A // BEWARE! Do not use getRole() as role may be not readable
0N/A //
0N/A // Can throw RelationNotFoundException (but already checked),
0N/A // RoleNotFoundException
0N/A int currRoleRefNbr =
0N/A (getRoleCardinality(relationId, currRoleName)).intValue();
0N/A
0N/A // Retrieves new number of element in role
0N/A int currRoleNewRefNbr = currRoleRefNbr - 1;
0N/A
0N/A // Retrieves role info for that role
0N/A //
0N/A // Shall not throw RelationTypeNotFoundException or
0N/A // RoleInfoNotFoundException
277N/A RoleInfo currRoleInfo;
0N/A try {
0N/A currRoleInfo = getRoleInfo(currRelTypeName,
0N/A currRoleName);
0N/A } catch (RelationTypeNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (RoleInfoNotFoundException exc2) {
0N/A throw new RuntimeException(exc2.getMessage());
0N/A }
0N/A
0N/A // Checks with expected minimum number of elements
0N/A boolean chkMinFlag = currRoleInfo.checkMinDegree(currRoleNewRefNbr);
0N/A
0N/A if (!chkMinFlag) {
0N/A // The relation has to be deleted
0N/A deleteRelFlag = true;
0N/A }
0N/A }
0N/A
0N/A if (deleteRelFlag) {
0N/A // Removes the relation
0N/A removeRelation(relationId);
0N/A
0N/A } else {
0N/A
0N/A // Updates each role in the relation using
0N/A // handleMBeanUnregistration() callback
0N/A //
0N/A // BEWARE: this roleNameList list MUST BE A COPY of a role name
0N/A // list for a referenced MBean in a relation, NOT a
0N/A // reference to an original one part of the
0N/A // myRefedMBeanObjName2RelIdsMap!!!! Because each role
0N/A // which name is in that list will be updated (potentially
0N/A // using setRole(). So the Relation Service will update the
0N/A // myRefedMBeanObjName2RelIdsMap to refelect the new role
0N/A // value!
686N/A for (String currRoleName : roleNameList) {
0N/A
0N/A if (relObj instanceof RelationSupport) {
0N/A // Internal relation
0N/A // Can throw RoleNotFoundException (but already checked)
0N/A //
0N/A // Shall not throw
0N/A // RelationTypeNotFoundException,
0N/A // InvalidRoleValueException (value was correct, removing
0N/A // one reference shall not invalidate it, else detected
0N/A // above)
0N/A try {
0N/A ((RelationSupport)relObj).handleMBeanUnregistrationInt(
0N/A objectName,
0N/A currRoleName,
0N/A true,
0N/A this);
0N/A } catch (RelationTypeNotFoundException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A } catch (InvalidRoleValueException exc4) {
0N/A throw new RuntimeException(exc4.getMessage());
0N/A }
0N/A
0N/A } else {
0N/A // Relation MBean
0N/A Object[] params = new Object[2];
0N/A params[0] = objectName;
0N/A params[1] = currRoleName;
0N/A String[] signature = new String[2];
0N/A signature[0] = "javax.management.ObjectName";
0N/A signature[1] = "java.lang.String";
0N/A // Shall not throw InstanceNotFoundException, or
0N/A // MBeanException (wrapping RoleNotFoundException or
0N/A // MBeanException or InvalidRoleValueException) or
0N/A // ReflectionException
0N/A try {
0N/A myMBeanServer.invoke(((ObjectName)relObj),
0N/A "handleMBeanUnregistration",
0N/A params,
0N/A signature);
0N/A } catch (InstanceNotFoundException exc1) {
0N/A throw new RuntimeException(exc1.getMessage());
0N/A } catch (ReflectionException exc3) {
0N/A throw new RuntimeException(exc3.getMessage());
0N/A } catch (MBeanException exc2) {
0N/A Exception wrappedExc = exc2.getTargetException();
0N/A throw new RuntimeException(wrappedExc.getMessage());
0N/A }
0N/A
0N/A }
0N/A }
0N/A }
0N/A
0N/A RELATION_LOGGER.exiting(RelationService.class.getName(),
0N/A "handleReferenceUnregistration");
0N/A return;
0N/A }
0N/A}