KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > util > cache > mbeans > JmxBaseCache


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  * @Version $Id: JmxBaseCache.java,v 1.4 2005/12/25 04:25:22 tcfujii Exp $
26  * Created on May 4, 2005 11:55 AM
27  */

28
29 package com.sun.appserv.util.cache.mbeans;
30
31 import com.sun.appserv.util.cache.BaseCache;
32 import com.sun.appserv.util.cache.Constants;
33
34 /**
35  * This class provides implementation for JmxBaseCacheMBean
36  *
37  * @author Krishnamohan Meduri (Krishna.Meduri@Sun.com)
38  *
39  */

40 public class JmxBaseCache implements JmxBaseCacheMBean {
41
42     private String JavaDoc name;
43     private BaseCache baseCache;
44
45     public JmxBaseCache(BaseCache baseCache, String JavaDoc name) {
46         this.baseCache = baseCache;
47         this.name = name;
48     }
49     /**
50      * Returns a unique identifier for this MBean inside the domain
51      */

52     public String JavaDoc getName() {
53         return name;
54     }
55
56     /**
57      * Returns maximum possible number of entries
58      */

59     public Integer JavaDoc getMaxEntries() {
60         return (Integer JavaDoc) baseCache.getStatByName(
61                                         Constants.STAT_BASECACHE_MAX_ENTRIES);
62     }
63
64     /**
65      * Returns threshold. This when reached, an overflow will occur
66      */

67     public Integer JavaDoc getThreshold() {
68         return (Integer JavaDoc) baseCache.getStatByName(
69                                         Constants.STAT_BASECACHE_THRESHOLD);
70     }
71
72     /**
73      * Returns current number of buckets
74      */

75     public Integer JavaDoc getTableSize() {
76         return (Integer JavaDoc) baseCache.getStatByName(
77                                         Constants.STAT_BASECACHE_TABLE_SIZE);
78     }
79
80     /**
81      * Returns current number of Entries
82      */

83     public Integer JavaDoc getEntryCount() {
84         return (Integer JavaDoc) baseCache.getStatByName(
85                                         Constants.STAT_BASECACHE_ENTRY_COUNT);
86     }
87
88     /**
89      * Return the number of cache hits
90      */

91     public Integer JavaDoc getHitCount() {
92         return (Integer JavaDoc) baseCache.getStatByName(
93                                         Constants.STAT_BASECACHE_HIT_COUNT);
94     }
95
96     /**
97      * Returns the number of cache misses
98      */

99     public Integer JavaDoc getMissCount() {
100         return (Integer JavaDoc) baseCache.getStatByName(
101                                         Constants.STAT_BASECACHE_MISS_COUNT);
102     }
103
104     /**
105      * Returns the number of entries that have been removed
106      */

107     public Integer JavaDoc getRemovalCount() {
108         return (Integer JavaDoc) baseCache.getStatByName(
109                                         Constants.STAT_BASECACHE_REMOVAL_COUNT);
110     }
111
112     /**
113      * Returns the number of values that have been refreshed
114      * (replaced with a new value in an existing extry)
115      */

116     public Integer JavaDoc getRefreshCount() {
117         return (Integer JavaDoc) baseCache.getStatByName(
118                                         Constants.STAT_BASECACHE_REFRESH_COUNT);
119     }
120
121     /**
122      * Returns the number of times that an overflow has occurred
123      */

124     public Integer JavaDoc getOverflowCount() {
125         return (Integer JavaDoc) baseCache.getStatByName(
126                                         Constants.STAT_BASECACHE_OVERFLOW_COUNT);
127     }
128
129     /**
130      * Returns the number of times new entries have been added
131      */

132     public Integer JavaDoc getAddCount() {
133         return (Integer JavaDoc) baseCache.getStatByName(
134                                         Constants.STAT_BASECACHE_ADD_COUNT);
135     }
136 }
137
Popular Tags