jdk/src/java.management/share/classes/javax/management/relation/RelationSupport.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
    25 
    25 
    26 package javax.management.relation;
    26 package javax.management.relation;
    27 
    27 
    28 
    28 
    29 
    29 
       
    30 import java.lang.System.Logger.Level;
    30 import java.util.ArrayList;
    31 import java.util.ArrayList;
    31 
       
    32 import java.util.HashMap;
    32 import java.util.HashMap;
    33 import java.util.Iterator;
    33 import java.util.Iterator;
    34 import java.util.Map;
    34 import java.util.Map;
    35 import java.util.List;
    35 import java.util.List;
    36 
    36 
   160         throws InvalidRoleValueException,
   160         throws InvalidRoleValueException,
   161                IllegalArgumentException {
   161                IllegalArgumentException {
   162 
   162 
   163         super();
   163         super();
   164 
   164 
   165         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   165         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   166                 "RelationSupport");
       
   167 
   166 
   168         // Can throw InvalidRoleValueException and IllegalArgumentException
   167         // Can throw InvalidRoleValueException and IllegalArgumentException
   169         initMembers(relationId,
   168         initMembers(relationId,
   170                     relationServiceName,
   169                     relationServiceName,
   171                     null,
   170                     null,
   172                     relationTypeName,
   171                     relationTypeName,
   173                     list);
   172                     list);
   174 
   173 
   175         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   174         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   176                 "RelationSupport");
       
   177     }
   175     }
   178 
   176 
   179     /**
   177     /**
   180      * Creates a {@code RelationSupport} object.
   178      * Creates a {@code RelationSupport} object.
   181      * <P>This constructor has to be used when the user relation MBean
   179      * <P>This constructor has to be used when the user relation MBean
   237         if (relationServiceMBeanServer == null) {
   235         if (relationServiceMBeanServer == null) {
   238             String excMsg = "Invalid parameter.";
   236             String excMsg = "Invalid parameter.";
   239             throw new IllegalArgumentException(excMsg);
   237             throw new IllegalArgumentException(excMsg);
   240         }
   238         }
   241 
   239 
   242         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   240         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   243                 "RelationSupport");
       
   244 
   241 
   245         // Can throw InvalidRoleValueException and
   242         // Can throw InvalidRoleValueException and
   246         // IllegalArgumentException
   243         // IllegalArgumentException
   247         initMembers(relationId,
   244         initMembers(relationId,
   248                     relationServiceName,
   245                     relationServiceName,
   249                     relationServiceMBeanServer,
   246                     relationServiceMBeanServer,
   250                     relationTypeName,
   247                     relationTypeName,
   251                     list);
   248                     list);
   252 
   249 
   253         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   250         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   254                 "RelationSupport");
       
   255     }
   251     }
   256 
   252 
   257     //
   253     //
   258     // Relation Interface
   254     // Relation Interface
   259     //
   255     //
   284         if (roleName == null) {
   280         if (roleName == null) {
   285             String excMsg = "Invalid parameter.";
   281             String excMsg = "Invalid parameter.";
   286             throw new IllegalArgumentException(excMsg);
   282             throw new IllegalArgumentException(excMsg);
   287         }
   283         }
   288 
   284 
   289         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   285         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName);
   290                 "getRole", roleName);
       
   291 
   286 
   292         // Can throw RoleNotFoundException and
   287         // Can throw RoleNotFoundException and
   293         // RelationServiceNotRegisteredException
   288         // RelationServiceNotRegisteredException
   294         List<ObjectName> result = cast(
   289         List<ObjectName> result = cast(
   295             getRoleInt(roleName, false, null, false));
   290             getRoleInt(roleName, false, null, false));
   296 
   291 
   297         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRole");
   292         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   298         return result;
   293         return result;
   299     }
   294     }
   300 
   295 
   301     /**
   296     /**
   302      * Retrieves values of roles with given names.
   297      * Retrieves values of roles with given names.
   322         if (roleNameArray == null) {
   317         if (roleNameArray == null) {
   323             String excMsg = "Invalid parameter.";
   318             String excMsg = "Invalid parameter.";
   324             throw new IllegalArgumentException(excMsg);
   319             throw new IllegalArgumentException(excMsg);
   325         }
   320         }
   326 
   321 
   327         RELATION_LOGGER.entering(RelationSupport.class.getName(), "getRoles");
   322         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   328 
   323 
   329         // Can throw RelationServiceNotRegisteredException
   324         // Can throw RelationServiceNotRegisteredException
   330         RoleResult result = getRolesInt(roleNameArray, false, null);
   325         RoleResult result = getRolesInt(roleNameArray, false, null);
   331 
   326 
   332         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoles");
   327         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   333         return result;
   328         return result;
   334     }
   329     }
   335 
   330 
   336     /**
   331     /**
   337      * Returns all roles present in the relation.
   332      * Returns all roles present in the relation.
   344      * Service is not registered in the MBean Server
   339      * Service is not registered in the MBean Server
   345      */
   340      */
   346     public RoleResult getAllRoles()
   341     public RoleResult getAllRoles()
   347         throws RelationServiceNotRegisteredException {
   342         throws RelationServiceNotRegisteredException {
   348 
   343 
   349         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   344         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   350                 "getAllRoles");
       
   351 
   345 
   352         RoleResult result = null;
   346         RoleResult result = null;
   353         try {
   347         try {
   354             result = getAllRolesInt(false, null);
   348             result = getAllRolesInt(false, null);
   355         } catch (IllegalArgumentException exc) {
   349         } catch (IllegalArgumentException exc) {
   356             // OK : Invalid parameters, ignore...
   350             // OK : Invalid parameters, ignore...
   357         }
   351         }
   358 
   352 
   359         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getAllRoles");
   353         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   360         return result;
   354         return result;
   361     }
   355     }
   362 
   356 
   363     /**
   357     /**
   364      * Returns all roles in the relation without checking read mode.
   358      * Returns all roles in the relation without checking read mode.
   365      *
   359      *
   366      * @return a RoleList
   360      * @return a RoleList
   367      */
   361      */
   368     public RoleList retrieveAllRoles() {
   362     public RoleList retrieveAllRoles() {
   369 
   363 
   370         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   364         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   371                 "retrieveAllRoles");
       
   372 
   365 
   373         RoleList result;
   366         RoleList result;
   374         synchronized(myRoleName2ValueMap) {
   367         synchronized(myRoleName2ValueMap) {
   375             result =
   368             result =
   376                 new RoleList(new ArrayList<Role>(myRoleName2ValueMap.values()));
   369                 new RoleList(new ArrayList<Role>(myRoleName2ValueMap.values()));
   377         }
   370         }
   378 
   371 
   379         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   372         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   380                 "retrieveAllRoles");
       
   381         return result;
   373         return result;
   382     }
   374     }
   383 
   375 
   384     /**
   376     /**
   385      * Returns the number of MBeans currently referenced in the given role.
   377      * Returns the number of MBeans currently referenced in the given role.
   398         if (roleName == null) {
   390         if (roleName == null) {
   399             String excMsg = "Invalid parameter.";
   391             String excMsg = "Invalid parameter.";
   400             throw new IllegalArgumentException(excMsg);
   392             throw new IllegalArgumentException(excMsg);
   401         }
   393         }
   402 
   394 
   403         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   395         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName);
   404                 "getRoleCardinality", roleName);
       
   405 
   396 
   406         // Try to retrieve the role
   397         // Try to retrieve the role
   407         Role role;
   398         Role role;
   408         synchronized(myRoleName2ValueMap) {
   399         synchronized(myRoleName2ValueMap) {
   409             // No null Role is allowed, so direct use of get()
   400             // No null Role is allowed, so direct use of get()
   424             }
   415             }
   425         }
   416         }
   426 
   417 
   427         List<ObjectName> roleValue = role.getRoleValue();
   418         List<ObjectName> roleValue = role.getRoleValue();
   428 
   419 
   429         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   420         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   430                 "getRoleCardinality");
       
   431         return roleValue.size();
   421         return roleValue.size();
   432     }
   422     }
   433 
   423 
   434     /**
   424     /**
   435      * Sets the given role.
   425      * Sets the given role.
   474         if (role == null) {
   464         if (role == null) {
   475             String excMsg = "Invalid parameter.";
   465             String excMsg = "Invalid parameter.";
   476             throw new IllegalArgumentException(excMsg);
   466             throw new IllegalArgumentException(excMsg);
   477         }
   467         }
   478 
   468 
   479         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   469         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", role);
   480                 "setRole", role);
       
   481 
   470 
   482         // Will return null :)
   471         // Will return null :)
   483         Object result = setRoleInt(role, false, null, false);
   472         Object result = setRoleInt(role, false, null, false);
   484 
   473 
   485         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRole");
   474         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   486         return;
   475         return;
   487     }
   476     }
   488 
   477 
   489     /**
   478     /**
   490      * Sets the given roles.
   479      * Sets the given roles.
   519         if (list == null) {
   508         if (list == null) {
   520             String excMsg = "Invalid parameter.";
   509             String excMsg = "Invalid parameter.";
   521             throw new IllegalArgumentException(excMsg);
   510             throw new IllegalArgumentException(excMsg);
   522         }
   511         }
   523 
   512 
   524         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   513         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", list);
   525                 "setRoles", list);
       
   526 
   514 
   527         RoleResult result = setRolesInt(list, false, null);
   515         RoleResult result = setRolesInt(list, false, null);
   528 
   516 
   529         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoles");
   517         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   530         return result;
   518         return result;
   531     }
   519     }
   532 
   520 
   533     /**
   521     /**
   534      * Callback used by the Relation Service when a MBean referenced in a role
   522      * Callback used by the Relation Service when a MBean referenced in a role
   568         if (objectName == null || roleName == null) {
   556         if (objectName == null || roleName == null) {
   569             String excMsg = "Invalid parameter.";
   557             String excMsg = "Invalid parameter.";
   570             throw new IllegalArgumentException(excMsg);
   558             throw new IllegalArgumentException(excMsg);
   571         }
   559         }
   572 
   560 
   573         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   561         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", objectName, roleName);
   574                 "handleMBeanUnregistration",
       
   575                 new Object[]{objectName, roleName});
       
   576 
   562 
   577         // Can throw RoleNotFoundException, InvalidRoleValueException,
   563         // Can throw RoleNotFoundException, InvalidRoleValueException,
   578         // or RelationTypeNotFoundException
   564         // or RelationTypeNotFoundException
   579         handleMBeanUnregistrationInt(objectName,
   565         handleMBeanUnregistrationInt(objectName,
   580                                      roleName,
   566                                      roleName,
   581                                      false,
   567                                      false,
   582                                      null);
   568                                      null);
   583 
   569 
   584         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   570         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   585                 "handleMBeanUnregistration");
       
   586         return;
   571         return;
   587     }
   572     }
   588 
   573 
   589     /**
   574     /**
   590      * Retrieves MBeans referenced in the various roles of the relation.
   575      * Retrieves MBeans referenced in the various roles of the relation.
   592      * @return a HashMap mapping:
   577      * @return a HashMap mapping:
   593      * <P> ObjectName {@literal ->} ArrayList of String (role names)
   578      * <P> ObjectName {@literal ->} ArrayList of String (role names)
   594      */
   579      */
   595     public Map<ObjectName,List<String>> getReferencedMBeans() {
   580     public Map<ObjectName,List<String>> getReferencedMBeans() {
   596 
   581 
   597         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   582         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   598                 "getReferencedMBeans");
       
   599 
   583 
   600         Map<ObjectName,List<String>> refMBeanMap =
   584         Map<ObjectName,List<String>> refMBeanMap =
   601             new HashMap<ObjectName,List<String>>();
   585             new HashMap<ObjectName,List<String>>();
   602 
   586 
   603         synchronized(myRoleName2ValueMap) {
   587         synchronized(myRoleName2ValueMap) {
   626                     }
   610                     }
   627                 }
   611                 }
   628             }
   612             }
   629         }
   613         }
   630 
   614 
   631         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   615         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   632                 "getReferencedMBeans");
       
   633         return refMBeanMap;
   616         return refMBeanMap;
   634     }
   617     }
   635 
   618 
   636     /**
   619     /**
   637      * Returns name of associated relation type.
   620      * Returns name of associated relation type.
   777             (relationServCallFlg && relationServ == null)) {
   760             (relationServCallFlg && relationServ == null)) {
   778             String excMsg = "Invalid parameter.";
   761             String excMsg = "Invalid parameter.";
   779             throw new IllegalArgumentException(excMsg);
   762             throw new IllegalArgumentException(excMsg);
   780         }
   763         }
   781 
   764 
   782         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   765         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName);
   783                 "getRoleInt", roleName);
       
   784 
   766 
   785         int pbType = 0;
   767         int pbType = 0;
   786 
   768 
   787         Role role;
   769         Role role;
   788         synchronized(myRoleName2ValueMap) {
   770         synchronized(myRoleName2ValueMap) {
   883                 // returns a RoleUnresolved object
   865                 // returns a RoleUnresolved object
   884                 result = new RoleUnresolved(roleName, null, pbType);
   866                 result = new RoleUnresolved(roleName, null, pbType);
   885             }
   867             }
   886         }
   868         }
   887 
   869 
   888         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "getRoleInt");
   870         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   889         return result;
   871         return result;
   890     }
   872     }
   891 
   873 
   892     // Gets the given roles
   874     // Gets the given roles
   893     // For each role, verifies if the role exists and is readable according to
   875     // For each role, verifies if the role exists and is readable according to
   919             (relationServCallFlg && relationServ == null)) {
   901             (relationServCallFlg && relationServ == null)) {
   920             String excMsg = "Invalid parameter.";
   902             String excMsg = "Invalid parameter.";
   921             throw new IllegalArgumentException(excMsg);
   903             throw new IllegalArgumentException(excMsg);
   922         }
   904         }
   923 
   905 
   924         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   906         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   925                 "getRolesInt");
       
   926 
   907 
   927         RoleList roleList = new RoleList();
   908         RoleList roleList = new RoleList();
   928         RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
   909         RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
   929 
   910 
   930         for (int i = 0; i < roleNameArray.length; i++) {
   911         for (int i = 0; i < roleNameArray.length; i++) {
   964                 }
   945                 }
   965             }
   946             }
   966         }
   947         }
   967 
   948 
   968         RoleResult result = new RoleResult(roleList, roleUnresList);
   949         RoleResult result = new RoleResult(roleList, roleUnresList);
   969         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   950         RELATION_LOGGER.log(Level.TRACE, "RETURN");
   970                 "getRolesInt");
       
   971         return result;
   951         return result;
   972     }
   952     }
   973 
   953 
   974     // Returns all roles present in the relation
   954     // Returns all roles present in the relation
   975     //
   955     //
   989         if (relationServCallFlg && relationServ == null) {
   969         if (relationServCallFlg && relationServ == null) {
   990             String excMsg = "Invalid parameter.";
   970             String excMsg = "Invalid parameter.";
   991             throw new IllegalArgumentException(excMsg);
   971             throw new IllegalArgumentException(excMsg);
   992         }
   972         }
   993 
   973 
   994         RELATION_LOGGER.entering(RelationSupport.class.getName(),
   974         RELATION_LOGGER.log(Level.TRACE, "ENTRY");
   995                 "getAllRolesInt");
       
   996 
   975 
   997         List<String> roleNameList;
   976         List<String> roleNameList;
   998         synchronized(myRoleName2ValueMap) {
   977         synchronized(myRoleName2ValueMap) {
   999             roleNameList =
   978             roleNameList =
  1000                 new ArrayList<String>(myRoleName2ValueMap.keySet());
   979                 new ArrayList<String>(myRoleName2ValueMap.keySet());
  1004 
   983 
  1005         RoleResult result = getRolesInt(roleNames,
   984         RoleResult result = getRolesInt(roleNames,
  1006                                         relationServCallFlg,
   985                                         relationServCallFlg,
  1007                                         relationServ);
   986                                         relationServ);
  1008 
   987 
  1009         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
   988         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1010                 "getAllRolesInt");
       
  1011         return result;
   989         return result;
  1012     }
   990     }
  1013 
   991 
  1014     // Sets the role with given value
   992     // Sets the role with given value
  1015     //
   993     //
  1081             (relationServCallFlg && relationServ == null)) {
  1059             (relationServCallFlg && relationServ == null)) {
  1082             String excMsg = "Invalid parameter.";
  1060             String excMsg = "Invalid parameter.";
  1083             throw new IllegalArgumentException(excMsg);
  1061             throw new IllegalArgumentException(excMsg);
  1084         }
  1062         }
  1085 
  1063 
  1086         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1064         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
  1087                 "setRoleInt", new Object[] {aRole, relationServCallFlg,
  1065                             aRole, relationServCallFlg, relationServ,
  1088                 relationServ, multiRoleFlg});
  1066                             multiRoleFlg);
  1089 
  1067 
  1090         String roleName = aRole.getRoleName();
  1068         String roleName = aRole.getRoleName();
  1091         int pbType = 0;
  1069         int pbType = 0;
  1092 
  1070 
  1093         // Checks if role exists in the relation
  1071         // Checks if role exists in the relation
  1242                                             aRole.getRoleValue(),
  1220                                             aRole.getRoleValue(),
  1243                                             pbType);
  1221                                             pbType);
  1244             }
  1222             }
  1245         }
  1223         }
  1246 
  1224 
  1247         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRoleInt");
  1225         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1248         return result;
  1226         return result;
  1249     }
  1227     }
  1250 
  1228 
  1251     // Requires the Relation Service to send a notification
  1229     // Requires the Relation Service to send a notification
  1252     // RelationNotification, with type being either:
  1230     // RelationNotification, with type being either:
  1284             (relationServCallFlg && relationServ == null)) {
  1262             (relationServCallFlg && relationServ == null)) {
  1285             String excMsg = "Invalid parameter.";
  1263             String excMsg = "Invalid parameter.";
  1286             throw new IllegalArgumentException(excMsg);
  1264             throw new IllegalArgumentException(excMsg);
  1287         }
  1265         }
  1288 
  1266 
  1289         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1267         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
  1290                 "sendRoleUpdateNotification", new Object[] {newRole,
  1268                             newRole, oldRoleValue, relationServCallFlg,
  1291                 oldRoleValue, relationServCallFlg, relationServ});
  1269                             relationServ);
  1292 
  1270 
  1293         if (relationServCallFlg) {
  1271         if (relationServCallFlg) {
  1294             // Direct call to the Relation Service
  1272             // Direct call to the Relation Service
  1295             // Shall not throw a RelationNotFoundException for an internal
  1273             // Shall not throw a RelationNotFoundException for an internal
  1296             // relation
  1274             // relation
  1339                     throw new RuntimeException(wrappedExc.getMessage());
  1317                     throw new RuntimeException(wrappedExc.getMessage());
  1340                 }
  1318                 }
  1341             }
  1319             }
  1342         }
  1320         }
  1343 
  1321 
  1344         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
  1322         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1345                 "sendRoleUpdateNotification");
       
  1346         return;
  1323         return;
  1347     }
  1324     }
  1348 
  1325 
  1349     // Requires the Relation Service to update its internal map handling
  1326     // Requires the Relation Service to update its internal map handling
  1350     // MBeans referenced in relations.
  1327     // MBeans referenced in relations.
  1381             (relationServCallFlg && relationServ == null)) {
  1358             (relationServCallFlg && relationServ == null)) {
  1382             String excMsg = "Invalid parameter.";
  1359             String excMsg = "Invalid parameter.";
  1383             throw new IllegalArgumentException(excMsg);
  1360             throw new IllegalArgumentException(excMsg);
  1384         }
  1361         }
  1385 
  1362 
  1386         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1363         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
  1387                 "updateRelationServiceMap", new Object[] {newRole,
  1364                             newRole, oldRoleValue, relationServCallFlg,
  1388                 oldRoleValue, relationServCallFlg, relationServ});
  1365                             relationServ);
  1389 
  1366 
  1390         if (relationServCallFlg) {
  1367         if (relationServCallFlg) {
  1391             // Direct call to the Relation Service
  1368             // Direct call to the Relation Service
  1392             // Shall not throw a RelationNotFoundException
  1369             // Shall not throw a RelationNotFoundException
  1393             try {
  1370             try {
  1431                     throw new RuntimeException(wrappedExc.getMessage());
  1408                     throw new RuntimeException(wrappedExc.getMessage());
  1432                 }
  1409                 }
  1433             }
  1410             }
  1434         }
  1411         }
  1435 
  1412 
  1436         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
  1413         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1437                 "updateRelationServiceMap");
       
  1438         return;
  1414         return;
  1439     }
  1415     }
  1440 
  1416 
  1441     // Sets the given roles
  1417     // Sets the given roles
  1442     // For each role:
  1418     // For each role:
  1482             (relationServCallFlg && relationServ == null)) {
  1458             (relationServCallFlg && relationServ == null)) {
  1483             String excMsg = "Invalid parameter.";
  1459             String excMsg = "Invalid parameter.";
  1484             throw new IllegalArgumentException(excMsg);
  1460             throw new IllegalArgumentException(excMsg);
  1485         }
  1461         }
  1486 
  1462 
  1487         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1463         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2}",
  1488                 "setRolesInt",
  1464                             list, relationServCallFlg, relationServ);
  1489                 new Object[] {list, relationServCallFlg, relationServ});
       
  1490 
  1465 
  1491         RoleList roleList = new RoleList();
  1466         RoleList roleList = new RoleList();
  1492         RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
  1467         RoleUnresolvedList roleUnresList = new RoleUnresolvedList();
  1493 
  1468 
  1494         for (Role currRole : list.asList()) {
  1469         for (Role currRole : list.asList()) {
  1532             }
  1507             }
  1533         }
  1508         }
  1534 
  1509 
  1535         RoleResult result = new RoleResult(roleList, roleUnresList);
  1510         RoleResult result = new RoleResult(roleList, roleUnresList);
  1536 
  1511 
  1537         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "setRolesInt");
  1512         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1538         return result;
  1513         return result;
  1539     }
  1514     }
  1540 
  1515 
  1541     // Initializes all members
  1516     // Initializes all members
  1542     //
  1517     //
  1576             relationTypeName == null) {
  1551             relationTypeName == null) {
  1577             String excMsg = "Invalid parameter.";
  1552             String excMsg = "Invalid parameter.";
  1578             throw new IllegalArgumentException(excMsg);
  1553             throw new IllegalArgumentException(excMsg);
  1579         }
  1554         }
  1580 
  1555 
  1581         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1556         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3} {4}",
  1582                 "initMembers", new Object[] {relationId, relationServiceName,
  1557                             relationId, relationServiceName,
  1583                 relationServiceMBeanServer, relationTypeName, list});
  1558                             relationServiceMBeanServer, relationTypeName, list);
  1584 
  1559 
  1585         myRelId = relationId;
  1560         myRelId = relationId;
  1586         myRelServiceName = relationServiceName;
  1561         myRelServiceName = relationServiceName;
  1587         myRelServiceMBeanServer = relationServiceMBeanServer;
  1562         myRelServiceMBeanServer = relationServiceMBeanServer;
  1588         myRelTypeName = relationTypeName;
  1563         myRelTypeName = relationTypeName;
  1589         // Can throw InvalidRoleValueException
  1564         // Can throw InvalidRoleValueException
  1590         initRoleMap(list);
  1565         initRoleMap(list);
  1591 
  1566 
  1592         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers");
  1567         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1593         return;
  1568         return;
  1594     }
  1569     }
  1595 
  1570 
  1596     // Initialize the internal role map from given RoleList parameter
  1571     // Initialize the internal role map from given RoleList parameter
  1597     //
  1572     //
  1606 
  1581 
  1607         if (list == null) {
  1582         if (list == null) {
  1608             return;
  1583             return;
  1609         }
  1584         }
  1610 
  1585 
  1611         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1586         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", list);
  1612                 "initRoleMap", list);
       
  1613 
  1587 
  1614         synchronized(myRoleName2ValueMap) {
  1588         synchronized(myRoleName2ValueMap) {
  1615 
  1589 
  1616             for (Role currRole : list.asList()) {
  1590             for (Role currRole : list.asList()) {
  1617 
  1591 
  1630                 myRoleName2ValueMap.put(currRoleName,
  1604                 myRoleName2ValueMap.put(currRoleName,
  1631                                         (Role)(currRole.clone()));
  1605                                         (Role)(currRole.clone()));
  1632             }
  1606             }
  1633         }
  1607         }
  1634 
  1608 
  1635         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initRoleMap");
  1609         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1636         return;
  1610         return;
  1637     }
  1611     }
  1638 
  1612 
  1639     // Callback used by the Relation Service when a MBean referenced in a role
  1613     // Callback used by the Relation Service when a MBean referenced in a role
  1640     // is unregistered.
  1614     // is unregistered.
  1690             (relationServCallFlg && relationServ == null)) {
  1664             (relationServCallFlg && relationServ == null)) {
  1691             String excMsg = "Invalid parameter.";
  1665             String excMsg = "Invalid parameter.";
  1692             throw new IllegalArgumentException(excMsg);
  1666             throw new IllegalArgumentException(excMsg);
  1693         }
  1667         }
  1694 
  1668 
  1695         RELATION_LOGGER.entering(RelationSupport.class.getName(),
  1669         RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1} {2} {3}",
  1696                 "handleMBeanUnregistrationInt", new Object[] {objectName,
  1670                             objectName, roleName, relationServCallFlg,
  1697                 roleName, relationServCallFlg, relationServ});
  1671                             relationServ);
  1698 
  1672 
  1699         // Retrieves current role value
  1673         // Retrieves current role value
  1700         Role role;
  1674         Role role;
  1701         synchronized(myRoleName2ValueMap) {
  1675         synchronized(myRoleName2ValueMap) {
  1702             role = (myRoleName2ValueMap.get(roleName));
  1676             role = (myRoleName2ValueMap.get(roleName));
  1721         // RelationTypeNotFoundException
  1695         // RelationTypeNotFoundException
  1722         // (RoleNotFoundException already detected)
  1696         // (RoleNotFoundException already detected)
  1723         Object result =
  1697         Object result =
  1724             setRoleInt(newRole, relationServCallFlg, relationServ, false);
  1698             setRoleInt(newRole, relationServCallFlg, relationServ, false);
  1725 
  1699 
  1726         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
  1700         RELATION_LOGGER.log(Level.TRACE, "RETURN");
  1727                 "handleMBeanUnregistrationInt");
       
  1728         return;
  1701         return;
  1729     }
  1702     }
  1730 
  1703 
  1731 }
  1704 }