001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2004 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: EditDatasourceStatAction.java 5685 2004-10-27 12:35:02Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.service.db;
025:
026: import java.io.IOException;
027:
028: import javax.management.ObjectName;
029: import javax.servlet.ServletException;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import org.apache.struts.action.ActionForm;
034: import org.apache.struts.action.ActionForward;
035: import org.apache.struts.action.ActionMapping;
036: import org.objectweb.jonas.jmx.J2eeObjectName;
037: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
038: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
039:
040: /**
041: * @author Adriana Danes
042: */
043:
044: public class EditDatasourceStatAction extends JonasBaseAction {
045:
046: // --------------------------------------------------------- Public Methods
047:
048: public ActionForward executeAction(ActionMapping p_Mapping,
049: ActionForm p_Form, HttpServletRequest p_Request,
050: HttpServletResponse p_Response) throws IOException,
051: ServletException {
052:
053: // Datasource to edit
054: String sName = null;
055:
056: // Form used is already in session as we already executed one EditDatasource action
057: DatasourceForm oForm = (DatasourceForm) m_Session
058: .getAttribute("datasourceForm");
059:
060: if (oForm != null) {
061: sName = oForm.getDatasourceName();
062: } else {
063: return (p_Mapping.findForward("Global Error"));
064: }
065:
066: // Force the node selected in tree
067: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
068: + WhereAreYou.NODE_SEPARATOR + "services"
069: + WhereAreYou.NODE_SEPARATOR + "database"
070: + WhereAreYou.NODE_SEPARATOR + sName, true);
071:
072: // Populate
073: try {
074: if (sName != null) {
075: populate(oForm, m_WhereAreYou.getCurrentDomainName(),
076: m_WhereAreYou.getCurrentJonasServerName());
077: }
078: } catch (Throwable t) {
079: addGlobalError(t);
080: saveErrors(p_Request, m_Errors);
081: return (p_Mapping.findForward("Global Error"));
082: }
083: // Forward to the jsp.
084: return (p_Mapping.findForward("DatasourceStat"));
085: }
086:
087: // --------------------------------------------------------- Protected Methods
088:
089: protected void populate(DatasourceForm p_Form, String domainName,
090: String serverName) throws Exception {
091:
092: // ObjectName used for JDBCDataSource
093: ObjectName oObjectName = J2eeObjectName.getJDBCDataSource(
094: domainName, serverName, p_Form.getDatasourceName());
095:
096: p_Form.setCurrentOpened(toStringIntegerAttribute(oObjectName,
097: "currentOpened"));
098: p_Form.setCurrentBusy(toStringIntegerAttribute(oObjectName,
099: "currentBusy"));
100: p_Form.setBusyMaxRecent(toStringIntegerAttribute(oObjectName,
101: "busyMax"));
102: p_Form.setBusyMinRecent(toStringIntegerAttribute(oObjectName,
103: "busyMin"));
104: p_Form.setCurrentInTx(toStringIntegerAttribute(oObjectName,
105: "currentInTx"));
106: p_Form.setOpenedCount(toStringIntegerAttribute(oObjectName,
107: "openedCount"));
108: p_Form.setConnectionFailures(toStringIntegerAttribute(
109: oObjectName, "connectionFailures"));
110: p_Form.setConnectionLeaks(toStringIntegerAttribute(oObjectName,
111: "connectionLeaks"));
112: p_Form.setCurrentWaiters(toStringIntegerAttribute(oObjectName,
113: "currentWaiters"));
114: p_Form.setWaitersHigh(toStringIntegerAttribute(oObjectName,
115: "waitersHigh"));
116: p_Form.setWaitersHighRecent(toStringIntegerAttribute(
117: oObjectName, "waitersHighRecent"));
118: p_Form.setWaiterCount(toStringIntegerAttribute(oObjectName,
119: "waiterCount"));
120: p_Form.setWaitingTime(toStringLongAttribute(oObjectName,
121: "waitingTime"));
122: p_Form.setWaitingHigh(toStringLongAttribute(oObjectName,
123: "waitingHigh"));
124: p_Form.setWaitingHighRecent(toStringLongAttribute(oObjectName,
125: "waitingHighRecent"));
126: p_Form.setServedOpen(toStringIntegerAttribute(oObjectName,
127: "servedOpen"));
128: p_Form.setRejectedOpen(toStringIntegerAttribute(oObjectName,
129: "rejectedOpen"));
130: p_Form.setRejectedFull(toStringIntegerAttribute(oObjectName,
131: "rejectedFull"));
132: p_Form.setRejectedTimeout(toStringIntegerAttribute(oObjectName,
133: "rejectedTimeout"));
134: p_Form.setRejectedOther(toStringIntegerAttribute(oObjectName,
135: "rejectedOther"));
136: }
137: }
|