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: ApplyDatasourceStatAction.java 5462 2004-09-20 12:57:34Z 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:
039: /**
040: * @author Adriana Danes
041: */
042:
043: public class ApplyDatasourceStatAction extends JonasBaseAction {
044:
045: // --------------------------------------------------------- Public Methods
046:
047: public ActionForward executeAction(ActionMapping p_Mapping,
048: ActionForm p_Form, HttpServletRequest p_Request,
049: HttpServletResponse p_Response) throws IOException,
050: ServletException {
051:
052: // Form used
053: DatasourceForm oForm = (DatasourceForm) p_Form;
054: try {
055: String domainName = m_WhereAreYou.getCurrentDomainName();
056: String serverName = m_WhereAreYou
057: .getCurrentJonasServerName();
058: populate(oForm, domainName, serverName);
059: } catch (Throwable t) {
060: addGlobalError(t);
061: saveErrors(p_Request, m_Errors);
062: return (p_Mapping.findForward("Global Error"));
063: }
064: // Forward to the jsp and add the parameter 'name' with the good value.
065: return new ActionForward(p_Mapping.findForward(
066: "ActionEditDatasourceStat").getPath()
067: + "?name=" + oForm.getDatasourceName());
068: }
069:
070: // --------------------------------------------------------- Protected Methods
071:
072: protected void populate(DatasourceForm p_Form, String domainName,
073: String serverName) throws Exception {
074: // Object name used
075: ObjectName oObjectName = J2eeObjectName.getJDBCDataSource(
076: domainName, serverName, p_Form.getDatasourceName());
077: // Populate
078: p_Form.setCurrentOpened(toStringIntegerAttribute(oObjectName,
079: "currentOpened"));
080: p_Form.setCurrentBusy(toStringIntegerAttribute(oObjectName,
081: "currentBusy"));
082: p_Form.setCurrentInTx(toStringIntegerAttribute(oObjectName,
083: "currentInTx"));
084: p_Form.setOpenedCount(toStringIntegerAttribute(oObjectName,
085: "openedCount"));
086: p_Form.setConnectionFailures(toStringIntegerAttribute(
087: oObjectName, "connectionFailures"));
088: p_Form.setConnectionLeaks(toStringIntegerAttribute(oObjectName,
089: "connectionLeaks"));
090: p_Form.setCurrentWaiters(toStringIntegerAttribute(oObjectName,
091: "currentWaiters"));
092: p_Form.setWaitersHigh(toStringIntegerAttribute(oObjectName,
093: "waitersHigh"));
094: p_Form.setWaitersHighRecent(toStringIntegerAttribute(
095: oObjectName, "waitersHighRecent"));
096: p_Form.setWaiterCount(toStringIntegerAttribute(oObjectName,
097: "waiterCount"));
098: p_Form.setWaitingTime(toStringLongAttribute(oObjectName,
099: "waitingTime"));
100: p_Form.setWaitingHigh(toStringLongAttribute(oObjectName,
101: "waitingHigh"));
102: p_Form.setWaitingHighRecent(toStringLongAttribute(oObjectName,
103: "waitingHighRecent"));
104: p_Form.setServedOpen(toStringIntegerAttribute(oObjectName,
105: "servedOpen"));
106: p_Form.setRejectedOpen(toStringIntegerAttribute(oObjectName,
107: "rejectedOpen"));
108: p_Form.setRejectedFull(toStringIntegerAttribute(oObjectName,
109: "rejectedFull"));
110: p_Form.setRejectedTimeout(toStringIntegerAttribute(oObjectName,
111: "rejectedTimeout"));
112: p_Form.setRejectedOther(toStringIntegerAttribute(oObjectName,
113: "rejectedOther"));
114: }
115:
116: }
|