KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.appserv.management.j2ee.statistics;
26
27 import java.util.Map JavaDoc;
28 import java.io.Serializable JavaDoc;
29
30 import javax.management.openmbean.CompositeData JavaDoc;
31
32 import com.sun.appserv.management.util.jmx.OpenMBeanUtil;
33
34 import com.sun.appserv.management.j2ee.statistics.StatisticImpl;
35
36 /**
37  *
38  */

39 public final class NumberStatisticImpl
40         extends StatisticImpl implements NumberStatistic, Serializable JavaDoc {
41     static final long serialVersionUID = 2090185734375468533L;
42     
43     private Number JavaDoc Current;
44     
45     public NumberStatisticImpl( final CompositeData JavaDoc compositeData ) {
46         this( OpenMBeanUtil.compositeDataToMap( compositeData ) );
47     }
48     
49     public NumberStatisticImpl( final Map JavaDoc<String JavaDoc,?> m ) {
50         this( new MapStatisticImpl( m ) );
51     }
52     
53     public NumberStatisticImpl( final NumberStatistic n ) {
54         super( n );
55         Current = n.getCurrent();
56     }
57     
58     public NumberStatisticImpl( final MapStatistic m ) {
59         super( m );
60         Current = (Number JavaDoc)m.getValue( "Current" );
61     }
62     
63     public NumberStatisticImpl(
64             final String JavaDoc name,
65             final String JavaDoc description,
66             final String JavaDoc unit,
67             final long startTime,
68             final long lastSampleTime,
69             final Number JavaDoc current ) {
70         super( name, description, unit, startTime, lastSampleTime );
71         this.Current = current;
72     }
73     
74     public void setNumber(Number JavaDoc c) {
75           this.Current = c;
76           this.mLastSampleTime = System.currentTimeMillis();
77     }
78
79     public Number JavaDoc getCurrent() {
80         return( Current );
81     }
82 }
83
84
85
86
87
88
Popular Tags