/* ------------------------------------------------------------ */ public synchronized ObjectName uniqueObjectName( MBeanServer server, Object object, String objectName) { if (!objectName.endsWith("=")) { String className = object.getClass().getName(); if (className.indexOf(".") > 0) className = className.substring(className.lastIndexOf(".") + 1); if (className.endsWith("MBean")) className = className.substring(0, className.length() - 5); if (!objectName.endsWith(":")) objectName += ","; objectName += className + "="; } ObjectName oName = null; try { while (true) { Integer id = (Integer) __objectId.get(objectName); if (id == null) id = new Integer(0); oName = new ObjectName(objectName + id); id = new Integer(id.intValue() + 1); __objectId.put(objectName, id); // If no server, this must be unique if (server == null) break; // Otherwise let's check it is unique // if not found then it is unique if (!server.isRegistered(oName)) break; } } catch (Exception e) { log.warn(LogSupport.EXCEPTION, e); } return oName; }