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: * Ligical cluster monitoring action
19: * @author Adriana.Danes@bull.net
20: */
21: public class LogicalClusterAction 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:
28: // Current server
29: String serverName = m_WhereAreYou.getCurrentJonasServerName();
30:
31: // Get cluster name from the 'clust' parameter
32: String name = p_Request.getParameter("clust");
33: if (name == null) {
34: addGlobalError(new Exception(
35: "LogicalClusterAction: clust parameter is null."));
36: saveErrors(p_Request, m_Errors);
37: return (p_Mapping.findForward("Global Error"));
38: }
39: // cluster type
40: String type = "LogicalCluster";
41: // Form used
42: LogicalClusterForm oForm = (LogicalClusterForm) p_Form;
43: oForm.setName(name);
44: try {
45: ObjectName on = JonasObjectName.cluster(name, type);
46: String state = (String) JonasManagementRepr.getAttribute(
47: on, "State", serverName);
48: oForm.setState(state);
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("LogicalCluster"));
57: }
58: }
|