try
{
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
InstanceOfQueryExp queryExp = null;
queryExp = new InstanceOfQueryExp("org.jboss.monitor.JBossMonitorMBean");
Set monitors = mbeanServer.queryNames(null, queryExp);
Iterator mbeans = monitors.iterator();
while (mbeans.hasNext())
{
ObjectName moname = (ObjectName) mbeans.next();
Object[] nullArgs = {};
String[] nullSig = {};
boolean alerted = ((Boolean) mbeanServer.invoke(moname, "alerted", nullArgs, nullSig)).booleanValue();
if (alerted)
{
mbeanServer.invoke(moname, "clearAlert", nullArgs, nullSig);
}
}
}
catch (Exception ex)
{
req.setAttribute("error", "Error clearing alerts: " + ex.toString());
}
req.getRequestDispatcher("/listMonitors.jsp").forward(req, resp);