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