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 018package org.apache.activemq.store; 019 020import org.apache.activemq.management.CountStatisticImpl; 021import org.apache.activemq.management.SizeStatisticImpl; 022import org.apache.activemq.management.StatsImpl; 023 024/** 025 * The J2EE Statistics for a Message Sore 026 */ 027public class MessageStoreStatistics extends StatsImpl { 028 029 protected CountStatisticImpl messageCount; 030 protected SizeStatisticImpl messageSize; 031 032 033 public MessageStoreStatistics() { 034 this(true); 035 } 036 037 public MessageStoreStatistics(boolean enabled) { 038 039 messageCount = new CountStatisticImpl("messageCount", "The number of messages in the store passing through the destination"); 040 messageSize = new SizeStatisticImpl("messageSize","Size of messages in the store passing through the destination"); 041 042 addStatistic("messageCount", messageCount); 043 addStatistic("messageSize", messageSize); 044 045 this.setEnabled(enabled); 046 } 047 048 049 public CountStatisticImpl getMessageCount() { 050 return messageCount; 051 } 052 053 public SizeStatisticImpl getMessageSize() { 054 return messageSize; 055 } 056 057 public void reset() { 058 if (this.isDoReset()) { 059 super.reset(); 060 messageCount.reset(); 061 messageSize.reset(); 062 } 063 } 064 065 public void setEnabled(boolean enabled) { 066 super.setEnabled(enabled); 067 messageCount.setEnabled(enabled); 068 messageSize.setEnabled(enabled); 069 } 070 071 public void setParent(MessageStoreStatistics parent) { 072 if (parent != null) { 073 messageCount.setParent(parent.messageCount); 074 messageSize.setParent(parent.messageSize); 075 } else { 076 messageCount.setParent(null); 077 messageSize.setParent(null); 078 } 079 } 080 081}