KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > resource > monitor > AbstractStatsImpl


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.enterprise.resource.monitor;
25
26 import javax.management.j2ee.statistics.RangeStatistic JavaDoc;
27 import javax.management.j2ee.statistics.Statistic JavaDoc;
28
29 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl;
30 import com.sun.enterprise.admin.monitor.stats.RangeStatisticImpl;
31
32 /**
33  *
34  * @author Sivakumar Thyagarajan
35  */

36 public class AbstractStatsImpl {
37     //@todo : initialized by sub-classes
38
protected GenericStatsImpl gsImpl;
39
40     /**
41      * This is an implementation of the mandatory JSR77 Stats
42      * interface method.
43      * Here we simply delegate it to the GenericStatsImpl object
44      * that we have
45      */

46     public Statistic JavaDoc[] getStatistics() {
47         return gsImpl.getStatistics();
48     }
49
50     /**
51      * This is an implementation of the mandatory JSR77 Stats
52      * interface method.
53      * Here we simply delegate it to the GenericStatsImpl object
54      * that we have
55      */

56     public Statistic JavaDoc getStatistic( String JavaDoc str ) {
57         return gsImpl.getStatistic( str );
58     }
59
60      /**
61      * This is an implementation of the mandatory JSR77 Stats
62      * interface method.
63      * Here we simply delegate it to the GenericStatsImpl object
64      * that we have
65      */

66    public String JavaDoc[] getStatisticNames() {
67         return gsImpl.getStatisticNames();
68     }
69
70    /**
71     * A utility method to update a range statistic
72     */

73    protected RangeStatistic JavaDoc getUpdatedRangeStatistic
74                        (RangeStatistic JavaDoc originalStat, long currentValue,
75                                        long maxValue, long minValue){
76        return new RangeStatisticImpl(currentValue, maxValue, minValue,
77            originalStat.getName(), originalStat.getUnit(),
78            originalStat.getDescription(), originalStat.getStartTime(),
79            System.currentTimeMillis());
80    }
81 }
82
Popular Tags