001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.management.j2ee.statistics;
023:
024: import javax.management.j2ee.statistics.BoundedRangeStatistic;
025: import javax.management.j2ee.statistics.CountStatistic;
026: import javax.management.j2ee.statistics.JCAConnectionPoolStats;
027: import javax.management.j2ee.statistics.RangeStatistic;
028: import javax.management.j2ee.statistics.TimeStatistic;
029:
030: /**
031: * The JSR77.6.20 JCAConnectionPoolStats implementation
032: *
033: * @author Scott.Stark@jboss.org
034: * @version $Revision: 57197 $
035: */
036: public class JCAConnectionPoolStatsImpl extends JCAConnectionStatsImpl
037: implements JCAConnectionPoolStats {
038: // Constants -----------------------------------------------------
039:
040: /** @since 4.0.2 */
041: private static final long serialVersionUID = 6867747857618271195L;
042:
043: // Constructors --------------------------------------------------
044:
045: public JCAConnectionPoolStatsImpl(String cfName, String mcfName,
046: BoundedRangeStatistic freePoolSize,
047: BoundedRangeStatistic poolSize) {
048: this (cfName, mcfName, null, null, null, null, freePoolSize,
049: poolSize, null);
050: }
051:
052: public JCAConnectionPoolStatsImpl(String cfName, String mcfName,
053: TimeStatistic waitTime, TimeStatistic useTime,
054: CountStatistic closeCount, CountStatistic createCount,
055: BoundedRangeStatistic freePoolSize,
056: BoundedRangeStatistic poolSize,
057: RangeStatistic waitingThreadCount) {
058: super (cfName, mcfName, waitTime, useTime);
059: if (closeCount == null) {
060: closeCount = new CountStatisticImpl("CloseCount", "1",
061: "The number of connection closes");
062: }
063: if (createCount == null) {
064: createCount = new CountStatisticImpl("CreateCount", "1",
065: "The number of connection creates");
066: }
067: if (waitingThreadCount == null) {
068: waitingThreadCount = new RangeStatisticImpl(
069: "WaitingThreadCount", "1",
070: "The number of threads waiting for a connection");
071: }
072: super .addStatistic("CloseCount", closeCount);
073: super .addStatistic("CreateCount", createCount);
074: super .addStatistic("FreePoolSize", freePoolSize);
075: super .addStatistic("PoolSize", poolSize);
076: super .addStatistic("WaitingThreadCount", waitingThreadCount);
077: }
078:
079: public CountStatistic getCloseCount() {
080: CountStatistic cs = (CountStatistic) getStatistic("CloseCount");
081: return cs;
082: }
083:
084: public CountStatistic getCreateCount() {
085: CountStatistic cs = (CountStatistic) getStatistic("CreateCount");
086: return cs;
087: }
088:
089: public BoundedRangeStatistic getFreePoolSize() {
090: BoundedRangeStatistic brs = (BoundedRangeStatistic) getStatistic("FreePoolSize");
091: return brs;
092: }
093:
094: public BoundedRangeStatistic getPoolSize() {
095: BoundedRangeStatistic brs = (BoundedRangeStatistic) getStatistic("PoolSize");
096: return brs;
097: }
098:
099: public RangeStatistic getWaitingThreadCount() {
100: RangeStatistic rs = (RangeStatistic) getStatistic("WaitingThreadCount");
101: return rs;
102: }
103: }
|