01: package org.objectweb.jonas.webapp.jonasadmin.monitoring;
02:
03: import java.io.IOException;
04: import java.util.Iterator;
05:
06: import javax.management.ObjectName;
07: import javax.servlet.ServletException;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10:
11: import org.apache.struts.action.ActionForm;
12: import org.apache.struts.action.ActionForward;
13: import org.apache.struts.action.ActionMapping;
14: import org.objectweb.jonas.jmx.JonasManagementRepr;
15: import org.objectweb.jonas.jmx.JonasObjectName;
16: import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
17: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
18: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
19:
20: public class JkMemberAction 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 member name from the 'member' parameter and cluster name from the 'clust' parameter
27: String name = p_Request.getParameter("member");
28: if (name == null) {
29: addGlobalError(new Exception(
30: "JkMemberAction: member parameter is null."));
31: saveErrors(p_Request, m_Errors);
32: return (p_Mapping.findForward("Global Error"));
33: }
34: String cluster = p_Request.getParameter("clust");
35: if (cluster == null) {
36: addGlobalError(new Exception(
37: "JkClusterAction: clust parameter is null."));
38: saveErrors(p_Request, m_Errors);
39: return (p_Mapping.findForward("Global Error"));
40: }
41: // Form used
42: JkMemberForm oForm = (JkMemberForm) p_Form;
43: oForm.setName(name);
44: // cluster type
45: String type = "JkCluster";
46: try {
47: ObjectName on = JonasObjectName.clusterMember(name, type,
48: cluster);
49: oForm.setHost(getStringAttribute(on, "Host"));
50: oForm.setState(getStringAttribute(on, "State"));
51: oForm.setLbfactor(getIntegerAttribute(on, "Lbfactor"));
52: oForm.setPort(getIntegerAttribute(on, "Port"));
53: oForm.setType(getStringAttribute(on, "Type"));
54: } catch (Throwable t) {
55: addGlobalError(t);
56: saveErrors(p_Request, m_Errors);
57: return (p_Mapping.findForward("Global Error"));
58: }
59:
60: // Forward to the jsp.
61: return (p_Mapping.findForward("JkMember"));
62: }
63: }
|