1 22 package org.jboss.console.plugins.monitor; 23 24 import java.io.IOException ; 25 26 import javax.management.MBeanServer ; 27 import javax.management.ObjectName ; 28 import javax.servlet.ServletException ; 29 import javax.servlet.http.HttpServlet ; 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 33 import org.jboss.monitor.services.ActiveAlarmTableMBean; 34 import org.jboss.mx.util.MBeanServerLocator; 35 36 40 public class AcknowledgeActiveAlarmsServlet extends HttpServlet 41 { 42 protected void doGet(HttpServletRequest req, HttpServletResponse resp) 43 throws ServletException , IOException 44 { 45 doit(req, resp); 46 } 47 48 protected void doPost(HttpServletRequest req, HttpServletResponse resp) 49 throws ServletException , IOException 50 { 51 doit(req, resp); 52 } 53 54 protected void doit(HttpServletRequest req, HttpServletResponse resp) 55 throws ServletException , IOException 56 { 57 try 58 { 59 MBeanServer server = MBeanServerLocator.locateJBoss(); 60 ObjectName target = ActiveAlarmTableMBean.OBJECT_NAME; 61 62 String system = (String )server.getAttribute(target, "ServerId"); 64 String user = System.getProperty("user.name"); 66 67 String alarmId = req.getParameter("alarmId").trim(); 68 69 if (alarmId.equals("*")) 70 { 71 server.invoke( 72 target, 73 "acknowledgeAll", 74 new Object [] { user, system }, 75 new String [] { "java.lang.String", "java.lang.String" }); 76 } 77 else 78 { 79 server.invoke( 80 target, 81 "acknowledge", 82 new Object [] { alarmId, user, system }, 83 new String [] { "java.lang.String", "java.lang.String", "java.lang.String" }); 84 } 85 } 86 catch (Exception ex) 87 { 88 req.setAttribute("error", "Error acknowledging alarms: " + ex.toString()); 89 } 90 req.getRequestDispatcher("/listActiveAlarmTable.jsp").forward(req, resp); 91 } 92 93 } 94 | Popular Tags |