KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > monitor > ServletMonitorImpl


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  */

26
27 package com.sun.enterprise.management.monitor;
28
29 import java.util.Map JavaDoc;
30
31 import com.sun.appserv.management.base.XTypes;
32 import com.sun.enterprise.management.support.Delegate;
33
34 import com.sun.appserv.management.monitor.statistics.AltServletStats;
35
36 import javax.management.j2ee.statistics.Statistic JavaDoc;
37 import javax.management.j2ee.statistics.TimeStatistic JavaDoc;
38 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
39
40 import com.sun.appserv.management.util.misc.ArrayUtil;
41 import com.sun.appserv.management.util.j2ee.J2EEUtil;
42
43 import com.sun.appserv.management.j2ee.statistics.TimeStatisticImpl;
44 import com.sun.appserv.management.j2ee.statistics.CountStatisticImpl;
45
46
47 public class ServletMonitorImpl
48     extends MonitoringStatsImplBase
49     // implements ServletMonitor
50
{
51         public
52     ServletMonitorImpl(Delegate delegate)
53     {
54         super( XTypes.SERVLET_MONITOR, delegate );
55     }
56
57         protected Class JavaDoc
58     getStatsInterface()
59     {
60         return( AltServletStats.class );
61     }
62     
63         public AltServletStats
64     getAltServletStats()
65     {
66         return( (AltServletStats)getStats() );
67     }
68     
69     
70     /**
71         [WORKAROUND]
72         Underlying MBean supplies extra, non-standard and redundant Statistics;
73         make sure expose only those we advertise in AltServletStats (unit tests
74         will fail otherwise).
75         
76         Does this still need to be done in 9.0?
77      */

78         protected final Statistic JavaDoc[]
79     getStatisticsFromDelegate( final Delegate d)
80     {
81         final Statistic JavaDoc[] fromSuper = super.getStatisticsFromDelegate( d );
82         
83         final Map JavaDoc<String JavaDoc,Statistic JavaDoc> m = J2EEUtil.statisticsToMap( fromSuper );
84
85         final Statistic JavaDoc[] result = new Statistic JavaDoc[ 6 ];
86         
87         result[ 0 ] = (Statistic JavaDoc)m.get( "ServiceTime" ); // from ServletStats
88
result[ 1 ] = (Statistic JavaDoc)m.get( "ErrorCount" ); // from AltServletStats
89
result[ 2 ] = (Statistic JavaDoc)m.get( "RequestCount" ); // from AltServletStats
90
result[ 3 ] = (Statistic JavaDoc)m.get( "ProcessingTime" ); // from AltServletStats
91
result[ 4 ] = (Statistic JavaDoc)m.get( "MaxTime" ); // from AltServletStats
92
result[ 5 ] = (Statistic JavaDoc)m.get( "ServiceTime" ); // from AltServletStats
93

94         return result;
95     }
96     
97     
98
99     
100 }
101
Popular Tags