001: package org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect;
002:
003: import java.io.IOException;
004:
005: import javax.management.ObjectName;
006: import javax.servlet.ServletException;
007: import javax.servlet.http.HttpServletRequest;
008: import javax.servlet.http.HttpServletResponse;
009:
010: import org.apache.struts.action.ActionForm;
011: import org.apache.struts.action.ActionForward;
012: import org.apache.struts.action.ActionMapping;
013: import org.objectweb.jonas.jmx.JonasManagementRepr;
014: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
015: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
016: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.MqObjectNames;
017:
018: public class JonasMqConnectAction extends JonasBaseAction {
019:
020: public ActionForward executeAction(ActionMapping mapping,
021: ActionForm form, HttpServletRequest request,
022: HttpServletResponse response) throws IOException,
023: ServletException {
024:
025: JonasMqConnectForm fBean = (JonasMqConnectForm) form;
026: String connector = fBean.getConnector();
027: if (connector == null) {
028: connector = (String) m_Session.getAttribute("mqconnector");
029: } else {
030: m_Session.setAttribute("mqconnector", connector);
031: }
032: String operation = fBean.getOperation();
033: if (operation == null) {
034: operation = "view";
035: fBean.setOperation(operation);
036: }
037:
038: WhereAreYou oWhere = (WhereAreYou) request.getSession()
039: .getAttribute(WhereAreYou.SESSION_NAME);
040: String serverName = oWhere.getCurrentJonasServerName();
041: String domain = oWhere.getCurrentDomainName();
042:
043: //domain*jmq1*jonasmqconnect*jonasmqconnector*fwaMQJca
044: // Force the node selection in tree
045: String nodeName = "domain" + WhereAreYou.NODE_SEPARATOR
046: + serverName + WhereAreYou.NODE_SEPARATOR
047: + "jonasmqconnect" + WhereAreYou.NODE_SEPARATOR
048: + "jonasmqconnector" + WhereAreYou.NODE_SEPARATOR
049: + connector;
050: m_WhereAreYou.selectNameNode(nodeName, true);
051:
052: try {
053: ObjectName mbName = MqObjectNames.getConnectorONByName(
054: domain, connector);
055: if ("apply".equals(operation)) {
056: JonasManagementRepr.setAttribute(mbName, "HostName",
057: request.getParameter("hostname"), serverName);
058: JonasManagementRepr.setAttribute(mbName, "Channel",
059: request.getParameter("channel"), serverName);
060: JonasManagementRepr.setAttribute(mbName, "Port",
061: request.getParameter("port"), serverName);
062: JonasManagementRepr.setAttribute(mbName,
063: "QueueManager", request
064: .getParameter("queueManager"),
065: serverName);
066: JonasManagementRepr.setAttribute(mbName,
067: "TransportType", request
068: .getParameter("transportType"),
069: serverName);
070: }
071: if ("saveDestinationConfig".equals(operation)) {
072: Object[] params = {};
073: String[] signature = {};
074: JonasManagementRepr.invoke(mbName,
075: "saveDestinationConfig", params, signature,
076: serverName);
077: fBean.setOperation("view");
078: }
079: if ("loadDestinationConfig".equals(operation)) {
080: Object[] params = {};
081: String[] signature = {};
082: JonasManagementRepr.invoke(mbName,
083: "loadDestinationConfig", params, signature,
084: serverName);
085: fBean.setOperation("view");
086: }
087: if ("refresh".equals(operation)) {
088: Object[] params = {};
089: String[] signature = {};
090: JonasManagementRepr.invoke(mbName, "restartAdminQm",
091: params, signature, serverName);
092: fBean.setOperation("view");
093: }
094: String hostname = (String) JonasManagementRepr
095: .getAttribute(mbName, "HostName", serverName);
096: String channel = (String) JonasManagementRepr.getAttribute(
097: mbName, "Channel", serverName);
098: String port = (String) JonasManagementRepr.getAttribute(
099: mbName, "Port", serverName);
100: String queueManager = (String) JonasManagementRepr
101: .getAttribute(mbName, "QueueManager", serverName);
102: String transportType = (String) JonasManagementRepr
103: .getAttribute(mbName, "TransportType", serverName);
104: ((JonasMqConnectForm) form).setHostname(hostname);
105: ((JonasMqConnectForm) form).setChannel(channel);
106: ((JonasMqConnectForm) form).setPort(port);
107: ((JonasMqConnectForm) form).setQueueManager(queueManager);
108: ((JonasMqConnectForm) form).setTransportType(transportType);
109: } catch (Exception ex) {
110: ex.printStackTrace();
111: }
112: return mapping.findForward("JonasMqConnectStart");
113: }
114: }
|