KickJava   Java API By Example, From Geeks To Geeks.

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


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

54
55 public class EJBPoolStatsImpl
56     extends StatsImpl
57     implements com.sun.enterprise.admin.monitor.stats.EJBPoolStats
58 {
59     private EJBPoolStatsProvider delegate;
60
61     private MutableCountStatisticImpl jmsStat;
62     private MutableBoundedRangeStatisticImpl beansInPoolStat;
63     private MutableBoundedRangeStatisticImpl threadStat;
64     private MutableCountStatisticImpl createdStat;
65     private MutableCountStatisticImpl destroyedStat;
66
67     public EJBPoolStatsImpl(EJBPoolStatsProvider delegate) {
68     this.delegate = delegate;
69
70     initialize();
71     }
72
73     protected void initialize() {
74     super.initialize("com.sun.enterprise.admin.monitor.stats.EJBPoolStats");
75
76     jmsStat = new MutableCountStatisticImpl(
77         new CountStatisticImpl("JmsMaxMessagesLoad"));
78     beansInPoolStat = new MutableBoundedRangeStatisticImpl(
79         new BoundedRangeStatisticImpl("NumBeansInPool",
80             "Count", 0, delegate.getMaxPoolSize(),
81             delegate.getSteadyPoolSize()));
82     threadStat = new MutableBoundedRangeStatisticImpl(
83         new BoundedRangeStatisticImpl("NumThreadsWaiting"));
84     createdStat = new MutableCountStatisticImpl(
85         new CountStatisticImpl("TotalBeansCreated"));
86     destroyedStat = new MutableCountStatisticImpl(
87         new CountStatisticImpl("TotalBeansDestroyed"));
88     }
89
90     public CountStatistic JavaDoc getJmsMaxMessagesLoad() {
91     jmsStat.setCount(delegate.getJmsMaxMessagesLoad());
92     return (CountStatistic JavaDoc) jmsStat.modifiableView();
93     }
94
95     public BoundedRangeStatistic JavaDoc getNumBeansInPool() {
96     beansInPoolStat.setCount(delegate.getNumBeansInPool());
97     return (BoundedRangeStatistic JavaDoc) beansInPoolStat.modifiableView();
98     }
99
100     public BoundedRangeStatistic JavaDoc getNumThreadsWaiting() {
101     threadStat.setCount(delegate.getNumThreadsWaiting());
102     return (BoundedRangeStatistic JavaDoc) threadStat.modifiableView();
103     }
104
105     public CountStatistic JavaDoc getTotalBeansCreated() {
106     createdStat.setCount(delegate.getTotalBeansCreated());
107     return (CountStatistic JavaDoc) createdStat.modifiableView();
108     }
109
110     public CountStatistic JavaDoc getTotalBeansDestroyed() {
111     destroyedStat.setCount(delegate.getTotalBeansDestroyed());
112     return (CountStatistic JavaDoc) destroyedStat.modifiableView();
113     }
114
115 }
116
Popular Tags