001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.management.stats;
018    
019    import javax.management.j2ee.statistics.CountStatistic;
020    import javax.management.j2ee.statistics.JMSConsumerStats;
021    import javax.management.j2ee.statistics.JMSProducerStats;
022    import javax.management.j2ee.statistics.JMSSessionStats;
023    import javax.management.j2ee.statistics.TimeStatistic;
024    
025    /**
026     * Geronimo implementation of the JSR-77 JMSSessionStats interface.
027     * 
028     * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
029     */
030    public class JMSSessionStatsImpl extends StatsImpl implements JMSSessionStats {
031        private JMSProducerStats[] producersStats;
032    
033        private JMSConsumerStats[] consumersStats;
034    
035        private final CountStatisticImpl messageCount;
036    
037        private final CountStatisticImpl pendingMessageCount;
038    
039        private final CountStatisticImpl expiredMessageCount;
040    
041        private final CountStatisticImpl durableSubscriptionCount;
042    
043        private final TimeStatisticImpl messageWaitTime;
044    
045        public JMSSessionStatsImpl() {
046            messageCount = new CountStatisticImpl("Message Count",
047                    StatisticImpl.UNIT_COUNT, "Number of messages exchanged");
048            pendingMessageCount = new CountStatisticImpl("Pending Message Count",
049                    StatisticImpl.UNIT_COUNT, "Number of pending messages");
050            expiredMessageCount = new CountStatisticImpl("Expired Message Count",
051                    StatisticImpl.UNIT_COUNT, "Number of expired messages");
052            durableSubscriptionCount = new CountStatisticImpl(
053                    "Durable Subscription Count", StatisticImpl.UNIT_COUNT,
054                    "Number of durable subscriptions");
055            messageWaitTime = new TimeStatisticImpl("Message Wait Time",
056                    StatisticImpl.UNIT_COUNT,
057                    "Time spent by a message before being delivered");
058    
059            addStat("MessageCount", messageCount);
060            addStat("PendingMessageCount", pendingMessageCount);
061            addStat("ExpiredMessageCount", expiredMessageCount);
062            addStat("DurableSubscriptionCount", durableSubscriptionCount);
063            addStat("MessageWaitTime", messageWaitTime);
064        }
065    
066        public JMSProducerStats[] getProducers() {
067            return producersStats;
068        }
069    
070        public JMSConsumerStats[] getConsumers() {
071            return consumersStats;
072        }
073    
074        public CountStatistic getMessageCount() {
075            return messageCount;
076        }
077    
078        public CountStatistic getPendingMessageCount() {
079            return pendingMessageCount;
080        }
081    
082        public CountStatistic getExpiredMessageCount() {
083            return messageCount;
084        }
085    
086        public CountStatistic getDurableSubscriptionCount() {
087            return durableSubscriptionCount;
088        }
089    
090        public TimeStatistic getMessageWaitTime() {
091            return messageWaitTime;
092        }
093    }