KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > j2ee > statistics > RangeStatisticImpl


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  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/j2ee/statistics/RangeStatisticImpl.java,v 1.4 2006/03/09 20:30:29 llc Exp $
26  * $Revision: 1.4 $
27  * $Date: 2006/03/09 20:30:29 $
28  */

29
30 package com.sun.appserv.management.j2ee.statistics;
31
32 import java.util.Set JavaDoc;
33 import java.util.Map JavaDoc;
34 import java.io.Serializable JavaDoc;
35
36 import javax.management.openmbean.CompositeData JavaDoc;
37
38 import javax.management.j2ee.statistics.Statistic JavaDoc;
39 import javax.management.j2ee.statistics.RangeStatistic JavaDoc;
40
41 import com.sun.appserv.management.util.jmx.OpenMBeanUtil;
42
43 /**
44     
45  */

46 public class RangeStatisticImpl extends StatisticImpl
47     implements RangeStatistic JavaDoc, Serializable JavaDoc
48 {
49     static final long serialVersionUID = 6530146323113291603L;
50     
51     /* member names as defined by JSR 77 */
52     private final long Current;
53     private final long HighWaterMark;
54     private final long LowWaterMark;
55     
56     
57         public
58     RangeStatisticImpl(
59         final String JavaDoc name,
60         final String JavaDoc description,
61         final String JavaDoc unit,
62         final long startTime,
63         final long lastSampleTime,
64         final long low,
65         final long current,
66         final long high )
67     {
68         super( name, description, unit, startTime, lastSampleTime );
69         
70         if ( current < low || current > high )
71         {
72             throw new IllegalArgumentException JavaDoc();
73         }
74         
75         Current = current;
76         HighWaterMark = high;
77         LowWaterMark = low;
78     }
79     
80         public
81     RangeStatisticImpl( final CompositeData JavaDoc compositeData )
82     {
83         this( OpenMBeanUtil.compositeDataToMap( compositeData ) );
84     }
85     
86         public
87     RangeStatisticImpl( final Map JavaDoc<String JavaDoc,?> m )
88     {
89         this( new MapStatisticImpl( m ) );
90     }
91     
92         public
93     RangeStatisticImpl( final RangeStatistic JavaDoc s )
94     {
95         super( s );
96         
97         Current = s.getCurrent();
98         LowWaterMark = s.getHighWaterMark();
99         HighWaterMark = s.getLowWaterMark();
100     }
101     
102     
103         public
104     RangeStatisticImpl( final MapStatistic s )
105     {
106         super( s );
107         
108         Current = s.getlong( "Current" );
109         LowWaterMark = s.getlong( "LowWaterMark" );
110         HighWaterMark = s.getlong( "HighWaterMark" );
111     }
112
113
114         public long
115     getCurrent()
116     {
117         return( Current );
118     }
119
120         public long
121     getHighWaterMark()
122     {
123         return( HighWaterMark );
124     }
125
126         public long
127     getLowWaterMark()
128     {
129         return( LowWaterMark );
130     }
131 }
132
133
134
135
136
137
Popular Tags