KickJava   Java API By Example, From Geeks To Geeks.

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


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
29 import com.sun.ejb.spi.stats.MonitorableSFSBStoreManager;
30
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.MutableTimeStatisticImpl;
34 import com.sun.enterprise.admin.monitor.stats.TimeStatisticImpl;
35
36 /**
37  * An instance of this class is used by the StatefulContainer to update monitoring
38  * data. There is once instance of this class per StatefulEJBContainer
39  *
40  * @author Mahesh Kannan
41  */

42
43 public class StatefulSessionStoreMonitor {
44
45     private StatefulSessionStoreStatsImpl statsImpl;
46
47     void setDelegate(StatefulSessionStoreStatsImpl delegate) {
48     this.statsImpl = delegate;
49     }
50
51     final void appendStats(StringBuffer JavaDoc sbuf) {
52     if (statsImpl != null) {
53         statsImpl.appendStats(sbuf);
54     }
55     }
56
57     //The following methods are called from StatefulSessionContainer
58
//
59
public final boolean isMonitoringOn() {
60     return (statsImpl != null);
61     }
62
63     public final void incrementActivationCount(boolean success) {
64     StatefulSessionStoreStatsImpl delegate = statsImpl;
65     if (delegate != null) {
66         delegate.incrementActivationCount(success);
67     }
68     }
69
70     public final void incrementPassivationCount(boolean success) {
71     StatefulSessionStoreStatsImpl delegate = statsImpl;
72     if (delegate != null) {
73         delegate.incrementPassivationCount(success);
74     }
75     }
76
77     public final void setActivationSize(long val) {
78     StatefulSessionStoreStatsImpl delegate = statsImpl;
79     if (delegate != null) {
80         delegate.setActivationSize(val);
81     }
82     }
83
84     public final void setActivationTime(long val) {
85     StatefulSessionStoreStatsImpl delegate = statsImpl;
86     if (delegate != null) {
87         delegate.setActivationTime(val);
88     }
89     }
90
91     public final void setPassivationSize(long val) {
92     StatefulSessionStoreStatsImpl delegate = statsImpl;
93     if (delegate != null) {
94         delegate.setPassivationSize(val);
95     }
96     }
97
98     public final void setPassivationTime(long val) {
99     StatefulSessionStoreStatsImpl delegate = statsImpl;
100     if (delegate != null) {
101         delegate.setPassivationTime(val);
102     }
103     }
104
105     public final void incrementExpiredSessionsRemoved(long val) {
106     StatefulSessionStoreStatsImpl delegate = statsImpl;
107     if (delegate != null) {
108         delegate.incrementExpiredSessionCountVal(val);
109     }
110     }
111
112     public void incrementCheckpointCount(boolean success) {
113     throw new RuntimeException JavaDoc("Checkpoint operation not allowed on non-HA store");
114     }
115
116     public void setCheckpointSize(long val) {
117     throw new RuntimeException JavaDoc("Checkpoint operation not allowed on non-HA store");
118     }
119
120     public void setCheckpointTime(long val) {
121     throw new RuntimeException JavaDoc("Checkpoint operation not allowed on non-HA store");
122     }
123
124     //The following methods are maintained for backward compatibility
125
//Called from LruCache
126
public int getNumExpiredSessionsRemoved() {
127     StatefulSessionStoreStatsImpl delegate = statsImpl;
128     return (delegate != null)
129         ? delegate.getNumExpiredSessionCount()
130         : 0;
131     }
132
133     public int getNumPassivationErrors() {
134     StatefulSessionStoreStatsImpl delegate = statsImpl;
135     return (delegate != null)
136         ? delegate.getNumPassivationErrorCount()
137         : 0;
138     }
139
140     public int getNumPassivations() {
141     StatefulSessionStoreStatsImpl delegate = statsImpl;
142     return (delegate != null)
143         ? delegate.getNumPassivationCount()
144         : 0;
145     }
146
147     public int getNumPassivationSuccess() {
148     StatefulSessionStoreStatsImpl delegate = statsImpl;
149     return (delegate != null)
150         ? delegate.getNumPassivationSuccessCount()
151         : 0;
152     }
153
154 }
155
Popular Tags