01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.management.j2ee.statistics;
23:
24: import org.jboss.management.j2ee.StatisticsConstants;
25:
26: import javax.management.j2ee.statistics.JCAConnectionStats;
27: import javax.management.j2ee.statistics.TimeStatistic;
28:
29: /**
30: * @author Scott.Stark@jboss.org
31: * @version $Revision: 57197 $
32: */
33: public class JCAConnectionStatsImpl extends StatsBase implements
34: JCAConnectionStats {
35: // Constants -----------------------------------------------------
36:
37: /** @since 4.0.2 */
38: private static final long serialVersionUID = -5409299496765142153L;
39:
40: // Private Data --------------------------------------------------
41:
42: private String cfName;
43: private String mcfName;
44:
45: // Constructors --------------------------------------------------
46:
47: public JCAConnectionStatsImpl(String cfName, String mcfName) {
48: this (cfName, mcfName, null, null);
49: }
50:
51: public JCAConnectionStatsImpl(String cfName, String mcfName,
52: TimeStatistic waitTime, TimeStatistic useTime) {
53: if (waitTime == null) {
54: waitTime = new TimeStatisticImpl("WaitTime",
55: StatisticsConstants.MILLISECOND,
56: "Time spent waiting for a connection to be available");
57: }
58: if (useTime == null) {
59: useTime = new TimeStatisticImpl("UseTime",
60: StatisticsConstants.MILLISECOND,
61: "Time spent using the connection");
62: }
63: super .addStatistic("WaitTime", waitTime);
64: super .addStatistic("UseTime", useTime);
65: this .cfName = cfName;
66: this .mcfName = mcfName;
67: }
68:
69: public String getConnectionFactory() {
70: return cfName;
71: }
72:
73: public String getManagedConnectionFactory() {
74: return mcfName;
75: }
76:
77: public TimeStatistic getWaitTime() {
78: TimeStatistic ts = (TimeStatistic) getStatistic("WaitTime");
79: return ts;
80: }
81:
82: public TimeStatistic getUseTime() {
83: TimeStatistic ts = (TimeStatistic) getStatistic("UseTime");
84: return ts;
85: }
86: }
|