String newRootName = newRootNode.getAbsoluteName(ContextNode.SCHEMA_JMX);
int count = 0;
if (log.isLoggable(Level.FINER)) log.finer("JMX rename registration from '" + oldName + "' to new root '" + newRootName + "'");
try {
// e.g. "org.xmlBlaster:nodeClass=node,node=clientSUB1,*"
ObjectName query = new ObjectName(oldName+",*");
QueryExp queryExp = null;
Set mbeanSet = this.mbeanServer.queryMBeans(query, queryExp);
if (mbeanSet.size() == 0) {
if (log.isLoggable(Level.FINE)) log.fine("JMX rename registration from '" + oldName + "' to '" + newRootName + "', nothing found for '" + query + "'");
return count;
}
Iterator it = mbeanSet.iterator();
while (it.hasNext()) {
ObjectInstance instance = (ObjectInstance)it.next();
ObjectName tmp = instance.getObjectName();
JmxMBeanHandle mbeanHandle = (JmxMBeanHandle)this.mbeanMap.get(tmp.toString());
if (mbeanHandle == null) {
log.severe("Internal problem: Can't find registration of MBean '" + tmp.toString() + "'");
continue;
}
// /node/heron/connection/joe/session/2
ContextNode newRoot = ContextNode.valueOf(newRootName);
// /node/clientjoe1/service/Pop3Driver
ContextNode current = ContextNode.valueOf(tmp.toString());
if (current == null) continue;
// /node/clientjoe1
ContextNode parent = current.getParent(oldRootClassname);
if (parent == null) continue;
// service/Pop3Driver
ContextNode[] childs = parent.getChildren();
if (childs.length != 1) continue;
this.mbeanServer.unregisterMBean(tmp);
this.mbeanMap.remove(tmp.toString());
// take this leg and attach it to the newRoot
ContextNode result = newRoot.mergeChildTree(childs[0]);
if (log.isLoggable(Level.FINE)) log.fine("Renamed '" + oldName + "' to '" + result.getAbsoluteName(ContextNode.SCHEMA_JMX) + "'");
if (result != null) {