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: ListXaResourceAction.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 ListXaResourceAction extends JonasBaseAction {
049:
050: private String myasparam = null;
051:
052: // --------------------------------------------------------- Public Methods
053:
054: public ActionForward executeAction(ActionMapping pMapping,
055: ActionForm pForm, HttpServletRequest pRequest,
056: HttpServletResponse pResponse) throws IOException,
057: ServletException {
058:
059: // Reset the selected items in case the user is flip-flopping
060: // between tabs on jsp pages
061: try {
062: ItemsXaResourceForm xForm = (ItemsXaResourceForm) m_Session
063: .getAttribute("itemsXaResourceForm");
064: xForm.setAction(null);
065: xForm.setSelectedItems(new String[0]);
066: } catch (Exception e) {
067: // ignore, we may not have yet invoked ItemxXaResourceForm
068: ;
069: }
070:
071: // Force the node selected in tree
072: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
073: + WhereAreYou.NODE_SEPARATOR + "services"
074: + WhereAreYou.NODE_SEPARATOR + "transaction", true);
075:
076: // Form used
077: JtmServiceXAResourceForm oForm = (JtmServiceXAResourceForm) pForm;
078:
079: try {
080: // Get container list
081: String[] asParam = new String[1];
082: String[] asSignature = { "java.lang.String" };
083: String mys;
084: String sResmgr;
085: String sResource;
086: String sFullXid;
087: String sXid;
088: String sXidstate;
089: String sXidcount;
090: Object txObject;
091: String[] myTxInfo;
092: int txInfoSize;
093: ArrayList al = new ArrayList();
094:
095: // transaction to edit
096: String sName = pRequest.getParameter("fulltrans");
097:
098: if (sName == null) {
099: sName = myasparam;
100: } else {
101: myasparam = sName;
102: }
103:
104: asParam[0] = sName;
105:
106: // Object name used
107: String currentDomainName = m_WhereAreYou
108: .getCurrentDomainName();
109: String currentJonasServerName = m_WhereAreYou
110: .getCurrentJonasServerName();
111: String jtaResourceName = "JTAResource";
112: ObjectName jtaResourceObjectName = J2eeObjectName
113: .JTAResource(currentDomainName,
114: currentJonasServerName, jtaResourceName);
115:
116: txObject = JonasManagementRepr.invoke(
117: jtaResourceObjectName, "getAllXAResource", asParam,
118: asSignature, currentJonasServerName);
119:
120: myTxInfo = (String[]) txObject;
121:
122: if (txObject != null) {
123: txInfoSize = myTxInfo.length;
124:
125: for (int i = 0; i < txInfoSize; i++) {
126: mys = myTxInfo[i];
127: int myix1 = mys.indexOf("????");
128: sResmgr = mys.substring(0, myix1);
129: int myix2 = mys.indexOf("????", myix1 + 4);
130: sResource = mys.substring(myix1 + 4, myix2);
131: int myix3 = mys.indexOf("????", myix2 + 4);
132: sFullXid = mys.substring(myix2 + 4, myix3);
133: int myix4 = mys.indexOf("????", myix3 + 4);
134: sXid = mys.substring(myix3 + 4, myix4);
135: sXidstate = mys.substring(myix4 + 4);
136: al.add(new TxXaresource(null, sResmgr, sResource,
137: sFullXid, sXid, sXidstate));
138: }
139: }
140:
141: // Set list in the request
142: pRequest.setAttribute("listXaResourceEntries", al);
143: } catch (Throwable t) {
144: addGlobalError(t);
145: saveErrors(pRequest, m_Errors);
146: return (pMapping.findForward("Global Error"));
147: }
148:
149: // Forward to the jsp.
150: return (pMapping.findForward("Jtm XAResource"));
151: }
152: }
|