}
@Override
public void preDispatch(Set<MBeanServer> pMBeanServers, JmxRequest pJmxReq) {
if (pJmxReq instanceof JmxObjectNameRequest) {
JmxObjectNameRequest request = (JmxObjectNameRequest) pJmxReq;
if (request.getObjectName() != null &&
"java.lang".equals(request.getObjectName().getDomain())) {
try {
// invoking getMBeanInfo() works around a bug in getAttribute() that fails to
// refetch the domains from the platform (JDK) bean server (e.g. for MXMBeans)
for (MBeanServer s : pMBeanServers) {
try {
s.getMBeanInfo(request.getObjectName());
return;
} catch (InstanceNotFoundException exp) {
// Only one server can have the name. So, this exception
// is being expected to happen
}
}
} catch (IntrospectionException e) {
throw new IllegalStateException("Workaround for JBoss failed for object " + request.getObjectName() + ": " + e);
} catch (ReflectionException e) {
throw new IllegalStateException("Workaround for JBoss failed for object " + request.getObjectName() + ": " + e);
}
}
}
}