1 23 24 package com.sun.enterprise.management.monitor.stats; 25 26 import com.sun.enterprise.management.monitor.*; 27 import javax.management.InstanceNotFoundException ; 28 import javax.management.j2ee.statistics.Statistic ; 29 import com.sun.appserv.management.j2ee.statistics.MapStatistic; 30 import com.sun.appserv.management.j2ee.statistics.MapStatisticImpl; 31 import com.sun.appserv.management.j2ee.statistics.StatisticImpl; 32 import com.sun.appserv.management.j2ee.statistics.StatisticFactory; 33 import com.sun.appserv.management.util.misc.ExceptionUtil; 34 35 38 public abstract class CustomMonitoringStatsImplBase extends MonitoringStatsImplBase { 39 40 public CustomMonitoringStatsImplBase(String j2eeType) { 41 super(j2eeType); 42 } 43 44 48 protected Statistic [] getStatisticsFromImpl(CustomStatsImpl customStatsImpl) { 49 try { 50 final Statistic [] statistics = getStatisticsFromImplRaw(customStatsImpl); 51 for(int i = 0; i < statistics.length; ++i) { 53 final Statistic origStatistic = statistics[i]; 54 55 final MapStatistic m = new MapStatisticImpl(origStatistic); 56 57 final String convertedName = originalToDerivedStatisticName(origStatistic.getName()); 58 if (! convertedName.equals(origStatistic.getName())) 59 m.setName(convertedName); 60 61 final Class <? extends Statistic > theClass = 62 StatisticFactory.getInterface(origStatistic); 63 assert(theClass != null); 64 65 statistics[ i ] = StatisticFactory.create(theClass, m.asMap()); 67 68 assert(theClass.isAssignableFrom(statistics[ i ].getClass())); 69 } 70 return(statistics); 71 } catch (Exception e) { 72 final Throwable rootCause = ExceptionUtil.getRootCause(e); 73 74 if (!(rootCause instanceof InstanceNotFoundException )) 75 logWarning("Can't get Statistics from impl of " + getObjectName() + 79 "\n" + rootCause.getMessage() + "\n" + ExceptionUtil.getStackTrace(rootCause)); 80 throw new RuntimeException (e); 81 } 82 } 83 84 protected Statistic [] getStatisticsFromImplRaw(CustomStatsImpl impl) { 85 try { 86 final Statistic [] statistics = impl.getStatistics(); 87 return statistics; 88 } catch (Exception e) { 89 final Throwable rootCause = ExceptionUtil.getRootCause( e ); 90 logWarning( "CustomMonitoringStatsImplBase: " + 91 "the stats impl for the stats of AMX MBean " + 92 getObjectName() + " threw an exception: " + rootCause + 93 ", stack = \n" + ExceptionUtil.getStackTrace( rootCause ) ); 94 } 95 return new Statistic [0]; 96 } 97 } 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | Popular Tags |