001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 java.io.Serializable; 020 import javax.management.j2ee.statistics.Statistic; 021 022 /** 023 * Implementation of the JSR-77 Statistic interface (JSR77.6.4) 024 * 025 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ 026 */ 027 public class StatisticImpl implements Statistic, Serializable { 028 // Defined in JSR77.6.4.1.2 029 public final static String UNIT_TIME_HOUR = "HOUR"; 030 public final static String UNIT_TIME_MINUTE = "MINUTE"; 031 public final static String UNIT_TIME_SECOND = "SECOND"; 032 public final static String UNIT_TIME_MILLISECOND = "MILLISECOND"; 033 public final static String UNIT_TIME_MICROSECOND = "MICROSECOND"; 034 public final static String UNIT_TIME_NANOSECOND = "NANOSECOND"; 035 // Units that are not defined in JSR-77 036 public final static String UNIT_MEMORY_BYTES = "BYTE"; 037 public final static String UNIT_MEMORY_KILOBYTES = "KILOBYTE"; 038 public final static String UNIT_MEMORY_MEGABYTES = "MEGABYTE"; 039 public final static String UNIT_MEMORY_GIGABYTES = "GIGABYTE"; 040 public final static String UNIT_COUNT = "COUNT"; 041 042 private String name; 043 private String unit; 044 private String description; 045 private long startTime; 046 private long lastSampleTime; 047 048 public StatisticImpl(String name, String unit, String description) { 049 this.name = name; 050 this.unit = unit; 051 this.description = description; 052 } 053 054 public String getName() { 055 return name; 056 } 057 058 public String getUnit() { 059 return unit; 060 } 061 062 public String getDescription() { 063 return description; 064 } 065 066 public long getStartTime() { 067 return startTime; 068 } 069 070 public void setStartTime() { 071 this.startTime = System.currentTimeMillis(); 072 } 073 074 public void setStartTime(long startTime) { 075 this.startTime = startTime; 076 } 077 078 public long getLastSampleTime() { 079 return lastSampleTime; 080 } 081 082 public void setLastSampleTime(long lastSampleTime) { 083 this.lastSampleTime = lastSampleTime; 084 } 085 086 public void setLastSampleTime() { 087 this.lastSampleTime = System.currentTimeMillis(); 088 } 089 }