KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > types > Counter


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  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31 package com.sun.enterprise.admin.monitor.types;
32
33 /**
34  * Monitored attribute type counter. An attribute of Counter type has following
35  * properties -
36  * <ul>
37  * <li>Attribute value is Byte, Short, Integer or Long</li>
38  * <li>Attribute value is always greater than or equal to zero</li>
39  * <li>Attribute value can only be incremented.</li>
40  * <li>Attribute value can roll over and in that case a modulus value is
41  * defined.</li>
42  * </ul>
43  */

44 public class Counter extends MonitoredAttributeType {
45
46     /**
47      * Useful object to denote a monitored attribute whose values are of
48      * type java.lang.Byte and maximum value is Byte.MAX_VALUE
49      */

50     public static final Counter BYTE = new Counter(Byte.TYPE,
51             new Byte JavaDoc(Byte.MAX_VALUE));
52
53     /**
54      * Useful object to denote a monitored attribute whose values are of
55      * type java.lang.Short and maximum value is Short.MAX_VALUE
56      */

57     public static final Counter SHORT = new Counter(Short.TYPE,
58             new Short JavaDoc(Short.MAX_VALUE));
59
60     /**
61      * Useful object to denote a monitored attribute whose values are of
62      * type java.lang.Integer and maximum value is Integer.MAX_VALUE
63      */

64     public static final Counter INTEGER = new Counter(Integer.TYPE,
65             new Integer JavaDoc(Integer.MAX_VALUE));
66
67     /**
68      * Useful object to denote a monitored attribute whose values are of
69      * type java.lang.Long and maximum value is Long.MAX_VALUE
70      */

71     public static final Counter LONG = new Counter(Long.TYPE,
72             new Long JavaDoc(Long.MAX_VALUE));
73
74     /**
75      * Maximum value for this type
76      */

77     private Number JavaDoc maxValue;
78
79     /**
80      * Create a Type "Counter Monitored Attribute" with specified java type
81      * (of the monitored attribute value) and specified maximum value.
82      * @param type class of object returned as value for the monitored attribute
83      * @param maxVal maximum possible value for this type of monitored attribute
84      */

85     protected Counter(Class JavaDoc type, Number JavaDoc maxVal) {
86         super(type);
87         maxValue = maxVal;
88     }
89
90     /**
91      * Get maximum possible value for this counter. If the attribute value is
92      * higher than this number then it will be rolled over.
93      */

94     public Number JavaDoc getMaxValue() {
95         return maxValue;
96     }
97 }
98
Popular Tags