EditTransactionMonitorAction.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: EditTransactionMonitorAction.java,v 1.1 2004/06/08 21:25:24 tonyortiz Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.service.jtm;
00027 
00028 import java.io.IOException;
00029 import java.util.ArrayList;
00030 import java.util.Date;
00031 import java.util.List;
00032 import java.util.Collections;
00033 import java.util.Iterator;
00034 
00035 import javax.management.ObjectName;
00036 import javax.servlet.ServletException;
00037 import javax.servlet.http.HttpServletRequest;
00038 import javax.servlet.http.HttpServletResponse;
00039 
00040 import org.apache.struts.action.ActionForm;
00041 import org.apache.struts.action.ActionForward;
00042 import org.apache.struts.action.ActionMapping;
00043 import org.objectweb.jonas.jmx.J2eeObjectName;
00044 import org.objectweb.jonas.jmx.JonasManagementRepr;
00045 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
00046 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
00047 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00048 
00053 public class EditTransactionMonitorAction extends JonasBaseAction {
00054 
00055 // --------------------------------------------------------- Public Methods
00056 
00057     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
00058         , HttpServletRequest pRequest, HttpServletResponse pResponse)
00059         throws IOException, ServletException {
00060 
00061         // Force the node selected in tree
00062         m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
00063             + "services" + WhereAreYou.NODE_SEPARATOR + "transaction", true);
00064 
00065         // Form used
00066         JtmServiceMonitorForm oForm = (JtmServiceMonitorForm) pForm;
00067 
00068         try {
00069             // Get container list
00070             String mys;
00071             String sDate;
00072             String sTransaction;
00073             String sResource;
00074             String sState;
00075             Object txObject;
00076             String [] myTxInfo;
00077             int    txInfoSize;
00078             ArrayList al = new ArrayList();
00079 
00080             // Object name used
00081             String currentDomainName = m_WhereAreYou.getCurrentDomainName();
00082             String currentJonasServerName = m_WhereAreYou.getCurrentJonasServerName();
00083             String jtaResourceName = "JTAResource";
00084             ObjectName jtaResourceObjectName = J2eeObjectName.JTAResource(currentDomainName, currentJonasServerName, jtaResourceName);
00085 
00086             txObject = JonasManagementRepr.invoke(jtaResourceObjectName, "getAllActiveTx", null, null);
00087 
00088             myTxInfo = (String []) txObject;
00089 
00090             if (txObject != null) {
00091                 txInfoSize = myTxInfo.length;
00092 
00093                 for (int i = 0; i < txInfoSize; i++) {
00094                     mys = myTxInfo[i];
00095                     int myix1 = mys.indexOf("????");
00096                     sDate = mys.substring(0, myix1);
00097                     int myix2 = mys.indexOf("????", myix1 + 4);
00098                     sTransaction = mys.substring(myix1 + 4, myix2);
00099                     int myix3 = mys.indexOf("????", myix2 + 4);
00100                     sResource = mys.substring(myix2 + 4, myix3);
00101                     sState = mys.substring(myix3 + 4);
00102                     al.add(new TxItem (sDate, sTransaction, sResource, sState));
00103                 }
00104              }
00105 
00106              // Set list in the request
00107              pRequest.setAttribute("listTransactionsEntries", al);
00108         }
00109         catch (Throwable t) {
00110             addGlobalError(t);
00111             saveErrors(pRequest, m_Errors);
00112             return (pMapping.findForward("Global Error"));
00113         }
00114 
00115         // Forward to the jsp.
00116         return (pMapping.findForward("Jtm Monitor"));
00117     }
00118 }

Generated on Tue Feb 15 15:05:33 2005 for JOnAS by  doxygen 1.3.9.1