KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > service > jtm > ListXaResourceAction


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: ListXaResourceAction.java,v 1.1 2005/03/30 17:06:46 tonyortiz Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.service.jtm;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30
31 import javax.management.ObjectName JavaDoc;
32 import javax.servlet.ServletException JavaDoc;
33 import javax.servlet.http.HttpServletRequest JavaDoc;
34 import javax.servlet.http.HttpServletResponse JavaDoc;
35
36 import org.apache.struts.action.ActionForm;
37 import org.apache.struts.action.ActionForward;
38 import org.apache.struts.action.ActionMapping;
39 import org.objectweb.jonas.jmx.J2eeObjectName;
40 import org.objectweb.jonas.jmx.JonasManagementRepr;
41 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
42 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
43
44 /**
45  * @author Tony Ortiz
46  */

47
48 public class ListXaResourceAction extends JonasBaseAction {
49     
50     private String JavaDoc myasparam = null;
51
52 // --------------------------------------------------------- Public Methods
53

54     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
55         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
56         throws IOException JavaDoc, ServletException JavaDoc {
57         
58         // Reset the selected items in case the user is flip-flopping
59
// between tabs on jsp pages
60
try {
61             ItemsXaResourceForm xForm = (ItemsXaResourceForm) m_Session.getAttribute("itemsXaResourceForm");
62             xForm.setAction(null);
63             xForm.setSelectedItems(new String JavaDoc[0]);
64         } catch (Exception JavaDoc e) {
65             // ignore, we may not have yet invoked ItemxXaResourceForm
66
;
67         }
68
69         // Force the node selected in tree
70
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
71             + "services" + WhereAreYou.NODE_SEPARATOR + "transaction", true);
72         
73         // Form used
74
JtmServiceXAResourceForm oForm = (JtmServiceXAResourceForm) pForm;
75
76         try {
77             // Get container list
78
String JavaDoc[] asParam = new String JavaDoc[1];
79             String JavaDoc[] asSignature = {"java.lang.String"};
80             String JavaDoc mys;
81             String JavaDoc sResmgr;
82             String JavaDoc sResource;
83             String JavaDoc sFullXid;
84             String JavaDoc sXid;
85             String JavaDoc sXidstate;
86             String JavaDoc sXidcount;
87             Object JavaDoc txObject;
88             String JavaDoc [] myTxInfo;
89             int txInfoSize;
90             ArrayList JavaDoc al = new ArrayList JavaDoc();
91             
92             // transaction to edit
93
String JavaDoc sName = pRequest.getParameter("fulltrans");
94             
95             if (sName == null) {
96                  sName = myasparam;
97             } else {
98                  myasparam = sName;
99             }
100             
101             asParam[0] = sName;
102             
103             // Object name used
104
String JavaDoc currentDomainName = m_WhereAreYou.getCurrentDomainName();
105             String JavaDoc currentJonasServerName = m_WhereAreYou.getCurrentJonasServerName();
106             String JavaDoc jtaResourceName = "JTAResource";
107             ObjectName JavaDoc jtaResourceObjectName = J2eeObjectName.JTAResource(currentDomainName, currentJonasServerName, jtaResourceName);
108
109             txObject = JonasManagementRepr.invoke(jtaResourceObjectName, "getAllXAResource", asParam, asSignature);
110
111             myTxInfo = (String JavaDoc []) txObject;
112
113             if (txObject != null) {
114                 txInfoSize = myTxInfo.length;
115
116                 for (int i = 0; i < txInfoSize; i++) {
117                     mys = myTxInfo[i];
118                     int myix1 = mys.indexOf("????");
119                     sResmgr = mys.substring(0, myix1);
120                     int myix2 = mys.indexOf("????", myix1 + 4);
121                     sResource = mys.substring(myix1 + 4, myix2);
122                     int myix3 = mys.indexOf("????", myix2 + 4);
123                     sFullXid = mys.substring(myix2 + 4, myix3);
124                     int myix4 = mys.indexOf("????", myix3 + 4);
125                     sXid = mys.substring(myix3 + 4, myix4);
126                     sXidstate = mys.substring(myix4 + 4);
127                     al.add(new TxXaresource (null, sResmgr, sResource, sFullXid, sXid, sXidstate));
128                 }
129              }
130
131              // Set list in the request
132
pRequest.setAttribute("listXaResourceEntries", al);
133         }
134         catch (Throwable JavaDoc t) {
135             addGlobalError(t);
136             saveErrors(pRequest, m_Errors);
137             return (pMapping.findForward("Global Error"));
138         }
139
140         // Forward to the jsp.
141
return (pMapping.findForward("Jtm XAResource"));
142     }
143 }
144
Popular Tags