001: package org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect;
002:
003: import java.io.IOException;
004: import java.util.ArrayList;
005: import java.util.Collections;
006:
007: import javax.management.ObjectName;
008: import javax.servlet.ServletException;
009: import javax.servlet.http.HttpServletRequest;
010: import javax.servlet.http.HttpServletResponse;
011:
012: import org.apache.struts.action.ActionForm;
013: import org.apache.struts.action.ActionForward;
014: import org.apache.struts.action.ActionMapping;
015: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
016: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
017: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.MqObjectNames;
018: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.PropertiesComparator;
019: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.PropertiesUtil;
020: import org.objectweb.jonas.webapp.jonasadmin.jonasmqconnect.util.Property;
021:
022: public class ConnectionFactoryEditAction extends JonasBaseAction {
023:
024: public ActionForward executeAction(ActionMapping mapping,
025: ActionForm form, HttpServletRequest request,
026: HttpServletResponse response) throws IOException,
027: ServletException {
028:
029: ConnectionFactoryEditForm fBean = (ConnectionFactoryEditForm) form;
030: String type = fBean.getType(); // CF,TCF,QCF
031: String operation = fBean.getOperation();
032: ArrayList properties = new ArrayList();
033:
034: WhereAreYou oWhere = (WhereAreYou) request.getSession()
035: .getAttribute(WhereAreYou.SESSION_NAME);
036: String serverName = oWhere.getCurrentJonasServerName();
037: String domainName = oWhere.getCurrentDomainName();
038:
039: /*
040: *
041: */
042: String connector = "jonasmq";
043: String currentConnector = request.getParameter("connector");
044: if (currentConnector != null) {
045: connector = currentConnector;
046:
047: } else {
048: currentConnector = (String) m_Session
049: .getAttribute("mqconnector");
050: if (currentConnector != null) {
051: connector = currentConnector;
052: }
053: }
054: m_Session.setAttribute("mqconnector", connector);
055: try {
056: //ObjectName mbName = ObjectNames.getConnectorON();
057: ObjectName mbName = MqObjectNames.getConnectorONByName(
058: domainName, connector);
059:
060: //Class cfClass = null;
061: String methodName = "";
062: if (type.equals("TCF")) {
063: /* FWA commented out
064: cfClass = Thread.currentThread().getClass().
065: forName("com.ibm.mq.jms.MQTopicConnectionFactory");
066: */
067: methodName = "getTcfProperty";
068: } else if (type.equals("QCF")) {
069: /* FWA commented out
070: cfClass = Thread.currentThread().getClass().
071: forName("com.ibm.mq.jms.MQQueueConnectionFactory");
072: */
073: methodName = "getQcfProperty";
074: } else {
075: /* FWA commented out
076: cfClass = Thread.currentThread().getClass().
077: forName("com.ibm.mq.jms.MQConnectionFactory");
078: */
079: methodName = "getCfProperty";
080: }
081: /*
082: * FWA BEGIN
083: */
084: String[] propertiesToSkip = new String[] { "Version",
085: "HostName", "Channel", "Port", "TransportType",
086: "QueueManager", "Reference", "Class", "ConnTag" };
087: properties = PropertiesUtil.getJMSObjectProperties(mbName,
088: type, methodName, propertiesToSkip, serverName,
089: domainName);
090:
091: /* FWA : commented out : properties = PropertiesUtil.getClassProperties(mbName, cfClass,
092: "get"+methodName, new String []{"Version", "HostName",
093: "Channel", "Port", "TransportType", "QueueManager"},serverName);
094: */
095: /*
096: * FWA END
097: */
098:
099: if ("apply".equals(operation)) {
100: for (int i = 0; i < properties.size(); i++) {
101: Property property = (Property) properties.get(i);
102: property.setValue(request.getParameter(property
103: .getName()));
104: }
105:
106: PropertiesUtil.setClassProperties(mbName, /* cfClass, */
107: "set" + methodName, properties, serverName);
108: properties = PropertiesUtil.getJMSObjectProperties(
109: mbName, type, methodName, propertiesToSkip,
110: serverName, domainName);
111: /* FWA commented out
112: properties = PropertiesUtil.getClassProperties(mbName, cfClass,
113: "get"+methodName, new String []{"Channel", "HostName",
114: "Port", "TransportType", "QueueManager", "Version"},
115: serverName);
116: */
117: }
118: Collections.sort(properties, new PropertiesComparator());
119: } catch (Throwable t) {
120: addGlobalError(t);
121: saveErrors(request, m_Errors);
122: return (mapping.findForward("Global Error"));
123: }
124: fBean.setProperties(properties);
125: return mapping
126: .findForward("JonasMqConnectConnectionFactoryEdit");
127: }
128: }
|