001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: EditJtmServiceAction.java 5818 2004-11-30 09:16:51Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.service.jtm;
025:
026: import java.io.IOException;
027:
028: import javax.management.ObjectName;
029: import javax.servlet.ServletException;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import org.apache.struts.action.ActionForm;
034: import org.apache.struts.action.ActionForward;
035: import org.apache.struts.action.ActionMapping;
036: import org.objectweb.jonas.jmx.J2eeObjectName;
037: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
038: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
039: import org.objectweb.jonas.webapp.jonasadmin.catalina.ConnectorForm;
040:
041: /**
042: * Principal action for JTM service management.
043: * @author Adriana Danes
044: */
045: public class EditJtmServiceAction extends JonasBaseAction {
046:
047: /**
048: * Principal method
049: * @param pMapping action mapping
050: * @param pForm used form
051: * @param pRequest request parameters
052: * @param pResponse response parameters
053: * @return action forward
054: * @throws IOException action failed because a IOException
055: * @throws ServletException a ServletException occured
056: */
057: public ActionForward executeAction(ActionMapping pMapping,
058: ActionForm pForm, HttpServletRequest pRequest,
059: HttpServletResponse pResponse) throws IOException,
060: ServletException {
061:
062: // Force the node selected in tree
063: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
064: + WhereAreYou.NODE_SEPARATOR + "services"
065: + WhereAreYou.NODE_SEPARATOR + "transaction", true);
066:
067: // Form used
068: JtmServiceForm oForm = new JtmServiceForm();
069: m_Session.setAttribute("jtmServiceForm", oForm);
070: try {
071: // Object name used
072: String currentDomainName = m_WhereAreYou
073: .getCurrentDomainName();
074: String currentJonasServerName = m_WhereAreYou
075: .getCurrentJonasServerName();
076: String jtaResourceName = "JTAResource";
077: ObjectName jtaResourceObjectName = J2eeObjectName
078: .JTAResource(currentDomainName,
079: currentJonasServerName, jtaResourceName);
080:
081: String location;
082: boolean collocated = getBooleanAttribute(
083: jtaResourceObjectName, "localJtm");
084: if (collocated) {
085: // Collacated JTM
086: location = m_Resources.getMessage("tab.jtm.collocated");
087: oForm.setJtmLocation(location);
088: } else {
089: // Distant MOM
090: location = m_Resources.getMessage("tab.jtm.distant");
091: oForm.setJtmLocation(location);
092: }
093:
094: String host = getStringAttribute(jtaResourceObjectName,
095: "hostName");
096: oForm.setJtmHost(host);
097:
098: int port = getIntegerAttribute(jtaResourceObjectName,
099: "portNumber");
100: String portValue = null;
101: if (port == 0) {
102: // Undefined value
103: portValue = m_Resources.getMessage("tab.jtm.undefined");
104: oForm.setJtmPort(portValue);
105: } else {
106: oForm.setJtmPort(Integer.toString(port));
107: }
108:
109: int timeOut = getIntegerAttribute(jtaResourceObjectName,
110: "timeOut");
111: oForm.setTimeOutText(String.valueOf(timeOut));
112: } catch (Throwable t) {
113: addGlobalError(t);
114: saveErrors(pRequest, m_Errors);
115: return (pMapping.findForward("Global Error"));
116: }
117:
118: // Forward to the jsp.
119: return (pMapping.findForward("Jtm Service"));
120: }
121:
122: }
|