1 23 24 29 30 package com.sun.appserv.management.j2ee.statistics; 31 32 import java.util.Set ; 33 import java.util.Map ; 34 35 36 import javax.management.openmbean.CompositeData ; 37 38 import javax.management.j2ee.statistics.Stats ; 39 import javax.management.j2ee.statistics.Statistic ; 40 41 import com.sun.appserv.management.util.jmx.OpenMBeanUtil; 42 43 47 public final class CompositeDataStats implements Stats 48 { 49 final Map <String ,?> mItems; 50 51 54 public 55 CompositeDataStats( final CompositeData compositeData ) 56 { 57 mItems = OpenMBeanUtil.compositeDataToMap( compositeData ); 58 } 59 60 public Statistic 61 getStatistic( String statisticName ) 62 { 63 final CompositeData statData = (CompositeData )mItems.get( statisticName ); 64 if ( statData == null && ! mItems.containsKey( statisticName ) ) 65 { 66 throw new IllegalArgumentException ( statisticName ); 67 } 68 69 return( new CompositeDataStatistic( statData ) ); 70 } 71 72 public String [] 73 getStatisticNames() 74 { 75 final Set <String > nameSet = mItems.keySet(); 76 77 return( (String [])nameSet.toArray( new String [ nameSet.size() ] ) ); 78 } 79 80 public Statistic [] 81 getStatistics() 82 { 83 final String [] names = getStatisticNames(); 84 final Statistic [] statistics = new Statistic [ names.length ]; 85 86 for( int i = 0; i < names.length; ++i ) 87 { 88 statistics[ i ] = getStatistic( names[ i ] ); 89 } 90 91 return( statistics ); 92 } 93 94 } 95 96 97 98 99 100 | Popular Tags |