KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > base > stats > EJBCacheStatsImpl


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 package com.sun.ejb.base.stats;
25
26 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
27 import javax.management.j2ee.statistics.BoundedRangeStatistic JavaDoc;
28
29 import com.sun.enterprise.admin.monitor.stats.EJBCacheStats;
30 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl;
31 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl;
32 import com.sun.enterprise.admin.monitor.stats.BoundedRangeStatisticImpl;
33 import com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl;
34
35 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistry;
36 import com.sun.enterprise.admin.monitor.registry.MonitoringLevelListener;
37 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel;
38 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistrationException;
39
40 import com.sun.ejb.spi.stats.EJBCacheStatsProvider;
41
42 import java.util.logging.*;
43 import com.sun.enterprise.log.Log;
44 import com.sun.logging.*;
45
46 /**
47  * A Class for providing stats for EJB Caches.
48  * Used by both Entity and Stateful Containers
49  *
50  * @author Mahesh Kannan
51  */

52
53 public class EJBCacheStatsImpl
54     extends StatsImpl
55     implements com.sun.enterprise.admin.monitor.stats.EJBCacheStats
56 {
57     private EJBCacheStatsProvider delegate;
58
59     private MutableBoundedRangeStatisticImpl cacheHits;
60     private MutableBoundedRangeStatisticImpl cacheMisses;
61     private MutableBoundedRangeStatisticImpl numBeans;
62     private MutableCountStatisticImpl expiredStat;
63     private MutableCountStatisticImpl passivationErrors;
64     private MutableCountStatisticImpl passivations;
65     private MutableCountStatisticImpl passivationSuccess;
66
67
68     public EJBCacheStatsImpl(EJBCacheStatsProvider delegate) {
69     this.delegate = delegate;
70
71     initialize();
72     }
73
74     protected void initialize() {
75     super.initialize("com.sun.enterprise.admin.monitor.stats.EJBCacheStats");
76
77     cacheHits = new MutableBoundedRangeStatisticImpl(
78         new BoundedRangeStatisticImpl("CacheHits"));
79     cacheMisses = new MutableBoundedRangeStatisticImpl(
80         new BoundedRangeStatisticImpl("CacheMisses"));
81     numBeans = new MutableBoundedRangeStatisticImpl(
82         new BoundedRangeStatisticImpl("NumBeansInCache",
83            "Count", 0, delegate.getMaxCacheSize(), 0));
84     expiredStat = new MutableCountStatisticImpl(
85         new CountStatisticImpl("NumExpiredSessionsRemoved"));
86     passivationErrors = new MutableCountStatisticImpl(
87         new CountStatisticImpl("NumPassivationErrors"));
88     passivations = new MutableCountStatisticImpl(
89         new CountStatisticImpl("NumPassivations"));
90     passivationSuccess = new MutableCountStatisticImpl(
91         new CountStatisticImpl("NumPassivationSuccess"));
92     }
93
94     public BoundedRangeStatistic JavaDoc getCacheHits(){
95     cacheHits.setCount(delegate.getCacheHits());
96     return (BoundedRangeStatistic JavaDoc) cacheHits.modifiableView();
97     }
98
99     public BoundedRangeStatistic JavaDoc getCacheMisses(){
100     cacheMisses.setCount(delegate.getCacheMisses());
101     return (BoundedRangeStatistic JavaDoc) cacheMisses.modifiableView();
102     }
103
104     public BoundedRangeStatistic JavaDoc getNumBeansInCache(){
105     numBeans.setCount(delegate.getNumBeansInCache());
106     return (BoundedRangeStatistic JavaDoc) numBeans.modifiableView();
107     }
108
109     public CountStatistic JavaDoc getNumExpiredSessionsRemoved(){
110     expiredStat.setCount(delegate.getNumExpiredSessionsRemoved());
111     return (CountStatistic JavaDoc) expiredStat.modifiableView();
112     }
113
114     public CountStatistic JavaDoc getNumPassivationErrors(){
115     passivationErrors.setCount(delegate.getNumPassivationErrors());
116     return (CountStatistic JavaDoc) passivationErrors.modifiableView();
117     }
118
119     public CountStatistic JavaDoc getNumPassivations(){
120     passivations.setCount(delegate.getNumPassivations());
121     return (CountStatistic JavaDoc) passivations.modifiableView();
122     }
123
124     public CountStatistic JavaDoc getNumPassivationSuccess() {
125     passivationSuccess.setCount(delegate.getNumPassivationSuccess());
126     return (CountStatistic JavaDoc) passivationSuccess.modifiableView();
127     }
128
129 }
130
Popular Tags