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: * Jk cluster monitoring action
18: * @author Adriana.Danes@bull.net
19: */
20: public class JkClusterAction 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: "JkClusterAction: clust parameter is null."));
31: saveErrors(p_Request, m_Errors);
32: return (p_Mapping.findForward("Global Error"));
33: }
34: // cluster type
35: String type = "JkCluster";
36: // Form used
37: JkClusterForm oForm = (JkClusterForm) p_Form;
38: oForm.setName(name);
39: try {
40: ObjectName on = JonasObjectName.cluster(name, type);
41: String state = getStringAttribute(on, "State");
42: oForm.setState(state);
43: String[] workersList = getStringArrayAttribute(on,
44: "BalancedWorkers");
45: StringBuffer buf = new StringBuffer();
46: for (int i = 0; i < workersList.length; i++) {
47: if (i != 0) {
48: buf.append(',');
49: }
50: buf.append(workersList[i]);
51: }
52: oForm.setWorkers(new String(buf));
53: oForm.setStickySession(getBooleanAttribute(on,
54: "StickySession"));
55: } catch (Throwable t) {
56: addGlobalError(t);
57: saveErrors(p_Request, m_Errors);
58: return (p_Mapping.findForward("Global Error"));
59: }
60:
61: // Forward to the jsp.
62: return (p_Mapping.findForward("JkCluster"));
63: }
64: }
|