EditDatasourceStatAction.java

00001 
00026 package org.objectweb.jonas.webapp.jonasadmin.service.db;
00027 
00028 import java.io.IOException;
00029 
00030 import javax.management.ObjectName;
00031 import javax.servlet.ServletException;
00032 import javax.servlet.http.HttpServletRequest;
00033 import javax.servlet.http.HttpServletResponse;
00034 
00035 import org.apache.struts.action.ActionForm;
00036 import org.apache.struts.action.ActionForward;
00037 import org.apache.struts.action.ActionMapping;
00038 import org.objectweb.jonas.jmx.J2eeObjectName;
00039 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
00040 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00041 
00046 public class EditDatasourceStatAction extends JonasBaseAction {
00047 
00048 // --------------------------------------------------------- Public Methods
00049 
00050     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00051         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00052         throws IOException, ServletException {
00053 
00054         // Datasource to edit
00055         String sName = null;
00056 
00057         // Form used is already in session as we already executed one EditDatasource action
00058         DatasourceForm oForm = (DatasourceForm) m_Session.getAttribute("datasourceForm");
00059 
00060         if (oForm != null) {
00061             sName = oForm.getDatasourceName();
00062         } else {
00063             return (p_Mapping.findForward("Global Error"));
00064         }
00065 
00066         // Force the node selected in tree
00067         m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
00068             + "services" + WhereAreYou.NODE_SEPARATOR + "database" + WhereAreYou.NODE_SEPARATOR
00069             + sName, true);
00070 
00071         // Populate
00072         try {
00073             if (sName != null) {
00074                 populate(oForm, m_WhereAreYou.getCurrentDomainName(), m_WhereAreYou.getCurrentJonasServerName());
00075             }
00076         } catch (Throwable t) {
00077             addGlobalError(t);
00078             saveErrors(p_Request, m_Errors);
00079             return (p_Mapping.findForward("Global Error"));
00080         }
00081         // Forward to the jsp.
00082         return (p_Mapping.findForward("DatasourceStat"));
00083     }
00084 
00085 // --------------------------------------------------------- Protected Methods
00086 
00087     protected void populate(DatasourceForm p_Form, String domainName, String serverName)
00088         throws Exception {
00089 
00090         // ObjectName used for JDBCDataSource
00091         ObjectName oObjectName = J2eeObjectName.getJDBCDataSource(domainName, serverName, p_Form.getDatasourceName());
00092         
00093         p_Form.setCurrentOpened(toStringIntegerAttribute(oObjectName, "currentOpened"));
00094         p_Form.setCurrentBusy(toStringIntegerAttribute(oObjectName, "currentBusy"));
00095         p_Form.setBusyMaxRecent(toStringIntegerAttribute(oObjectName, "busyMax"));
00096         p_Form.setBusyMinRecent(toStringIntegerAttribute(oObjectName, "busyMin"));
00097         p_Form.setCurrentInTx(toStringIntegerAttribute(oObjectName, "currentInTx"));
00098         p_Form.setOpenedCount(toStringIntegerAttribute(oObjectName, "openedCount"));
00099         p_Form.setConnectionFailures(toStringIntegerAttribute(oObjectName, "connectionFailures"));
00100         p_Form.setConnectionLeaks(toStringIntegerAttribute(oObjectName, "connectionLeaks"));
00101         p_Form.setCurrentWaiters(toStringIntegerAttribute(oObjectName, "currentWaiters"));
00102         p_Form.setWaitersHigh(toStringIntegerAttribute(oObjectName, "waitersHigh"));
00103         p_Form.setWaitersHighRecent(toStringIntegerAttribute(oObjectName, "waitersHighRecent"));
00104         p_Form.setWaiterCount(toStringIntegerAttribute(oObjectName, "waiterCount"));
00105         p_Form.setWaitingTime(toStringLongAttribute(oObjectName, "waitingTime"));
00106         p_Form.setWaitingHigh(toStringLongAttribute(oObjectName, "waitingHigh"));
00107         p_Form.setWaitingHighRecent(toStringLongAttribute(oObjectName, "waitingHighRecent"));
00108         p_Form.setServedOpen(toStringIntegerAttribute(oObjectName, "servedOpen"));
00109         p_Form.setRejectedOpen(toStringIntegerAttribute(oObjectName, "rejectedOpen"));
00110         p_Form.setRejectedFull(toStringIntegerAttribute(oObjectName, "rejectedFull"));
00111         p_Form.setRejectedTimeout(toStringIntegerAttribute(oObjectName, "rejectedTimeout"));
00112         p_Form.setRejectedOther(toStringIntegerAttribute(oObjectName, "rejectedOther"));
00113     }
00114 }

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