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    
018    package org.apache.activemq.broker.region;
019    
020    import org.apache.activemq.management.CountStatisticImpl;
021    import org.apache.activemq.management.StatsImpl;
022    
023    /**
024     * The J2EE Statistics for the Connection.
025     * 
026     * 
027     */
028    public class ConnectionStatistics extends StatsImpl {
029    
030        private CountStatisticImpl enqueues;
031        private CountStatisticImpl dequeues;
032    
033        public ConnectionStatistics() {
034    
035            enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the connection");
036            dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been dispatched from the connection");
037    
038            addStatistic("enqueues", enqueues);
039            addStatistic("dequeues", dequeues);
040        }
041    
042        public CountStatisticImpl getEnqueues() {
043            return enqueues;
044        }
045    
046        public CountStatisticImpl getDequeues() {
047            return dequeues;
048        }
049    
050        public void reset() {
051            super.reset();
052            enqueues.reset();
053            dequeues.reset();
054        }
055    
056        public void setEnabled(boolean enabled) {
057            super.setEnabled(enabled);
058            enqueues.setEnabled(enabled);
059            dequeues.setEnabled(enabled);
060        }
061    
062        public void setParent(ConnectorStatistics parent) {
063            if (parent != null) {
064                enqueues.setParent(parent.getEnqueues());
065                dequeues.setParent(parent.getDequeues());
066            } else {
067                enqueues.setParent(null);
068                dequeues.setParent(null);
069            }
070        }
071    
072    }