log.info("+++ testAvailableServices, jndiURL="+jndiURL);
Properties env = new Properties();
env.setProperty(Context.PROVIDER_URL, jndiURL);
InitialContext ctx = new InitialContext(env);
MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
ObjectName all = new ObjectName("*:*");
Set allNames = server.queryNames(all, null);
ArrayList serverErrors = new ArrayList();
Iterator names = allNames.iterator();
int serviceCount = 0;
while( names.hasNext() )
{
ObjectName name = (ObjectName) names.next();
try
{
// BarrierController Barriers can be in CREATED or STOPPED state
// e.g. if the controller's startup notification hasn't been received,
// so log a message and exclude them from the search.
boolean isBarrier = server.isInstanceOf(name, BarrierController.Barrier.class.getName());
if( isBarrier )
{
log.debug("Skipping BarrierController.Barrier service: '" + name
+ "', in state: " + (String) server.getAttribute(name, "StateString"));
continue;
}
/* If this is a JSR-77 mbean, only the StateManageable types
have a meaningful state string
*/
boolean jsr77State = server.isInstanceOf(name, StateManageable.class.getName());
if( jsr77State )
{
// the stateManageable also needs to be true
Boolean flag = (Boolean) server.getAttribute(name, "stateManageable");
jsr77State = flag.booleanValue();
}
boolean mbeanService = server.isInstanceOf(name, ServiceMBean.class.getName());
if( jsr77State == true || mbeanService == true )
{
serviceCount ++;
String state = (String) server.getAttribute(name, "StateString");
if( VALID_STATES.contains(state) == false )
{
String msg = name+" is not Started, state="+state;
log.error(msg);
serverErrors.add(msg);