FileDocCategorySizeDatePackage
JVMStatsImpl.javaAPI DocGlassfish v2 API6281Fri May 04 22:35:54 BST 2007com.sun.enterprise.server.stats

JVMStatsImpl

public class JVMStatsImpl extends Object implements javax.management.j2ee.statistics.JVMStats
Provides an implementation of the JVMStats interface, defined as part of JSR77. It specifies the monitoring statistics for a JVM

Fields Summary
private final long
initTime
private com.sun.enterprise.admin.monitor.stats.GenericStatsImpl
baseStatsImpl
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
uptime
private com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl
heapSize
private static final String
STATS_INTERFACE_NAME
private static com.sun.enterprise.util.i18n.StringManager
sm
Constructors Summary
public JVMStatsImpl()
Constructor for JVMStatsImpl In addition to initializing the MutableStatistic objects, we also instantiate a GenericStatsImpl object here. All requests for getStatistics(), getStatistic() & getStatisticNames() are delegated to this instance of GenericStatsImpl.

                        

                                          
      
		
		initTime = System.currentTimeMillis();
		 try {
            baseStatsImpl = new GenericStatsImpl(STATS_INTERFACE_NAME, this);
        }catch(ClassNotFoundException cnfe){
            // TODO: Handle ClassNotFoundException
        }
        
        // Initialize a MutableCountStatistic
        CountStatistic u = new CountStatisticImpl( 
                    sm.getString("jvmstats.jvm_uptime"), 
                    sm.getString("jvmstats.milli_seconds"), 
                    sm.getString("jvmstats.jvm_uptime_desc") );
        uptime = new MutableCountStatisticImpl(u);
        
        
        // Initialize a MutableBoundedRangeStatistic
        long upper = Runtime.getRuntime().maxMemory();
        BoundedRangeStatistic h =  new BoundedRangeStatisticImpl(
                    sm.getString("jvmstats.jvm_heapsize"),
                    sm.getString("jvmstats.bytes"),
                    sm.getString("jvmstats.jvm_heapsize_desc"),
                    0, upper, 0); 
        
        heapSize = new MutableBoundedRangeStatisticImpl(h);
    
Methods Summary
public javax.management.j2ee.statistics.BoundedRangeStatisticgetHeapSize()
Method to query the size of the JVM's heap

return
BoundedRangeStatistic

        long heap = Runtime.getRuntime().totalMemory();
        heapSize.setCount(heap);
        return (BoundedRangeStatistic) heapSize.unmodifiableView();
    
public javax.management.j2ee.statistics.StatisticgetStatistic(java.lang.String str)
queries for a Statistic by name.

return
Statistic

        return baseStatsImpl.getStatistic(str);
    
public java.lang.String[]getStatisticNames()
returns an array of names of all the Statistics, that can be retrieved from this implementation of Stats

return
String[]

        return baseStatsImpl.getStatisticNames();
    
public javax.management.j2ee.statistics.Statistic[]getStatistics()
This method can be used to retrieve all the Statistics, exposed by this implementation of Stats

return
Statistic[]

        return baseStatsImpl.getStatistics();
    
public javax.management.j2ee.statistics.CountStatisticgetUpTime()
Method to query the amount of time that the JVM has been running

return
CountStatistic

        long curTime = System.currentTimeMillis();
        long upTime = curTime - initTime;
        uptime.setCount(upTime);
        return (CountStatistic) uptime.unmodifiableView();