public String[] getTargets() throws MBeanConfigException{
try {
java.util.ArrayList targetList = new java.util.ArrayList();
final MBeanServer mbs = MBeanServerFactory.getMBeanServer();
final AdminContext ac = MBeanRegistryFactory.getAdminContext();
final MBeanRegistry mr =
MBeanRegistryFactory.getAdminMBeanRegistry();
final String dn = ac.getDomainName();
final String servers = ServerTags.SERVERS;
final String server = ServerTags.SERVER;
final String cluster = ServerTags.CLUSTERS;
final String[] locations = new String[]{dn};
ObjectName serversON = mr.getMbeanObjectName(servers, locations);
ObjectName groupsON = mr.getMbeanObjectName(cluster, locations);
try{
ObjectName[] groupONArr = (ObjectName[])mbs.invoke(groupsON,
"getCluster", emptyParams, emptySignature);
for(int i = 0; i < groupONArr.length; i++){
targetList.add(mbs.getAttribute(groupONArr[i], "name"));
}
}catch(Exception e){
}
try {
ObjectName[] serverONArr = (ObjectName[])mbs.invoke(serversON,
"getServer", emptyParams, emptySignature);
for(int i = 0; i < serverONArr.length; i++){
String serverName =
(String)mbs.getAttribute(serverONArr[i], "name");
String[] locs = new String[]{dn,serverName};
ObjectName mbeanName = mr.getMbeanObjectName(server, locs);
Boolean clustered = (Boolean)mbs.invoke(mbeanName,
"isClustered", emptyParams, emptySignature);
if(!clustered.booleanValue()) {
targetList.add(serverName);
}