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.ItemDestination;
18: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.LogUtils;
19: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.MqObjectNames;
20:
21: public class DestinationsAction extends JonasBaseAction {
22:
23: public ActionForward executeAction(ActionMapping mapping,
24: ActionForm form, HttpServletRequest request,
25: HttpServletResponse response) throws IOException,
26: ServletException {
27:
28: DestinationsForm fBean = (DestinationsForm) 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 "connector" 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 = ObjectNames.getConnectorON();
50: ObjectName mbName = MqObjectNames.getConnectorONByName(
51: domainName, connector);
52: Object[] params = {};
53: String[] signature = {};
54: String[] onDestinations = (String[]) JonasManagementRepr
55: .invoke(mbName, "listDestinationObjectNames",
56: params, signature, serverName);
57: ArrayList destinationsArray = new ArrayList();
58: for (int i = 0; i < onDestinations.length; i++) {
59: ObjectName onDest = new ObjectName(onDestinations[i]);
60: params = new Object[] {};
61: signature = new String[] {};
62: boolean isTopic = ((Boolean) JonasManagementRepr
63: .getAttribute(onDest, "IsTopic", serverName))
64: .booleanValue();
65:
66: String baseName = "";
67:
68: signature = new String[] { "java.lang.String" };
69: if (isTopic) {
70: baseName = (String) JonasManagementRepr.invoke(
71: onDest, "getProperty",
72: new Object[] { "BaseTopicName" },
73: signature, serverName);
74: } else {
75: baseName = (String) JonasManagementRepr.invoke(
76: onDest, "getProperty",
77: new Object[] { "BaseQueueName" },
78: signature, serverName);
79: }
80: String name = onDest.getKeyProperty("name");
81: ItemDestination item = new ItemDestination(name,
82: (isTopic) ? "topic" : "queue", baseName, onDest);
83: destinationsArray.add(item);
84: }
85:
86: m_Session.setAttribute("mqdestinations", destinationsArray);
87: } catch (Exception ex) {
88: LogUtils.print(ex.getMessage());
89: }
90: return mapping.findForward("JonasMqConnectDestinations");
91: }
92: }
|