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: EditTransactionMonitorAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.jtm;
027:
028: import java.io.IOException;
029: import java.util.ArrayList;
030:
031: import javax.management.ObjectName;
032: import javax.servlet.ServletException;
033: import javax.servlet.http.HttpServletRequest;
034: import javax.servlet.http.HttpServletResponse;
035:
036: import org.apache.struts.action.ActionForm;
037: import org.apache.struts.action.ActionForward;
038: import org.apache.struts.action.ActionMapping;
039: import org.objectweb.jonas.jmx.J2eeObjectName;
040: import org.objectweb.jonas.jmx.JonasManagementRepr;
041: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
042: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
043:
044: /**
045: * @author Tony Ortiz
046: */
047:
048: public class EditTransactionMonitorAction extends JonasBaseAction {
049:
050: // --------------------------------------------------------- Public Methods
051:
052: public ActionForward executeAction(ActionMapping pMapping,
053: ActionForm pForm, HttpServletRequest pRequest,
054: HttpServletResponse pResponse) throws IOException,
055: ServletException {
056:
057: // Force the node selected in tree
058: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
059: + WhereAreYou.NODE_SEPARATOR + "services"
060: + WhereAreYou.NODE_SEPARATOR + "transaction", true);
061:
062: // Form used
063: JtmServiceMonitorForm oForm = (JtmServiceMonitorForm) pForm;
064:
065: try {
066: // Get container list
067: String mys;
068: String sDate;
069: String sTransaction;
070: String sResource;
071: String sState;
072: String sXidcount;
073: Object txObject;
074: String[] myTxInfo;
075: int txInfoSize;
076: ArrayList al = new ArrayList();
077:
078: // Object name used
079: String currentDomainName = m_WhereAreYou
080: .getCurrentDomainName();
081: String currentJonasServerName = m_WhereAreYou
082: .getCurrentJonasServerName();
083: String jtaResourceName = "JTAResource";
084: ObjectName jtaResourceObjectName = J2eeObjectName
085: .JTAResource(currentDomainName,
086: currentJonasServerName, jtaResourceName);
087:
088: txObject = JonasManagementRepr.invoke(
089: jtaResourceObjectName, "getAllActiveTx", null,
090: null, currentJonasServerName);
091:
092: myTxInfo = (String[]) txObject;
093:
094: if (txObject != null) {
095: txInfoSize = myTxInfo.length;
096:
097: for (int i = 0; i < txInfoSize; i++) {
098: mys = myTxInfo[i];
099: int myix1 = mys.indexOf("????");
100: sDate = mys.substring(0, myix1);
101: int myix2 = mys.indexOf("????", myix1 + 4);
102: sTransaction = mys.substring(myix1 + 4, myix2);
103: int myix3 = mys.indexOf("????", myix2 + 4);
104: sResource = mys.substring(myix2 + 4, myix3);
105: sState = mys.substring(myix3 + 4);
106: al.add(new TxItem(sDate, sTransaction, sResource,
107: sState));
108: }
109: }
110:
111: // Set list in the request
112: pRequest.setAttribute("listTransactionsEntries", al);
113: } catch (Throwable t) {
114: addGlobalError(t);
115: saveErrors(pRequest, m_Errors);
116: return (pMapping.findForward("Global Error"));
117: }
118:
119: // Forward to the jsp.
120: return (pMapping.findForward("Jtm Monitor"));
121: }
122: }
|