KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > stats > StatisticImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 /*
30  * $Id: StatisticImpl.java,v 1.2 2005/12/25 03:52:26 tcfujii Exp $
31  * $Date: 2005/12/25 03:52:26 $
32  * $Revision: 1.2 $
33  */

34
35 package com.sun.enterprise.admin.monitor.stats;
36 import javax.management.j2ee.statistics.Statistic JavaDoc;
37 import java.io.Serializable JavaDoc;
38 import com.sun.enterprise.util.i18n.StringManager;
39
40 /**
41  * An abstract class providing implementation of the Statistic interface
42  * The intent is for this to be subclassed by all the StatisticImpls.
43  * @author Muralidhar Vempaty
44  * @since S1AS8.0
45  * @version 1.0
46  */

47
48 public abstract class StatisticImpl implements Statistic JavaDoc,Serializable JavaDoc {
49     
50     private String JavaDoc statisticName;
51     private String JavaDoc statisticDesc;
52     private String JavaDoc statisticUnit;
53     private long startTime;
54     private long sampleTime;
55     
56     /** DEFAULT_UNIT is an empty string */
57     public static String JavaDoc DEFAULT_UNIT = null;
58     public static StringManager localStrMgr = null;
59     /** DEFAULT_VALUE of any statistic is 0 */
60     public static final long DEFAULT_VALUE = java.math.BigInteger.ZERO.longValue();
61
62     static {
63         localStrMgr = StringManager.getManager(StatisticImpl.class);
64         DEFAULT_UNIT = localStrMgr.getString("count_string");
65     }
66
67     /**
68      * Constructor
69      * @param name The name of the statistic
70      * @param unit The unit of measurement for this statistic
71      * @param desc A brief description of the statistic
72      * @param startTime Time in milliseconds at which the measurement was started
73      * @param sampleTime Time at which the last measurement was done.
74      **/

75     protected StatisticImpl(String JavaDoc name, String JavaDoc unit, String JavaDoc desc,
76                           long start_time, long sample_time) {
77         
78         statisticName = name;
79         statisticUnit = unit;
80         statisticDesc = desc;
81         startTime = start_time;
82         sampleTime = sample_time;
83     }
84     
85     /**
86      * returns the name of the statistic
87      */

88     public String JavaDoc getName() {
89         return this.statisticName;
90     }
91     
92     /**
93      * returns the description of the statistic
94      */

95     public String JavaDoc getDescription() {
96         return this.statisticDesc;
97     }
98     
99     /**
100      * returns the unit of measurement for the statistic
101      */

102     public String JavaDoc getUnit() {
103         return this.statisticUnit;
104     }
105     
106     /**
107      * returns the time in millis, at which the last measurement was taken
108      */

109     public long getLastSampleTime() {
110         return this.sampleTime;
111     }
112     
113     /**
114      * returns the time in millis, at which the first measurement was taken
115      */

116     public long getStartTime() {
117         return this.startTime;
118     }
119
120     /** This is a hack. This method allows us to internatinalize the descriptions.
121         See bug Id: 5045413
122     */

123     public void setDescription(final String JavaDoc desc) {
124         this.statisticDesc = desc;
125     }
126 }
127
Popular Tags