01: package org.objectweb.jonas.webapp.jonasadmin.monitoring;
02:
03: import java.io.IOException;
04:
05: import javax.management.ObjectName;
06: import javax.servlet.ServletException;
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: import org.apache.struts.action.ActionForm;
11: import org.apache.struts.action.ActionForward;
12: import org.apache.struts.action.ActionMapping;
13: import org.objectweb.jonas.jmx.JonasManagementRepr;
14: import org.objectweb.jonas.jmx.JonasObjectName;
15: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
16:
17: /**
18: * Joram cluster monitoring action
19: * @author Adriana.Danes@bull.net
20: */
21: public class JoramClusterAction extends JonasBaseAction {
22:
23: public ActionForward executeAction(ActionMapping p_Mapping,
24: ActionForm p_Form, HttpServletRequest p_Request,
25: HttpServletResponse p_Response) throws IOException,
26: ServletException {
27: // Current server
28: String serverName = m_WhereAreYou.getCurrentJonasServerName();
29:
30: // Get cluster name from the 'clust' parameter
31: String name = p_Request.getParameter("clust");
32: if (name == null) {
33: addGlobalError(new Exception(
34: "JoramClusterAction: clust parameter is null."));
35: saveErrors(p_Request, m_Errors);
36: return (p_Mapping.findForward("Global Error"));
37: }
38: // cluster type
39: String type = "JoramCluster";
40: // Form used
41: JoramClusterForm oForm = (JoramClusterForm) p_Form;
42: oForm.setName(name);
43: try {
44: ObjectName on = JonasObjectName.cluster(name, type);
45: String state = (String) JonasManagementRepr.getAttribute(
46: on, "State", serverName);
47: oForm.setState(state);
48:
49: } catch (Throwable t) {
50: addGlobalError(t);
51: saveErrors(p_Request, m_Errors);
52: return (p_Mapping.findForward("Global Error"));
53: }
54:
55: // Forward to the jsp.
56: return (p_Mapping.findForward("JoramCluster"));
57: }
58: }
|