1 26 27 package org.objectweb.jonas.webapp.jonasadmin.service.jtm; 28 29 import java.io.IOException ; 30 import java.util.ArrayList ; 31 32 import javax.management.ObjectName ; 33 import javax.servlet.ServletException ; 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 37 import org.apache.struts.action.ActionForm; 38 import org.apache.struts.action.ActionForward; 39 import org.apache.struts.action.ActionMapping; 40 import org.objectweb.jonas.jmx.J2eeObjectName; 41 import org.objectweb.jonas.jmx.JonasManagementRepr; 42 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 43 44 47 48 public class ApplyConfirmXaResourceAction extends JonasBaseAction { 49 50 52 54 public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm, 55 HttpServletRequest pRequest, HttpServletResponse pResponse) 56 throws IOException , ServletException { 57 58 60 ItemsXaResourceForm oForm = (ItemsXaResourceForm) m_Session.getAttribute("itemsXaResourceForm"); 62 63 try { 65 Object txObject; 66 String [] asParam = new String [1]; 67 String [] asSignature = {"java.lang.String"}; 68 69 String currentDomainName = m_WhereAreYou.getCurrentDomainName(); 70 String currentJonasServerName = m_WhereAreYou.getCurrentJonasServerName(); 71 String jtaResourceName = "JTAResource"; 72 ObjectName jtaResourceObjectName = J2eeObjectName.JTAResource(currentDomainName, currentJonasServerName, jtaResourceName); 73 74 if (oForm.getAction().equals("commit") == true) { 76 for (int i = 0; i < oForm.getSelectedItems().length; i++) { 77 asParam[0] = oForm.getSelectedItems()[i]; 78 txObject = JonasManagementRepr.invoke(jtaResourceObjectName, "commitXAResource", asParam, asSignature); 79 } 80 } 81 else if (oForm.getAction().equals("rollback") == true) { 83 for (int i = 0; i < oForm.getSelectedItems().length; i++) { 84 asParam[0] = oForm.getSelectedItems()[i]; 85 txObject = JonasManagementRepr.invoke(jtaResourceObjectName, "rollbackXAResource", asParam, asSignature); 86 } 87 } 88 else if (oForm.getAction().equals("forget") == true) { 90 for (int i = 0; i < oForm.getSelectedItems().length; i++) { 91 asParam[0] = oForm.getSelectedItems()[i]; 92 txObject = JonasManagementRepr.invoke(jtaResourceObjectName, "forgetXAResource", asParam, asSignature); 93 } 94 } 95 } 96 catch (Throwable t) { 97 addGlobalError(t); 98 saveErrors(pRequest, m_Errors); 99 return (pMapping.findForward("Global Error")); 100 } 101 102 oForm.setAction(null); 103 oForm.setSelectedItems(new String [0]); 104 105 try { 106 String mys; 108 String sDate; 109 String sFullTrans; 110 String sTransaction; 111 String sResource; 112 String sState; 113 String sXidcount; 114 Object txObject; 115 String [] myTxInfo; 116 int txInfoSize; 117 ArrayList al = new ArrayList (); 118 119 String currentDomainName = m_WhereAreYou.getCurrentDomainName(); 121 String currentJonasServerName = m_WhereAreYou.getCurrentJonasServerName(); 122 String jtaResourceName = "JTAResource"; 123 ObjectName jtaResourceObjectName = J2eeObjectName.JTAResource(currentDomainName, currentJonasServerName, jtaResourceName); 124 125 txObject = JonasManagementRepr.invoke(jtaResourceObjectName, "getAllRecoveryTx", null, null); 126 myTxInfo = (String []) txObject; 127 128 if (txObject != null) { 129 txInfoSize = myTxInfo.length; 130 131 for (int i = 0; i < txInfoSize; i++) { 132 mys = myTxInfo[i]; 133 int myix1 = mys.indexOf("????"); 134 sFullTrans = mys.substring(0, myix1); 135 int myix2 = mys.indexOf("????", myix1 + 4); 136 sTransaction = mys.substring(myix1 + 4, myix2); 137 int myix3 = mys.indexOf("????", myix2 + 4); 138 sDate = mys.substring(myix2 + 4, myix3); 139 sXidcount = mys.substring(myix3 + 4); 140 al.add(new TxRecovery (sFullTrans, sTransaction, sDate, sXidcount)); 141 } 142 } 143 144 pRequest.setAttribute("listRecoveryEntries", al); 146 } catch (Throwable t) { 147 addGlobalError(t); 148 saveErrors(pRequest, m_Errors); 149 return (pMapping.findForward("Global Error")); 150 } 151 152 return (pMapping.findForward("Jtm Recovery")); 154 } 155 156 158 } 159 | Popular Tags |