01: package org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect;
02:
03: import java.io.IOException;
04: import java.util.ArrayList;
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.webapp.jonasadmin.JonasBaseAction;
16: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
17: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.ItemMdb;
18: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.LogUtils;
19: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.MqObjectNames;
20:
21: public class MdbsAction extends JonasBaseAction {
22:
23: public ActionForward executeAction(ActionMapping mapping,
24: ActionForm form, HttpServletRequest request,
25: HttpServletResponse response) throws IOException,
26: ServletException {
27:
28: MdbsForm fBean = (MdbsForm) form;
29: WhereAreYou oWhere = (WhereAreYou) request.getSession()
30: .getAttribute(WhereAreYou.SESSION_NAME);
31: String serverName = oWhere.getCurrentJonasServerName();
32: String domainName = oWhere.getCurrentDomainName();
33:
34: /*
35: * The "mqconnector" session attribute should be set
36: */
37: String connector = (String) m_Session
38: .getAttribute("mqconnector");
39: //domain*jmq1*jonasmqconnect*jonasmqconnector*fwaMQJca
40: // Force the node selection in tree
41: String nodeName = "domain" + WhereAreYou.NODE_SEPARATOR
42: + serverName + WhereAreYou.NODE_SEPARATOR
43: + "jonasmqconnect" + WhereAreYou.NODE_SEPARATOR
44: + "jonasmqconnector" + WhereAreYou.NODE_SEPARATOR
45: + connector;
46: m_WhereAreYou.selectNameNode(nodeName, true);
47:
48: try {
49: ObjectName mbName = MqObjectNames.getConnectorONByName(
50: domainName, connector);
51: Object[] params = {};
52: String[] signature = {};
53: String[] onMdbs = (String[]) JonasManagementRepr.invoke(
54: mbName, "listConsumerObjectNames", params,
55: signature, serverName);
56: ArrayList mdbsArray = new ArrayList();
57: for (int i = 0; i < onMdbs.length; i++) {
58: ObjectName on = new ObjectName(onMdbs[i]);
59: int numberMsg = ((Integer) JonasManagementRepr
60: .getAttribute(on, "NumberOfReceivedMessages",
61: serverName)).intValue();
62:
63: String name = on.getKeyProperty("name");
64: String mqDest = on.getKeyProperty("MQDestination");
65: ItemMdb item = new ItemMdb(name, onMdbs[i], mqDest,
66: numberMsg);
67: mdbsArray.add(item);
68: }
69:
70: m_Session.setAttribute("mqmdbs", mdbsArray);
71: } catch (Exception ex) {
72: LogUtils.print(ex.getMessage());
73: }
74: return mapping.findForward("JonasMqConnectMdbs");
75: }
76: }
|