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.JonasObjectName;
14: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
15:
16: /**
17: * Tomcat cluster monitoring action
18: * @author Adriana.Danes@bull.net
19: */
20: public class TomcatClusterAction extends JonasBaseAction {
21:
22: public ActionForward executeAction(ActionMapping p_Mapping,
23: ActionForm p_Form, HttpServletRequest p_Request,
24: HttpServletResponse p_Response) throws IOException,
25: ServletException {
26: // Get cluster name from the 'clust' parameter
27: String name = p_Request.getParameter("clust");
28: if (name == null) {
29: addGlobalError(new Exception(
30: "TomcatClusterAction: clust parameter is null."));
31: saveErrors(p_Request, m_Errors);
32: return (p_Mapping.findForward("Global Error"));
33: }
34: // cluster type
35: String type = "TomcatCluster";
36: // Form used
37: TomcatClusterForm oForm = (TomcatClusterForm) p_Form;
38: oForm.setName(name);
39: try {
40: ObjectName on = JonasObjectName.cluster(name, type);
41: oForm.setState(getStringAttribute(on, "State"));
42: // Set specific parameters
43: oForm.setMcastAddr(getStringAttribute(on, "McastAddr"));
44: oForm
45: .setMcastDropTime(getLongAttribute(on,
46: "McastDropTime"));
47: oForm.setMcastFrequency(getLongAttribute(on,
48: "McastFrequency"));
49: oForm.setMcastPort(getIntegerAttribute(on, "McastPort"));
50: oForm.setMcastSocketTimeout(getIntegerAttribute(on,
51: "McastSocketTimeout"));
52: } catch (Throwable t) {
53: addGlobalError(t);
54: saveErrors(p_Request, m_Errors);
55: return (p_Mapping.findForward("Global Error"));
56: }
57:
58: // Forward to the jsp.
59: return (p_Mapping.findForward("TomcatCluster"));
60: }
61: }
|