jdk/src/java.management/share/classes/javax/management/relation/RelationService.java
changeset 43235 da1786d695b6
parent 25859 3317bb8137f4
equal deleted inserted replaced
43234:cb2a6851b837 43235:da1786d695b6
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    34 import java.util.Iterator;
    34 import java.util.Iterator;
    35 import java.util.List;
    35 import java.util.List;
    36 import java.util.Map;
    36 import java.util.Map;
    37 import java.util.Set;
    37 import java.util.Set;
    38 import java.util.concurrent.atomic.AtomicLong;
    38 import java.util.concurrent.atomic.AtomicLong;
    39 import java.util.logging.Level;
    39 import java.lang.System.Logger.Level;
    40 
    40 
    41 import javax.management.Attribute;
    41 import javax.management.Attribute;
    42 import javax.management.AttributeNotFoundException;
    42 import javax.management.AttributeNotFoundException;
    43 import javax.management.InstanceNotFoundException;
    43 import javax.management.InstanceNotFoundException;
    44 import javax.management.InvalidAttributeValueException;
    44 import javax.management.InvalidAttributeValueException;
   155      * when the purgeRelations method will be explicitly called.
   155      * when the purgeRelations method will be explicitly called.
   156      * <P>true is immediate purge.
   156      * <P>true is immediate purge.
   157      */
   157      */
   158     public RelationService(boolean immediatePurgeFlag) {
   158     public RelationService(boolean immediatePurgeFlag) {
   159 
   159 
   160         RELATION_LOGGER.entering(RelationService.class.getName(),
   160         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   161                 "RelationService");
       
   162 
   161 
   163         setPurgeFlag(immediatePurgeFlag);
   162         setPurgeFlag(immediatePurgeFlag);
   164 
   163 
   165         RELATION_LOGGER.exiting(RelationService.class.getName(),
   164         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   166                 "RelationService");
       
   167         return;
   165         return;
   168     }
   166     }
   169 
   167 
   170     /**
   168     /**
   171      * Checks if the Relation Service is active.
   169      * Checks if the Relation Service is active.
   284         if (relationTypeName == null || roleInfoArray == null) {
   282         if (relationTypeName == null || roleInfoArray == null) {
   285             String excMsg = "Invalid parameter.";
   283             String excMsg = "Invalid parameter.";
   286             throw new IllegalArgumentException(excMsg);
   284             throw new IllegalArgumentException(excMsg);
   287         }
   285         }
   288 
   286 
   289         RELATION_LOGGER.entering(RelationService.class.getName(),
   287         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
   290                 "createRelationType", relationTypeName);
       
   291 
   288 
   292         // Can throw an InvalidRelationTypeException
   289         // Can throw an InvalidRelationTypeException
   293         RelationType relType =
   290         RelationType relType =
   294             new RelationTypeSupport(relationTypeName, roleInfoArray);
   291             new RelationTypeSupport(relationTypeName, roleInfoArray);
   295 
   292 
   296         addRelationTypeInt(relType);
   293         addRelationTypeInt(relType);
   297 
   294 
   298         RELATION_LOGGER.exiting(RelationService.class.getName(),
   295         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   299                 "createRelationType");
       
   300         return;
   296         return;
   301     }
   297     }
   302 
   298 
   303     /**
   299     /**
   304      * Adds given object as a relation type. The object is expected to
   300      * Adds given object as a relation type. The object is expected to
   323         if (relationTypeObj == null) {
   319         if (relationTypeObj == null) {
   324             String excMsg = "Invalid parameter.";
   320             String excMsg = "Invalid parameter.";
   325             throw new IllegalArgumentException(excMsg);
   321             throw new IllegalArgumentException(excMsg);
   326         }
   322         }
   327 
   323 
   328         RELATION_LOGGER.entering(RelationService.class.getName(),
   324         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   329                 "addRelationType");
       
   330 
   325 
   331         // Checks the role infos
   326         // Checks the role infos
   332         List<RoleInfo> roleInfoList = relationTypeObj.getRoleInfos();
   327         List<RoleInfo> roleInfoList = relationTypeObj.getRoleInfos();
   333         if (roleInfoList == null) {
   328         if (roleInfoList == null) {
   334             String excMsg = "No role info provided.";
   329             String excMsg = "No role info provided.";
   344         // Can throw InvalidRelationTypeException
   339         // Can throw InvalidRelationTypeException
   345         RelationTypeSupport.checkRoleInfos(roleInfoArray);
   340         RelationTypeSupport.checkRoleInfos(roleInfoArray);
   346 
   341 
   347         addRelationTypeInt(relationTypeObj);
   342         addRelationTypeInt(relationTypeObj);
   348 
   343 
   349         RELATION_LOGGER.exiting(RelationService.class.getName(),
   344         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   350                 "addRelationType");
       
   351         return;
   345         return;
   352      }
   346      }
   353 
   347 
   354     /**
   348     /**
   355      * Retrieves names of all known relation types.
   349      * Retrieves names of all known relation types.
   383         if (relationTypeName == null) {
   377         if (relationTypeName == null) {
   384             String excMsg = "Invalid parameter.";
   378             String excMsg = "Invalid parameter.";
   385             throw new IllegalArgumentException(excMsg);
   379             throw new IllegalArgumentException(excMsg);
   386         }
   380         }
   387 
   381 
   388         RELATION_LOGGER.entering(RelationService.class.getName(),
   382         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
   389                 "getRoleInfos", relationTypeName);
       
   390 
   383 
   391         // Can throw a RelationTypeNotFoundException
   384         // Can throw a RelationTypeNotFoundException
   392         RelationType relType = getRelationType(relationTypeName);
   385         RelationType relType = getRelationType(relationTypeName);
   393 
   386 
   394         RELATION_LOGGER.exiting(RelationService.class.getName(),
   387         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   395                 "getRoleInfos");
       
   396         return relType.getRoleInfos();
   388         return relType.getRoleInfos();
   397     }
   389     }
   398 
   390 
   399     /**
   391     /**
   400      * Retrieves role info for given role name of a given relation type.
   392      * Retrieves role info for given role name of a given relation type.
   419         if (relationTypeName == null || roleInfoName == null) {
   411         if (relationTypeName == null || roleInfoName == null) {
   420             String excMsg = "Invalid parameter.";
   412             String excMsg = "Invalid parameter.";
   421             throw new IllegalArgumentException(excMsg);
   413             throw new IllegalArgumentException(excMsg);
   422         }
   414         }
   423 
   415 
   424         RELATION_LOGGER.entering(RelationService.class.getName(),
   416         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
   425                 "getRoleInfo", new Object[] {relationTypeName, roleInfoName});
   417                             relationTypeName, roleInfoName);
   426 
   418 
   427         // Can throw a RelationTypeNotFoundException
   419         // Can throw a RelationTypeNotFoundException
   428         RelationType relType = getRelationType(relationTypeName);
   420         RelationType relType = getRelationType(relationTypeName);
   429 
   421 
   430         // Can throw a RoleInfoNotFoundException
   422         // Can throw a RoleInfoNotFoundException
   431         RoleInfo roleInfo = relType.getRoleInfo(roleInfoName);
   423         RoleInfo roleInfo = relType.getRoleInfo(roleInfoName);
   432 
   424 
   433         RELATION_LOGGER.exiting(RelationService.class.getName(),
   425         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   434                 "getRoleInfo");
       
   435         return roleInfo;
   426         return roleInfo;
   436     }
   427     }
   437 
   428 
   438     /**
   429     /**
   439      * Removes given relation type from Relation Service.
   430      * Removes given relation type from Relation Service.
   459         if (relationTypeName == null) {
   450         if (relationTypeName == null) {
   460             String excMsg = "Invalid parameter.";
   451             String excMsg = "Invalid parameter.";
   461             throw new IllegalArgumentException(excMsg);
   452             throw new IllegalArgumentException(excMsg);
   462         }
   453         }
   463 
   454 
   464         RELATION_LOGGER.entering(RelationService.class.getName(),
   455         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
   465                 "removeRelationType", relationTypeName);
       
   466 
   456 
   467         // Checks if the relation type to be removed exists
   457         // Checks if the relation type to be removed exists
   468         // Can throw a RelationTypeNotFoundException
   458         // Can throw a RelationTypeNotFoundException
   469         RelationType relType = getRelationType(relationTypeName);
   459         RelationType relType = getRelationType(relationTypeName);
   470 
   460 
   502                     throw new RuntimeException(exc1.getMessage());
   492                     throw new RuntimeException(exc1.getMessage());
   503                 }
   493                 }
   504             }
   494             }
   505         }
   495         }
   506 
   496 
   507         RELATION_LOGGER.exiting(RelationService.class.getName(),
   497         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   508                 "removeRelationType");
       
   509         return;
   498         return;
   510     }
   499     }
   511 
   500 
   512     //
   501     //
   513     // Relation handling
   502     // Relation handling
   564             relationTypeName == null) {
   553             relationTypeName == null) {
   565             String excMsg = "Invalid parameter.";
   554             String excMsg = "Invalid parameter.";
   566             throw new IllegalArgumentException(excMsg);
   555             throw new IllegalArgumentException(excMsg);
   567         }
   556         }
   568 
   557 
   569         RELATION_LOGGER.entering(RelationService.class.getName(),
   558         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
   570                 "createRelation",
   559                             relationId, relationTypeName, roleList);
   571                 new Object[] {relationId, relationTypeName, roleList});
       
   572 
   560 
   573         // Creates RelationSupport object
   561         // Creates RelationSupport object
   574         // Can throw InvalidRoleValueException
   562         // Can throw InvalidRoleValueException
   575         RelationSupport relObj = new RelationSupport(relationId,
   563         RelationSupport relObj = new RelationSupport(relationId,
   576                                                myObjName,
   564                                                myObjName,
   586                        relObj,
   574                        relObj,
   587                        null,
   575                        null,
   588                        relationId,
   576                        relationId,
   589                        relationTypeName,
   577                        relationTypeName,
   590                        roleList);
   578                        roleList);
   591         RELATION_LOGGER.exiting(RelationService.class.getName(),
   579         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   592                 "createRelation");
       
   593         return;
   580         return;
   594     }
   581     }
   595 
   582 
   596     /**
   583     /**
   597      * Adds an MBean created by the user (and registered by him in the MBean
   584      * Adds an MBean created by the user (and registered by him in the MBean
   652         if (relationObjectName == null) {
   639         if (relationObjectName == null) {
   653             String excMsg = "Invalid parameter.";
   640             String excMsg = "Invalid parameter.";
   654             throw new IllegalArgumentException(excMsg);
   641             throw new IllegalArgumentException(excMsg);
   655         }
   642         }
   656 
   643 
   657         RELATION_LOGGER.entering(RelationService.class.getName(),
   644         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationObjectName);
   658                 "addRelation", relationObjectName);
       
   659 
   645 
   660         // Can throw RelationServiceNotRegisteredException
   646         // Can throw RelationServiceNotRegisteredException
   661         isActive();
   647         isActive();
   662 
   648 
   663         // Checks that the relation MBean implements the Relation interface.
   649         // Checks that the relation MBean implements the Relation interface.
   789         // unregistration of this MBean
   775         // unregistration of this MBean
   790         List<ObjectName> newRefList = new ArrayList<ObjectName>();
   776         List<ObjectName> newRefList = new ArrayList<ObjectName>();
   791         newRefList.add(relationObjectName);
   777         newRefList.add(relationObjectName);
   792         updateUnregistrationListener(newRefList, null);
   778         updateUnregistrationListener(newRefList, null);
   793 
   779 
   794         RELATION_LOGGER.exiting(RelationService.class.getName(),
   780         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   795                 "addRelation");
       
   796         return;
   781         return;
   797     }
   782     }
   798 
   783 
   799     /**
   784     /**
   800      * If the relation is represented by an MBean (created by the user and
   785      * If the relation is represented by an MBean (created by the user and
   817         if (relationId == null) {
   802         if (relationId == null) {
   818             String excMsg = "Invalid parameter.";
   803             String excMsg = "Invalid parameter.";
   819             throw new IllegalArgumentException(excMsg);
   804             throw new IllegalArgumentException(excMsg);
   820         }
   805         }
   821 
   806 
   822         RELATION_LOGGER.entering(RelationService.class.getName(),
   807         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
   823                 "isRelationMBean", relationId);
       
   824 
   808 
   825         // Can throw RelationNotFoundException
   809         // Can throw RelationNotFoundException
   826         Object result = getRelation(relationId);
   810         Object result = getRelation(relationId);
   827         if (result instanceof ObjectName) {
   811         if (result instanceof ObjectName) {
   828             return ((ObjectName)result);
   812             return ((ObjectName)result);
   848         if (objectName == null) {
   832         if (objectName == null) {
   849             String excMsg = "Invalid parameter.";
   833             String excMsg = "Invalid parameter.";
   850             throw new IllegalArgumentException(excMsg);
   834             throw new IllegalArgumentException(excMsg);
   851         }
   835         }
   852 
   836 
   853         RELATION_LOGGER.entering(RelationService.class.getName(),
   837         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", objectName);
   854                 "isRelation", objectName);
       
   855 
   838 
   856         String result = null;
   839         String result = null;
   857         synchronized(myRelMBeanObjName2RelIdMap) {
   840         synchronized(myRelMBeanObjName2RelIdMap) {
   858             String relId = myRelMBeanObjName2RelIdMap.get(objectName);
   841             String relId = myRelMBeanObjName2RelIdMap.get(objectName);
   859             if (relId != null) {
   842             if (relId != null) {
   879         if (relationId == null) {
   862         if (relationId == null) {
   880             String excMsg = "Invalid parameter.";
   863             String excMsg = "Invalid parameter.";
   881             throw new IllegalArgumentException(excMsg);
   864             throw new IllegalArgumentException(excMsg);
   882         }
   865         }
   883 
   866 
   884         RELATION_LOGGER.entering(RelationService.class.getName(),
   867         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
   885                 "hasRelation", relationId);
       
   886 
   868 
   887         try {
   869         try {
   888             // Can throw RelationNotFoundException
   870             // Can throw RelationNotFoundException
   889             Object result = getRelation(relationId);
   871             Object result = getRelation(relationId);
   890             return true;
   872             return true;
   931         if (roleName == null || relationTypeName == null) {
   913         if (roleName == null || relationTypeName == null) {
   932             String excMsg = "Invalid parameter.";
   914             String excMsg = "Invalid parameter.";
   933             throw new IllegalArgumentException(excMsg);
   915             throw new IllegalArgumentException(excMsg);
   934         }
   916         }
   935 
   917 
   936         RELATION_LOGGER.entering(RelationService.class.getName(),
   918         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
   937                 "checkRoleReading", new Object[] {roleName, relationTypeName});
   919                             roleName, relationTypeName);
   938 
   920 
   939         Integer result;
   921         Integer result;
   940 
   922 
   941         // Can throw a RelationTypeNotFoundException
   923         // Can throw a RelationTypeNotFoundException
   942         RelationType relType = getRelationType(relationTypeName);
   924         RelationType relType = getRelationType(relationTypeName);
   954 
   936 
   955         } catch (RoleInfoNotFoundException exc) {
   937         } catch (RoleInfoNotFoundException exc) {
   956             result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
   938             result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
   957         }
   939         }
   958 
   940 
   959         RELATION_LOGGER.exiting(RelationService.class.getName(),
   941         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   960                 "checkRoleReading");
       
   961         return result;
   942         return result;
   962     }
   943     }
   963 
   944 
   964     /**
   945     /**
   965      * Checks if given Role can be set in a relation of given type.
   946      * Checks if given Role can be set in a relation of given type.
   993             initFlag == null) {
   974             initFlag == null) {
   994             String excMsg = "Invalid parameter.";
   975             String excMsg = "Invalid parameter.";
   995             throw new IllegalArgumentException(excMsg);
   976             throw new IllegalArgumentException(excMsg);
   996         }
   977         }
   997 
   978 
   998         RELATION_LOGGER.entering(RelationService.class.getName(),
   979         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
   999                 "checkRoleWriting",
   980                             role, relationTypeName, initFlag);
  1000                 new Object[] {role, relationTypeName, initFlag});
       
  1001 
   981 
  1002         // Can throw a RelationTypeNotFoundException
   982         // Can throw a RelationTypeNotFoundException
  1003         RelationType relType = getRelationType(relationTypeName);
   983         RelationType relType = getRelationType(relationTypeName);
  1004 
   984 
  1005         String roleName = role.getRoleName();
   985         String roleName = role.getRoleName();
  1011 
   991 
  1012         RoleInfo roleInfo;
   992         RoleInfo roleInfo;
  1013         try {
   993         try {
  1014             roleInfo = relType.getRoleInfo(roleName);
   994             roleInfo = relType.getRoleInfo(roleName);
  1015         } catch (RoleInfoNotFoundException exc) {
   995         } catch (RoleInfoNotFoundException exc) {
  1016             RELATION_LOGGER.exiting(RelationService.class.getName(),
   996             RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1017                     "checkRoleWriting");
       
  1018             return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
   997             return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
  1019         }
   998         }
  1020 
   999 
  1021         Integer result = checkRoleInt(2,
  1000         Integer result = checkRoleInt(2,
  1022                                       roleName,
  1001                                       roleName,
  1023                                       roleValue,
  1002                                       roleValue,
  1024                                       roleInfo,
  1003                                       roleInfo,
  1025                                       writeChkFlag);
  1004                                       writeChkFlag);
  1026 
  1005 
  1027         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1006         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1028                 "checkRoleWriting");
       
  1029         return result;
  1007         return result;
  1030     }
  1008     }
  1031 
  1009 
  1032     /**
  1010     /**
  1033      * Sends a notification (RelationNotification) for a relation creation.
  1011      * Sends a notification (RelationNotification) for a relation creation.
  1053         if (relationId == null) {
  1031         if (relationId == null) {
  1054             String excMsg = "Invalid parameter.";
  1032             String excMsg = "Invalid parameter.";
  1055             throw new IllegalArgumentException(excMsg);
  1033             throw new IllegalArgumentException(excMsg);
  1056         }
  1034         }
  1057 
  1035 
  1058         RELATION_LOGGER.entering(RelationService.class.getName(),
  1036         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
  1059                 "sendRelationCreationNotification", relationId);
       
  1060 
  1037 
  1061         // Message
  1038         // Message
  1062         StringBuilder ntfMsg = new StringBuilder("Creation of relation ");
  1039         StringBuilder ntfMsg = new StringBuilder("Creation of relation ");
  1063         ntfMsg.append(relationId);
  1040         ntfMsg.append(relationId);
  1064 
  1041 
  1069                             null,
  1046                             null,
  1070                             null,
  1047                             null,
  1071                             null,
  1048                             null,
  1072                             null);
  1049                             null);
  1073 
  1050 
  1074         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1051         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1075                 "sendRelationCreationNotification");
       
  1076         return;
  1052         return;
  1077     }
  1053     }
  1078 
  1054 
  1079     /**
  1055     /**
  1080      * Sends a notification (RelationNotification) for a role update in the
  1056      * Sends a notification (RelationNotification) for a role update in the
  1112         }
  1088         }
  1113 
  1089 
  1114         if (!(oldValue instanceof ArrayList<?>))
  1090         if (!(oldValue instanceof ArrayList<?>))
  1115             oldValue = new ArrayList<ObjectName>(oldValue);
  1091             oldValue = new ArrayList<ObjectName>(oldValue);
  1116 
  1092 
  1117         RELATION_LOGGER.entering(RelationService.class.getName(),
  1093         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  1118                 "sendRoleUpdateNotification",
  1094                             relationId, newRole, oldValue);
  1119                 new Object[] {relationId, newRole, oldValue});
       
  1120 
  1095 
  1121         String roleName = newRole.getRoleName();
  1096         String roleName = newRole.getRoleName();
  1122         List<ObjectName> newRoleVal = newRole.getRoleValue();
  1097         List<ObjectName> newRoleVal = newRole.getRoleValue();
  1123 
  1098 
  1124         // Message
  1099         // Message
  1138                             null,
  1113                             null,
  1139                             roleName,
  1114                             roleName,
  1140                             newRoleVal,
  1115                             newRoleVal,
  1141                             oldValue);
  1116                             oldValue);
  1142 
  1117 
  1143         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1118         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1144                 "sendRoleUpdateNotification");
       
  1145     }
  1119     }
  1146 
  1120 
  1147     /**
  1121     /**
  1148      * Sends a notification (RelationNotification) for a relation removal.
  1122      * Sends a notification (RelationNotification) for a relation removal.
  1149      * The notification type is:
  1123      * The notification type is:
  1170         if (relationId == null) {
  1144         if (relationId == null) {
  1171             String excMsg = "Invalid parameter";
  1145             String excMsg = "Invalid parameter";
  1172             throw new IllegalArgumentException(excMsg);
  1146             throw new IllegalArgumentException(excMsg);
  1173         }
  1147         }
  1174 
  1148 
  1175         RELATION_LOGGER.entering(RelationService.class.getName(),
  1149         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
  1176                 "sendRelationRemovalNotification",
  1150                             relationId, unregMBeanList);
  1177                 new Object[] {relationId, unregMBeanList});
       
  1178 
  1151 
  1179         // Can throw RelationNotFoundException
  1152         // Can throw RelationNotFoundException
  1180         sendNotificationInt(3,
  1153         sendNotificationInt(3,
  1181                             "Removal of relation " + relationId,
  1154                             "Removal of relation " + relationId,
  1182                             relationId,
  1155                             relationId,
  1184                             null,
  1157                             null,
  1185                             null,
  1158                             null,
  1186                             null);
  1159                             null);
  1187 
  1160 
  1188 
  1161 
  1189         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1162         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1190                 "sendRelationRemovalNotification");
       
  1191         return;
  1163         return;
  1192     }
  1164     }
  1193 
  1165 
  1194     /**
  1166     /**
  1195      * Handles update of the Relation Service role map for the update of given
  1167      * Handles update of the Relation Service role map for the update of given
  1224             oldValue == null) {
  1196             oldValue == null) {
  1225             String excMsg = "Invalid parameter.";
  1197             String excMsg = "Invalid parameter.";
  1226             throw new IllegalArgumentException(excMsg);
  1198             throw new IllegalArgumentException(excMsg);
  1227         }
  1199         }
  1228 
  1200 
  1229         RELATION_LOGGER.entering(RelationService.class.getName(),
  1201         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  1230                 "updateRoleMap", new Object[] {relationId, newRole, oldValue});
  1202                             relationId, newRole, oldValue);
  1231 
  1203 
  1232         // Can throw RelationServiceNotRegisteredException
  1204         // Can throw RelationServiceNotRegisteredException
  1233         isActive();
  1205         isActive();
  1234 
  1206 
  1235         // Verifies the relation has been added in the Relation Service
  1207         // Verifies the relation has been added in the Relation Service
  1301         // To avoid having one listener per ObjectName of referenced MBean,
  1273         // To avoid having one listener per ObjectName of referenced MBean,
  1302         // and to increase performances, there is only one listener recording
  1274         // and to increase performances, there is only one listener recording
  1303         // all ObjectNames of interest
  1275         // all ObjectNames of interest
  1304         updateUnregistrationListener(newRefList, obsRefList);
  1276         updateUnregistrationListener(newRefList, obsRefList);
  1305 
  1277 
  1306         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1278         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1307                 "updateRoleMap");
       
  1308         return;
  1279         return;
  1309     }
  1280     }
  1310 
  1281 
  1311     /**
  1282     /**
  1312      * Removes given relation from the Relation Service.
  1283      * Removes given relation from the Relation Service.
  1336         if (relationId == null) {
  1307         if (relationId == null) {
  1337             String excMsg = "Invalid parameter.";
  1308             String excMsg = "Invalid parameter.";
  1338             throw new IllegalArgumentException(excMsg);
  1309             throw new IllegalArgumentException(excMsg);
  1339         }
  1310         }
  1340 
  1311 
  1341         RELATION_LOGGER.entering(RelationService.class.getName(),
  1312         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
  1342                 "removeRelation", relationId);
       
  1343 
  1313 
  1344         // Checks there is a relation with this id
  1314         // Checks there is a relation with this id
  1345         // Can throw RelationNotFoundException
  1315         // Can throw RelationNotFoundException
  1346         Object result = getRelation(relationId);
  1316         Object result = getRelation(relationId);
  1347 
  1317 
  1440                     myRelType2RelIdsMap.remove(relTypeName);
  1410                     myRelType2RelIdsMap.remove(relTypeName);
  1441                 }
  1411                 }
  1442             }
  1412             }
  1443         }
  1413         }
  1444 
  1414 
  1445         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1415         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1446                 "removeRelation");
       
  1447         return;
  1416         return;
  1448     }
  1417     }
  1449 
  1418 
  1450     /**
  1419     /**
  1451      * Purges the relations.
  1420      * Purges the relations.
  1474      * Service is not registered in the MBean Server.
  1443      * Service is not registered in the MBean Server.
  1475      */
  1444      */
  1476     public void purgeRelations()
  1445     public void purgeRelations()
  1477         throws RelationServiceNotRegisteredException {
  1446         throws RelationServiceNotRegisteredException {
  1478 
  1447 
  1479         RELATION_LOGGER.entering(RelationService.class.getName(),
  1448         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
  1480                 "purgeRelations");
       
  1481 
  1449 
  1482         // Can throw RelationServiceNotRegisteredException
  1450         // Can throw RelationServiceNotRegisteredException
  1483         isActive();
  1451         isActive();
  1484 
  1452 
  1485         // Revisit [cebro] Handle the CIM "Delete" and "IfDeleted" qualifier:
  1453         // Revisit [cebro] Handle the CIM "Delete" and "IfDeleted" qualifier:
  1572                     throw new RuntimeException(exc2.getMessage());
  1540                     throw new RuntimeException(exc2.getMessage());
  1573                 }
  1541                 }
  1574             }
  1542             }
  1575         }
  1543         }
  1576 
  1544 
  1577         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1545         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1578                 "purgeRelations");
       
  1579         return;
  1546         return;
  1580     }
  1547     }
  1581 
  1548 
  1582     /**
  1549     /**
  1583      * Retrieves the relations where a given MBean is referenced.
  1550      * Retrieves the relations where a given MBean is referenced.
  1608         if (mbeanName == null) {
  1575         if (mbeanName == null) {
  1609             String excMsg = "Invalid parameter.";
  1576             String excMsg = "Invalid parameter.";
  1610             throw new IllegalArgumentException(excMsg);
  1577             throw new IllegalArgumentException(excMsg);
  1611         }
  1578         }
  1612 
  1579 
  1613         RELATION_LOGGER.entering(RelationService.class.getName(),
  1580         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  1614                 "findReferencingRelations",
  1581                             mbeanName, relationTypeName, roleName);
  1615                 new Object[] {mbeanName, relationTypeName, roleName});
       
  1616 
  1582 
  1617         Map<String,List<String>> result = new HashMap<String,List<String>>();
  1583         Map<String,List<String>> result = new HashMap<String,List<String>>();
  1618 
  1584 
  1619         synchronized(myRefedMBeanObjName2RelIdsMap) {
  1585         synchronized(myRefedMBeanObjName2RelIdsMap) {
  1620 
  1586 
  1682                     }
  1648                     }
  1683                 }
  1649                 }
  1684             }
  1650             }
  1685         }
  1651         }
  1686 
  1652 
  1687         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1653         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1688                 "findReferencingRelations");
       
  1689         return result;
  1654         return result;
  1690     }
  1655     }
  1691 
  1656 
  1692     /**
  1657     /**
  1693      * Retrieves the MBeans associated to given one in a relation.
  1658      * Retrieves the MBeans associated to given one in a relation.
  1718         if (mbeanName == null) {
  1683         if (mbeanName == null) {
  1719             String excMsg = "Invalid parameter.";
  1684             String excMsg = "Invalid parameter.";
  1720             throw new IllegalArgumentException(excMsg);
  1685             throw new IllegalArgumentException(excMsg);
  1721         }
  1686         }
  1722 
  1687 
  1723         RELATION_LOGGER.entering(RelationService.class.getName(),
  1688         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  1724                 "findAssociatedMBeans",
  1689                             mbeanName, relationTypeName, roleName);
  1725                 new Object[] {mbeanName, relationTypeName, roleName});
       
  1726 
  1690 
  1727         // Retrieves the map <relation id> -> <role names> for those
  1691         // Retrieves the map <relation id> -> <role names> for those
  1728         // criterias
  1692         // criterias
  1729         Map<String,List<String>> relId2RoleNamesMap =
  1693         Map<String,List<String>> relId2RoleNamesMap =
  1730             findReferencingRelations(mbeanName,
  1694             findReferencingRelations(mbeanName,
  1767                     }
  1731                     }
  1768                 }
  1732                 }
  1769             }
  1733             }
  1770         }
  1734         }
  1771 
  1735 
  1772         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1736         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1773                 "findAssociatedMBeans");
       
  1774         return result;
  1737         return result;
  1775     }
  1738     }
  1776 
  1739 
  1777     /**
  1740     /**
  1778      * Returns the relation ids for relations of the given type.
  1741      * Returns the relation ids for relations of the given type.
  1792         if (relationTypeName == null) {
  1755         if (relationTypeName == null) {
  1793             String excMsg = "Invalid parameter.";
  1756             String excMsg = "Invalid parameter.";
  1794             throw new IllegalArgumentException(excMsg);
  1757             throw new IllegalArgumentException(excMsg);
  1795         }
  1758         }
  1796 
  1759 
  1797         RELATION_LOGGER.entering(RelationService.class.getName(),
  1760         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
  1798                 "findRelationsOfType");
       
  1799 
  1761 
  1800         // Can throw RelationTypeNotFoundException
  1762         // Can throw RelationTypeNotFoundException
  1801         RelationType relType = getRelationType(relationTypeName);
  1763         RelationType relType = getRelationType(relationTypeName);
  1802 
  1764 
  1803         List<String> result;
  1765         List<String> result;
  1807                 result = new ArrayList<String>();
  1769                 result = new ArrayList<String>();
  1808             else
  1770             else
  1809                 result = new ArrayList<String>(result1);
  1771                 result = new ArrayList<String>(result1);
  1810         }
  1772         }
  1811 
  1773 
  1812         RELATION_LOGGER.exiting(RelationService.class.getName(),
  1774         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1813                 "findRelationsOfType");
       
  1814         return result;
  1775         return result;
  1815     }
  1776     }
  1816 
  1777 
  1817     /**
  1778     /**
  1818      * Retrieves role value for given role name in given relation.
  1779      * Retrieves role value for given role name in given relation.
  1843         if (relationId == null || roleName == null) {
  1804         if (relationId == null || roleName == null) {
  1844             String excMsg = "Invalid parameter.";
  1805             String excMsg = "Invalid parameter.";
  1845             throw new IllegalArgumentException(excMsg);
  1806             throw new IllegalArgumentException(excMsg);
  1846         }
  1807         }
  1847 
  1808 
  1848         RELATION_LOGGER.entering(RelationService.class.getName(),
  1809         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
  1849                 "getRole", new Object[] {relationId, roleName});
  1810                             relationId, roleName);
  1850 
  1811 
  1851         // Can throw RelationServiceNotRegisteredException
  1812         // Can throw RelationServiceNotRegisteredException
  1852         isActive();
  1813         isActive();
  1853 
  1814 
  1854         // Can throw a RelationNotFoundException
  1815         // Can throw a RelationNotFoundException
  1897                     throw new RuntimeException(wrappedExc.getMessage());
  1858                     throw new RuntimeException(wrappedExc.getMessage());
  1898                 }
  1859                 }
  1899             }
  1860             }
  1900         }
  1861         }
  1901 
  1862 
  1902         RELATION_LOGGER.exiting(RelationService.class.getName(), "getRole");
  1863         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1903         return result;
  1864         return result;
  1904     }
  1865     }
  1905 
  1866 
  1906     /**
  1867     /**
  1907      * Retrieves values of roles with given names in given relation.
  1868      * Retrieves values of roles with given names in given relation.
  1929         if (relationId == null || roleNameArray == null) {
  1890         if (relationId == null || roleNameArray == null) {
  1930             String excMsg = "Invalid parameter.";
  1891             String excMsg = "Invalid parameter.";
  1931             throw new IllegalArgumentException(excMsg);
  1892             throw new IllegalArgumentException(excMsg);
  1932         }
  1893         }
  1933 
  1894 
  1934         RELATION_LOGGER.entering(RelationService.class.getName(),
  1895         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
  1935                 "getRoles", relationId);
       
  1936 
  1896 
  1937         // Can throw RelationServiceNotRegisteredException
  1897         // Can throw RelationServiceNotRegisteredException
  1938         isActive();
  1898         isActive();
  1939 
  1899 
  1940         // Can throw a RelationNotFoundException
  1900         // Can throw a RelationNotFoundException
  1974                 throw new
  1934                 throw new
  1975                     RuntimeException((exc3.getTargetException()).getMessage());
  1935                     RuntimeException((exc3.getTargetException()).getMessage());
  1976             }
  1936             }
  1977         }
  1937         }
  1978 
  1938 
  1979         RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles");
  1939         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1980         return result;
  1940         return result;
  1981     }
  1941     }
  1982 
  1942 
  1983     /**
  1943     /**
  1984      * Returns all roles present in the relation.
  1944      * Returns all roles present in the relation.
  2002         if (relationId == null) {
  1962         if (relationId == null) {
  2003             String excMsg = "Invalid parameter.";
  1963             String excMsg = "Invalid parameter.";
  2004             throw new IllegalArgumentException(excMsg);
  1964             throw new IllegalArgumentException(excMsg);
  2005         }
  1965         }
  2006 
  1966 
  2007         RELATION_LOGGER.entering(RelationService.class.getName(),
  1967         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
  2008                 "getRoles", relationId);
       
  2009 
  1968 
  2010         // Can throw a RelationNotFoundException
  1969         // Can throw a RelationNotFoundException
  2011         Object relObj = getRelation(relationId);
  1970         Object relObj = getRelation(relationId);
  2012 
  1971 
  2013         RoleResult result;
  1972         RoleResult result;
  2026             } catch (Exception exc) {
  1985             } catch (Exception exc) {
  2027                 throw new RuntimeException(exc.getMessage());
  1986                 throw new RuntimeException(exc.getMessage());
  2028             }
  1987             }
  2029         }
  1988         }
  2030 
  1989 
  2031         RELATION_LOGGER.exiting(RelationService.class.getName(), "getRoles");
  1990         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2032         return result;
  1991         return result;
  2033     }
  1992     }
  2034 
  1993 
  2035     /**
  1994     /**
  2036      * Retrieves the number of MBeans currently referenced in the given role.
  1995      * Retrieves the number of MBeans currently referenced in the given role.
  2053         if (relationId == null || roleName == null) {
  2012         if (relationId == null || roleName == null) {
  2054             String excMsg = "Invalid parameter.";
  2013             String excMsg = "Invalid parameter.";
  2055             throw new IllegalArgumentException(excMsg);
  2014             throw new IllegalArgumentException(excMsg);
  2056         }
  2015         }
  2057 
  2016 
  2058         RELATION_LOGGER.entering(RelationService.class.getName(),
  2017         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
  2059                 "getRoleCardinality", new Object[] {relationId, roleName});
  2018                             relationId, roleName);
  2060 
  2019 
  2061         // Can throw a RelationNotFoundException
  2020         // Can throw a RelationNotFoundException
  2062         Object relObj = getRelation(relationId);
  2021         Object relObj = getRelation(relationId);
  2063 
  2022 
  2064         Integer result;
  2023         Integer result;
  2096                     throw new RuntimeException(wrappedExc.getMessage());
  2055                     throw new RuntimeException(wrappedExc.getMessage());
  2097                 }
  2056                 }
  2098             }
  2057             }
  2099         }
  2058         }
  2100 
  2059 
  2101         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2060         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2102                 "getRoleCardinality");
       
  2103         return result;
  2061         return result;
  2104     }
  2062     }
  2105 
  2063 
  2106     /**
  2064     /**
  2107      * Sets the given role in given relation.
  2065      * Sets the given role in given relation.
  2145         if (relationId == null || role == null) {
  2103         if (relationId == null || role == null) {
  2146             String excMsg = "Invalid parameter.";
  2104             String excMsg = "Invalid parameter.";
  2147             throw new IllegalArgumentException(excMsg);
  2105             throw new IllegalArgumentException(excMsg);
  2148         }
  2106         }
  2149 
  2107 
  2150         RELATION_LOGGER.entering(RelationService.class.getName(),
  2108         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
  2151                 "setRole", new Object[] {relationId, role});
  2109                             relationId, role);
  2152 
  2110 
  2153         // Can throw RelationServiceNotRegisteredException
  2111         // Can throw RelationServiceNotRegisteredException
  2154         isActive();
  2112         isActive();
  2155 
  2113 
  2156         // Can throw a RelationNotFoundException
  2114         // Can throw a RelationNotFoundException
  2209             } catch (InvalidAttributeValueException exc5) {
  2167             } catch (InvalidAttributeValueException exc5) {
  2210               throw new RuntimeException(exc5.getMessage());
  2168               throw new RuntimeException(exc5.getMessage());
  2211             }
  2169             }
  2212         }
  2170         }
  2213 
  2171 
  2214         RELATION_LOGGER.exiting(RelationService.class.getName(), "setRole");
  2172         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2215         return;
  2173         return;
  2216     }
  2174     }
  2217 
  2175 
  2218     /**
  2176     /**
  2219      * Sets the given roles in given relation.
  2177      * Sets the given roles in given relation.
  2245         if (relationId == null || roleList == null) {
  2203         if (relationId == null || roleList == null) {
  2246             String excMsg = "Invalid parameter.";
  2204             String excMsg = "Invalid parameter.";
  2247             throw new IllegalArgumentException(excMsg);
  2205             throw new IllegalArgumentException(excMsg);
  2248         }
  2206         }
  2249 
  2207 
  2250         RELATION_LOGGER.entering(RelationService.class.getName(),
  2208         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
  2251                 "setRoles", new Object[] {relationId, roleList});
  2209                             relationId, roleList);
  2252 
  2210 
  2253         // Can throw RelationServiceNotRegisteredException
  2211         // Can throw RelationServiceNotRegisteredException
  2254         isActive();
  2212         isActive();
  2255 
  2213 
  2256         // Can throw a RelationNotFoundException
  2214         // Can throw a RelationNotFoundException
  2294                 throw new
  2252                 throw new
  2295                     RuntimeException((exc2.getTargetException()).getMessage());
  2253                     RuntimeException((exc2.getTargetException()).getMessage());
  2296             }
  2254             }
  2297         }
  2255         }
  2298 
  2256 
  2299         RELATION_LOGGER.exiting(RelationService.class.getName(), "setRoles");
  2257         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2300         return result;
  2258         return result;
  2301     }
  2259     }
  2302 
  2260 
  2303     /**
  2261     /**
  2304      * Retrieves MBeans referenced in the various roles of the relation.
  2262      * Retrieves MBeans referenced in the various roles of the relation.
  2320         if (relationId == null) {
  2278         if (relationId == null) {
  2321             String excMsg = "Invalid parameter.";
  2279             String excMsg = "Invalid parameter.";
  2322             throw new IllegalArgumentException(excMsg);
  2280             throw new IllegalArgumentException(excMsg);
  2323         }
  2281         }
  2324 
  2282 
  2325         RELATION_LOGGER.entering(RelationService.class.getName(),
  2283         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}",
  2326                 "getReferencedMBeans", relationId);
  2284                             relationId);
  2327 
  2285 
  2328         // Can throw a RelationNotFoundException
  2286         // Can throw a RelationNotFoundException
  2329         Object relObj = getRelation(relationId);
  2287         Object relObj = getRelation(relationId);
  2330 
  2288 
  2331         Map<ObjectName,List<String>> result;
  2289         Map<ObjectName,List<String>> result;
  2344             } catch (Exception exc) {
  2302             } catch (Exception exc) {
  2345                 throw new RuntimeException(exc.getMessage());
  2303                 throw new RuntimeException(exc.getMessage());
  2346             }
  2304             }
  2347         }
  2305         }
  2348 
  2306 
  2349         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2307         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2350                 "getReferencedMBeans");
       
  2351         return result;
  2308         return result;
  2352     }
  2309     }
  2353 
  2310 
  2354     /**
  2311     /**
  2355      * Returns name of associated relation type for given relation.
  2312      * Returns name of associated relation type for given relation.
  2369         if (relationId == null) {
  2326         if (relationId == null) {
  2370             String excMsg = "Invalid parameter.";
  2327             String excMsg = "Invalid parameter.";
  2371             throw new IllegalArgumentException(excMsg);
  2328             throw new IllegalArgumentException(excMsg);
  2372         }
  2329         }
  2373 
  2330 
  2374         RELATION_LOGGER.entering(RelationService.class.getName(),
  2331         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
  2375                 "getRelationTypeName", relationId);
       
  2376 
  2332 
  2377         // Can throw a RelationNotFoundException
  2333         // Can throw a RelationNotFoundException
  2378         Object relObj = getRelation(relationId);
  2334         Object relObj = getRelation(relationId);
  2379 
  2335 
  2380         String result;
  2336         String result;
  2393             } catch (Exception exc) {
  2349             } catch (Exception exc) {
  2394                 throw new RuntimeException(exc.getMessage());
  2350                 throw new RuntimeException(exc.getMessage());
  2395             }
  2351             }
  2396         }
  2352         }
  2397 
  2353 
  2398         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2354         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2399                 "getRelationTypeName");
       
  2400         return result;
  2355         return result;
  2401     }
  2356     }
  2402 
  2357 
  2403     //
  2358     //
  2404     // NotificationListener Interface
  2359     // NotificationListener Interface
  2419         if (notif == null) {
  2374         if (notif == null) {
  2420             String excMsg = "Invalid parameter.";
  2375             String excMsg = "Invalid parameter.";
  2421             throw new IllegalArgumentException(excMsg);
  2376             throw new IllegalArgumentException(excMsg);
  2422         }
  2377         }
  2423 
  2378 
  2424         RELATION_LOGGER.entering(RelationService.class.getName(),
  2379         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", notif);
  2425                 "handleNotification", notif);
       
  2426 
  2380 
  2427         if (notif instanceof MBeanServerNotification) {
  2381         if (notif instanceof MBeanServerNotification) {
  2428 
  2382 
  2429             MBeanServerNotification mbsNtf = (MBeanServerNotification) notif;
  2383             MBeanServerNotification mbsNtf = (MBeanServerNotification) notif;
  2430             String ntfType = notif.getType();
  2384             String ntfType = notif.getType();
  2478                     }
  2432                     }
  2479                 }
  2433                 }
  2480             }
  2434             }
  2481         }
  2435         }
  2482 
  2436 
  2483         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2437         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2484                 "handleNotification");
       
  2485         return;
  2438         return;
  2486     }
  2439     }
  2487 
  2440 
  2488     //
  2441     //
  2489     // NotificationBroadcaster interface
  2442     // NotificationBroadcaster interface
  2493      * Returns a NotificationInfo object containing the name of the Java class
  2446      * Returns a NotificationInfo object containing the name of the Java class
  2494      * of the notification and the notification types sent.
  2447      * of the notification and the notification types sent.
  2495      */
  2448      */
  2496     public MBeanNotificationInfo[] getNotificationInfo() {
  2449     public MBeanNotificationInfo[] getNotificationInfo() {
  2497 
  2450 
  2498         RELATION_LOGGER.entering(RelationService.class.getName(),
  2451         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
  2499                 "getNotificationInfo");
       
  2500 
  2452 
  2501         String ntfClass = "javax.management.relation.RelationNotification";
  2453         String ntfClass = "javax.management.relation.RelationNotification";
  2502 
  2454 
  2503         String[] ntfTypes = new String[] {
  2455         String[] ntfTypes = new String[] {
  2504             RelationNotification.RELATION_BASIC_CREATION,
  2456             RelationNotification.RELATION_BASIC_CREATION,
  2512         String ntfDesc = "Sent when a relation is created, updated or deleted.";
  2464         String ntfDesc = "Sent when a relation is created, updated or deleted.";
  2513 
  2465 
  2514         MBeanNotificationInfo ntfInfo =
  2466         MBeanNotificationInfo ntfInfo =
  2515             new MBeanNotificationInfo(ntfTypes, ntfClass, ntfDesc);
  2467             new MBeanNotificationInfo(ntfTypes, ntfClass, ntfDesc);
  2516 
  2468 
  2517         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2469         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2518                 "getNotificationInfo");
       
  2519         return new MBeanNotificationInfo[] {ntfInfo};
  2470         return new MBeanNotificationInfo[] {ntfInfo};
  2520     }
  2471     }
  2521 
  2472 
  2522     //
  2473     //
  2523     // Misc
  2474     // Misc
  2537         if (relationTypeObj == null) {
  2488         if (relationTypeObj == null) {
  2538             String excMsg = "Invalid parameter.";
  2489             String excMsg = "Invalid parameter.";
  2539             throw new IllegalArgumentException(excMsg);
  2490             throw new IllegalArgumentException(excMsg);
  2540         }
  2491         }
  2541 
  2492 
  2542         RELATION_LOGGER.entering(RelationService.class.getName(),
  2493         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
  2543                 "addRelationTypeInt");
       
  2544 
  2494 
  2545         String relTypeName = relationTypeObj.getRelationTypeName();
  2495         String relTypeName = relationTypeObj.getRelationTypeName();
  2546 
  2496 
  2547         // Checks that there is not already a relation type with that name
  2497         // Checks that there is not already a relation type with that name
  2548         // existing in the Relation Service
  2498         // existing in the Relation Service
  2568 
  2518 
  2569         if (relationTypeObj instanceof RelationTypeSupport) {
  2519         if (relationTypeObj instanceof RelationTypeSupport) {
  2570             ((RelationTypeSupport)relationTypeObj).setRelationServiceFlag(true);
  2520             ((RelationTypeSupport)relationTypeObj).setRelationServiceFlag(true);
  2571         }
  2521         }
  2572 
  2522 
  2573         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2523         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2574                 "addRelationTypeInt");
       
  2575         return;
  2524         return;
  2576      }
  2525      }
  2577 
  2526 
  2578     // Retrieves relation type with given name
  2527     // Retrieves relation type with given name
  2579     //
  2528     //
  2593         if (relationTypeName == null) {
  2542         if (relationTypeName == null) {
  2594             String excMsg = "Invalid parameter.";
  2543             String excMsg = "Invalid parameter.";
  2595             throw new IllegalArgumentException(excMsg);
  2544             throw new IllegalArgumentException(excMsg);
  2596         }
  2545         }
  2597 
  2546 
  2598         RELATION_LOGGER.entering(RelationService.class.getName(),
  2547         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName);
  2599                 "getRelationType", relationTypeName);
       
  2600 
  2548 
  2601         // No null relation type accepted, so can use get()
  2549         // No null relation type accepted, so can use get()
  2602         RelationType relType;
  2550         RelationType relType;
  2603         synchronized(myRelType2ObjMap) {
  2551         synchronized(myRelType2ObjMap) {
  2604             relType = (myRelType2ObjMap.get(relationTypeName));
  2552             relType = (myRelType2ObjMap.get(relationTypeName));
  2609             StringBuilder excMsgStrB = new StringBuilder(excMsg);
  2557             StringBuilder excMsgStrB = new StringBuilder(excMsg);
  2610             excMsgStrB.append(relationTypeName);
  2558             excMsgStrB.append(relationTypeName);
  2611             throw new RelationTypeNotFoundException(excMsgStrB.toString());
  2559             throw new RelationTypeNotFoundException(excMsgStrB.toString());
  2612         }
  2560         }
  2613 
  2561 
  2614         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2562         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2615                 "getRelationType");
       
  2616         return relType;
  2563         return relType;
  2617     }
  2564     }
  2618 
  2565 
  2619     // Retrieves relation corresponding to given relation id.
  2566     // Retrieves relation corresponding to given relation id.
  2620     // Returns either:
  2567     // Returns either:
  2637         if (relationId == null) {
  2584         if (relationId == null) {
  2638             String excMsg = "Invalid parameter.";
  2585             String excMsg = "Invalid parameter.";
  2639             throw new IllegalArgumentException(excMsg);
  2586             throw new IllegalArgumentException(excMsg);
  2640         }
  2587         }
  2641 
  2588 
  2642         RELATION_LOGGER.entering(RelationService.class.getName(),
  2589         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId);
  2643                 "getRelation", relationId);
       
  2644 
  2590 
  2645         // No null relation  accepted, so can use get()
  2591         // No null relation  accepted, so can use get()
  2646         Object rel;
  2592         Object rel;
  2647         synchronized(myRelId2ObjMap) {
  2593         synchronized(myRelId2ObjMap) {
  2648             rel = myRelId2ObjMap.get(relationId);
  2594             rel = myRelId2ObjMap.get(relationId);
  2651         if (rel == null) {
  2597         if (rel == null) {
  2652             String excMsg = "No relation associated to relation id " + relationId;
  2598             String excMsg = "No relation associated to relation id " + relationId;
  2653             throw new RelationNotFoundException(excMsg);
  2599             throw new RelationNotFoundException(excMsg);
  2654         }
  2600         }
  2655 
  2601 
  2656         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2602         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2657                 "getRelation");
       
  2658         return rel;
  2603         return rel;
  2659     }
  2604     }
  2660 
  2605 
  2661     // Adds a new MBean reference (reference to an ObjectName) in the
  2606     // Adds a new MBean reference (reference to an ObjectName) in the
  2662     // referenced MBean map (myRefedMBeanObjName2RelIdsMap).
  2607     // referenced MBean map (myRefedMBeanObjName2RelIdsMap).
  2682             roleName == null) {
  2627             roleName == null) {
  2683             String excMsg = "Invalid parameter.";
  2628             String excMsg = "Invalid parameter.";
  2684             throw new IllegalArgumentException(excMsg);
  2629             throw new IllegalArgumentException(excMsg);
  2685         }
  2630         }
  2686 
  2631 
  2687         RELATION_LOGGER.entering(RelationService.class.getName(),
  2632         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  2688                 "addNewMBeanReference",
  2633                             objectName, relationId, roleName);
  2689                 new Object[] {objectName, relationId, roleName});
       
  2690 
  2634 
  2691         boolean isNewFlag = false;
  2635         boolean isNewFlag = false;
  2692 
  2636 
  2693         synchronized(myRefedMBeanObjName2RelIdsMap) {
  2637         synchronized(myRefedMBeanObjName2RelIdsMap) {
  2694 
  2638 
  2737                     roleNames.add(roleName);
  2681                     roleNames.add(roleName);
  2738                 }
  2682                 }
  2739             }
  2683             }
  2740         }
  2684         }
  2741 
  2685 
  2742         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2686         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2743                 "addNewMBeanReference");
       
  2744         return isNewFlag;
  2687         return isNewFlag;
  2745     }
  2688     }
  2746 
  2689 
  2747     // Removes an obsolete MBean reference (reference to an ObjectName) in
  2690     // Removes an obsolete MBean reference (reference to an ObjectName) in
  2748     // the referenced MBean map (myRefedMBeanObjName2RelIdsMap).
  2691     // the referenced MBean map (myRefedMBeanObjName2RelIdsMap).
  2770             roleName == null) {
  2713             roleName == null) {
  2771             String excMsg = "Invalid parameter.";
  2714             String excMsg = "Invalid parameter.";
  2772             throw new IllegalArgumentException(excMsg);
  2715             throw new IllegalArgumentException(excMsg);
  2773         }
  2716         }
  2774 
  2717 
  2775         RELATION_LOGGER.entering(RelationService.class.getName(),
  2718         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
  2776                 "removeMBeanReference",
  2719                             objectName, relationId, roleName, allRolesFlag);
  2777                 new Object[] {objectName, relationId, roleName, allRolesFlag});
       
  2778 
  2720 
  2779         boolean noLongerRefFlag = false;
  2721         boolean noLongerRefFlag = false;
  2780 
  2722 
  2781         synchronized(myRefedMBeanObjName2RelIdsMap) {
  2723         synchronized(myRefedMBeanObjName2RelIdsMap) {
  2782 
  2724 
  2788             Map<String,List<String>> mbeanRefMap =
  2730             Map<String,List<String>> mbeanRefMap =
  2789                 (myRefedMBeanObjName2RelIdsMap.get(objectName));
  2731                 (myRefedMBeanObjName2RelIdsMap.get(objectName));
  2790 
  2732 
  2791             if (mbeanRefMap == null) {
  2733             if (mbeanRefMap == null) {
  2792                 // The MBean is no longer referenced
  2734                 // The MBean is no longer referenced
  2793                 RELATION_LOGGER.exiting(RelationService.class.getName(),
  2735                 RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2794                         "removeMBeanReference");
       
  2795                 return true;
  2736                 return true;
  2796             }
  2737             }
  2797 
  2738 
  2798             List<String> roleNames = null;
  2739             List<String> roleNames = null;
  2799             if (!allRolesFlag) {
  2740             if (!allRolesFlag) {
  2822                 myRefedMBeanObjName2RelIdsMap.remove(objectName);
  2763                 myRefedMBeanObjName2RelIdsMap.remove(objectName);
  2823                 noLongerRefFlag = true;
  2764                 noLongerRefFlag = true;
  2824             }
  2765             }
  2825         }
  2766         }
  2826 
  2767 
  2827         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2768         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2828                 "removeMBeanReference");
       
  2829         return noLongerRefFlag;
  2769         return noLongerRefFlag;
  2830     }
  2770     }
  2831 
  2771 
  2832     // Updates the listener registered to the MBean Server to be informed of
  2772     // Updates the listener registered to the MBean Server to be informed of
  2833     // referenced MBean deregistrations
  2773     // referenced MBean deregistrations
  2848                 // Nothing to do :)
  2788                 // Nothing to do :)
  2849                 return;
  2789                 return;
  2850             }
  2790             }
  2851         }
  2791         }
  2852 
  2792 
  2853         RELATION_LOGGER.entering(RelationService.class.getName(),
  2793         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}",
  2854                 "updateUnregistrationListener",
  2794                             newRefList, obsoleteRefList);
  2855                 new Object[] {newRefList, obsoleteRefList});
       
  2856 
  2795 
  2857         // Can throw RelationServiceNotRegisteredException
  2796         // Can throw RelationServiceNotRegisteredException
  2858         isActive();
  2797         isActive();
  2859 
  2798 
  2860         if (newRefList != null || obsoleteRefList != null) {
  2799         if (newRefList != null || obsoleteRefList != null) {
  2934 //                     RelationServiceNotRegisteredException(exc.getMessage());
  2873 //                     RelationServiceNotRegisteredException(exc.getMessage());
  2935 //              }
  2874 //              }
  2936             }
  2875             }
  2937         }
  2876         }
  2938 
  2877 
  2939         RELATION_LOGGER.exiting(RelationService.class.getName(),
  2878         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  2940                 "updateUnregistrationListener");
       
  2941         return;
  2879         return;
  2942     }
  2880     }
  2943 
  2881 
  2944     // Adds a relation (being either a RelationSupport object or an MBean
  2882     // Adds a relation (being either a RelationSupport object or an MBean
  2945     // referenced using its ObjectName) in the Relation Service.
  2883     // referenced using its ObjectName) in the Relation Service.
  3001               relationObj != null))) {
  2939               relationObj != null))) {
  3002             String excMsg = "Invalid parameter.";
  2940             String excMsg = "Invalid parameter.";
  3003             throw new IllegalArgumentException(excMsg);
  2941             throw new IllegalArgumentException(excMsg);
  3004         }
  2942         }
  3005 
  2943 
  3006         RELATION_LOGGER.entering(RelationService.class.getName(),
  2944         RELATION_LOGGER.log(Level.TRACE,
  3007                 "addRelationInt", new Object[] {relationBaseFlag, relationObj,
  2945                             "ENTRY {0} {1} {2} {3} {4} {5}",
  3008                 relationObjName, relationId, relationTypeName, roleList});
  2946                             relationBaseFlag, relationObj, relationObjName,
       
  2947                             relationId, relationTypeName, roleList);
  3009 
  2948 
  3010         // Can throw RelationServiceNotRegisteredException
  2949         // Can throw RelationServiceNotRegisteredException
  3011         isActive();
  2950         isActive();
  3012 
  2951 
  3013         // Checks if there is already a relation with given id
  2952         // Checks if there is already a relation with given id
  3142 
  3081 
  3143         } catch (RelationNotFoundException exc) {
  3082         } catch (RelationNotFoundException exc) {
  3144             // OK : The Relation could not be found.
  3083             // OK : The Relation could not be found.
  3145         }
  3084         }
  3146 
  3085 
  3147         RELATION_LOGGER.exiting(RelationService.class.getName(),
  3086         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3148                 "addRelationInt");
       
  3149         return;
  3087         return;
  3150     }
  3088     }
  3151 
  3089 
  3152     // Checks that given role conforms to given role info.
  3090     // Checks that given role conforms to given role info.
  3153     //
  3091     //
  3183             (chkType == 2 && roleValue == null)) {
  3121             (chkType == 2 && roleValue == null)) {
  3184             String excMsg = "Invalid parameter.";
  3122             String excMsg = "Invalid parameter.";
  3185             throw new IllegalArgumentException(excMsg);
  3123             throw new IllegalArgumentException(excMsg);
  3186         }
  3124         }
  3187 
  3125 
  3188         RELATION_LOGGER.entering(RelationService.class.getName(),
  3126         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4}",
  3189                 "checkRoleInt", new Object[] {chkType, roleName,
  3127                             chkType, roleName, roleValue, roleInfo, writeChkFlag);
  3190                 roleValue, roleInfo, writeChkFlag});
       
  3191 
  3128 
  3192         // Compares names
  3129         // Compares names
  3193         String expName = roleInfo.getName();
  3130         String expName = roleInfo.getName();
  3194         if (!(roleName.equals(expName))) {
  3131         if (!(roleName.equals(expName))) {
  3195             RELATION_LOGGER.exiting(RelationService.class.getName(),
  3132             RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3196                     "checkRoleInt");
       
  3197             return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
  3133             return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
  3198         }
  3134         }
  3199 
  3135 
  3200         // Checks read access if required
  3136         // Checks read access if required
  3201         if (chkType == 1) {
  3137         if (chkType == 1) {
  3202             boolean isReadable = roleInfo.isReadable();
  3138             boolean isReadable = roleInfo.isReadable();
  3203             if (!isReadable) {
  3139             if (!isReadable) {
  3204                 RELATION_LOGGER.exiting(RelationService.class.getName(),
  3140                 RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3205                         "checkRoleInt");
       
  3206                 return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE);
  3141                 return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE);
  3207             } else {
  3142             } else {
  3208                 // End of check :)
  3143                 // End of check :)
  3209                 RELATION_LOGGER.exiting(RelationService.class.getName(),
  3144                 RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3210                         "checkRoleInt");
       
  3211                 return 0;
  3145                 return 0;
  3212             }
  3146             }
  3213         }
  3147         }
  3214 
  3148 
  3215         // Checks write access if required
  3149         // Checks write access if required
  3216         if (writeChkFlag) {
  3150         if (writeChkFlag) {
  3217             boolean isWritable = roleInfo.isWritable();
  3151             boolean isWritable = roleInfo.isWritable();
  3218             if (!isWritable) {
  3152             if (!isWritable) {
  3219                 RELATION_LOGGER.exiting(RelationService.class.getName(),
  3153                 RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3220                         "checkRoleInt");
       
  3221                 return RoleStatus.ROLE_NOT_WRITABLE;
  3154                 return RoleStatus.ROLE_NOT_WRITABLE;
  3222             }
  3155             }
  3223         }
  3156         }
  3224 
  3157 
  3225         int refNbr = roleValue.size();
  3158         int refNbr = roleValue.size();
  3226 
  3159 
  3227         // Checks minimum cardinality
  3160         // Checks minimum cardinality
  3228         boolean chkMinFlag = roleInfo.checkMinDegree(refNbr);
  3161         boolean chkMinFlag = roleInfo.checkMinDegree(refNbr);
  3229         if (!chkMinFlag) {
  3162         if (!chkMinFlag) {
  3230             RELATION_LOGGER.exiting(RelationService.class.getName(),
  3163             RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3231                     "checkRoleInt");
       
  3232             return RoleStatus.LESS_THAN_MIN_ROLE_DEGREE;
  3164             return RoleStatus.LESS_THAN_MIN_ROLE_DEGREE;
  3233         }
  3165         }
  3234 
  3166 
  3235         // Checks maximum cardinality
  3167         // Checks maximum cardinality
  3236         boolean chkMaxFlag = roleInfo.checkMaxDegree(refNbr);
  3168         boolean chkMaxFlag = roleInfo.checkMaxDegree(refNbr);
  3237         if (!chkMaxFlag) {
  3169         if (!chkMaxFlag) {
  3238             RELATION_LOGGER.exiting(RelationService.class.getName(),
  3170             RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3239                     "checkRoleInt");
       
  3240             return RoleStatus.MORE_THAN_MAX_ROLE_DEGREE;
  3171             return RoleStatus.MORE_THAN_MAX_ROLE_DEGREE;
  3241         }
  3172         }
  3242 
  3173 
  3243         // Verifies that each referenced MBean is registered in the MBean
  3174         // Verifies that each referenced MBean is registered in the MBean
  3244         // Server and that it is an instance of the class specified in the
  3175         // Server and that it is an instance of the class specified in the
  3250 
  3181 
  3251         for (ObjectName currObjName : roleValue) {
  3182         for (ObjectName currObjName : roleValue) {
  3252 
  3183 
  3253             // Checks it is registered
  3184             // Checks it is registered
  3254             if (currObjName == null) {
  3185             if (currObjName == null) {
  3255                 RELATION_LOGGER.exiting(RelationService.class.getName(),
  3186                 RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3256                         "checkRoleInt");
       
  3257                 return RoleStatus.REF_MBEAN_NOT_REGISTERED;
  3187                 return RoleStatus.REF_MBEAN_NOT_REGISTERED;
  3258             }
  3188             }
  3259 
  3189 
  3260             // Checks if it is of the correct class
  3190             // Checks if it is of the correct class
  3261             // Can throw an InstanceNotFoundException, if MBean not registered
  3191             // Can throw an InstanceNotFoundException, if MBean not registered
  3262             try {
  3192             try {
  3263                 boolean classSts = myMBeanServer.isInstanceOf(currObjName,
  3193                 boolean classSts = myMBeanServer.isInstanceOf(currObjName,
  3264                                                               expClassName);
  3194                                                               expClassName);
  3265                 if (!classSts) {
  3195                 if (!classSts) {
  3266                     RELATION_LOGGER.exiting(RelationService.class.getName(),
  3196                     RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3267                             "checkRoleInt");
       
  3268                     return RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS;
  3197                     return RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS;
  3269                 }
  3198                 }
  3270 
  3199 
  3271             } catch (InstanceNotFoundException exc) {
  3200             } catch (InstanceNotFoundException exc) {
  3272                 RELATION_LOGGER.exiting(RelationService.class.getName(),
  3201                 RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3273                         "checkRoleInt");
       
  3274                 return RoleStatus.REF_MBEAN_NOT_REGISTERED;
  3202                 return RoleStatus.REF_MBEAN_NOT_REGISTERED;
  3275             }
  3203             }
  3276         }
  3204         }
  3277 
  3205 
  3278         RELATION_LOGGER.exiting(RelationService.class.getName(),
  3206         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3279                 "checkRoleInt");
       
  3280         return 0;
  3207         return 0;
  3281     }
  3208     }
  3282 
  3209 
  3283 
  3210 
  3284     // Initializes roles associated to given role infos to default value (empty
  3211     // Initializes roles associated to given role infos to default value (empty
  3326             roleInfoList == null) {
  3253             roleInfoList == null) {
  3327             String excMsg = "Invalid parameter.";
  3254             String excMsg = "Invalid parameter.";
  3328             throw new IllegalArgumentException(excMsg);
  3255             throw new IllegalArgumentException(excMsg);
  3329         }
  3256         }
  3330 
  3257 
  3331         RELATION_LOGGER.entering(RelationService.class.getName(),
  3258         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4} {5}",
  3332                 "initializeMissingRoles", new Object[] {relationBaseFlag,
  3259                             relationBaseFlag, relationObj, relationObjName,
  3333                 relationObj, relationObjName, relationId, relationTypeName,
  3260                             relationId, relationTypeName, roleInfoList);
  3334                 roleInfoList});
       
  3335 
  3261 
  3336         // Can throw RelationServiceNotRegisteredException
  3262         // Can throw RelationServiceNotRegisteredException
  3337         isActive();
  3263         isActive();
  3338 
  3264 
  3339         // For each role info (corresponding to a role not initialized by the
  3265         // For each role info (corresponding to a role not initialized by the
  3408                   throw new RuntimeException(exc5.getMessage());
  3334                   throw new RuntimeException(exc5.getMessage());
  3409                 }
  3335                 }
  3410             }
  3336             }
  3411         }
  3337         }
  3412 
  3338 
  3413         RELATION_LOGGER.exiting(RelationService.class.getName(),
  3339         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3414                 "initializeMissingRoles");
       
  3415         return;
  3340         return;
  3416     }
  3341     }
  3417 
  3342 
  3418     // Throws an exception corresponding to a given problem type
  3343     // Throws an exception corresponding to a given problem type
  3419     //
  3344     //
  3526               oldValue == null))) {
  3451               oldValue == null))) {
  3527             String excMsg = "Invalid parameter.";
  3452             String excMsg = "Invalid parameter.";
  3528             throw new IllegalArgumentException(excMsg);
  3453             throw new IllegalArgumentException(excMsg);
  3529         }
  3454         }
  3530 
  3455 
  3531         RELATION_LOGGER.entering(RelationService.class.getName(),
  3456         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4} {5} {6}",
  3532                 "sendNotificationInt", new Object[] {intNtfType, message,
  3457                             intNtfType, message, relationId, unregMBeanList,
  3533                 relationId, unregMBeanList, roleName, roleNewValue, oldValue});
  3458                             roleName, roleNewValue, oldValue);
  3534 
  3459 
  3535         // Relation type name
  3460         // Relation type name
  3536         // Note: do not use getRelationTypeName() as if it is a relation MBean
  3461         // Note: do not use getRelationTypeName() as if it is a relation MBean
  3537         //       it is already unregistered.
  3462         //       it is already unregistered.
  3538         String relTypeName;
  3463         String relTypeName;
  3614                                                oldValue);
  3539                                                oldValue);
  3615             }
  3540             }
  3616 
  3541 
  3617         sendNotification(ntf);
  3542         sendNotification(ntf);
  3618 
  3543 
  3619         RELATION_LOGGER.exiting(RelationService.class.getName(),
  3544         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3620                 "sendNotificationInt");
       
  3621         return;
  3545         return;
  3622     }
  3546     }
  3623 
  3547 
  3624     // Checks, for the unregistration of an MBean referenced in the roles given
  3548     // Checks, for the unregistration of an MBean referenced in the roles given
  3625     // in parameter, if the relation has to be removed or not, regarding
  3549     // in parameter, if the relation has to be removed or not, regarding
  3652             objectName == null) {
  3576             objectName == null) {
  3653             String excMsg = "Invalid parameter.";
  3577             String excMsg = "Invalid parameter.";
  3654             throw new IllegalArgumentException(excMsg);
  3578             throw new IllegalArgumentException(excMsg);
  3655         }
  3579         }
  3656 
  3580 
  3657         RELATION_LOGGER.entering(RelationService.class.getName(),
  3581         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  3658                 "handleReferenceUnregistration",
  3582                             relationId, objectName, roleNameList);
  3659                 new Object[] {relationId, objectName, roleNameList});
       
  3660 
  3583 
  3661         // Can throw RelationServiceNotRegisteredException
  3584         // Can throw RelationServiceNotRegisteredException
  3662         isActive();
  3585         isActive();
  3663 
  3586 
  3664         // Retrieves the relation type name of the relation
  3587         // Retrieves the relation type name of the relation
  3780 
  3703 
  3781                 }
  3704                 }
  3782             }
  3705             }
  3783         }
  3706         }
  3784 
  3707 
  3785         RELATION_LOGGER.exiting(RelationService.class.getName(),
  3708         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  3786                 "handleReferenceUnregistration");
       
  3787         return;
  3709         return;
  3788     }
  3710     }
  3789 }
  3711 }