1 23 24 package com.sun.ejb.base.stats; 25 26 import javax.management.j2ee.statistics.CountStatistic ; 27 import javax.management.j2ee.statistics.TimeStatistic ; 28 import javax.management.j2ee.statistics.BoundedRangeStatistic ; 29 30 import com.sun.enterprise.admin.monitor.stats.EJBCacheStats; 31 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 32 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 33 import com.sun.enterprise.admin.monitor.stats.TimeStatisticImpl; 34 import com.sun.enterprise.admin.monitor.stats.MutableTimeStatisticImpl; 35 36 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistry; 37 import com.sun.enterprise.admin.monitor.registry.MonitoringLevelListener; 38 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel; 39 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistrationException; 40 41 import java.util.logging.*; 42 import com.sun.enterprise.log.Log; 43 import com.sun.logging.*; 44 45 46 52 53 public class EJBMethodStatsImpl 54 extends StatsImpl 55 implements com.sun.enterprise.admin.monitor.stats.EJBMethodStats 56 { 57 private MethodMonitor delegate; 58 59 private MethodMonitor methodMonitor; 60 61 private MutableCountStatisticImpl executionStat; 62 private MutableCountStatisticImpl errorStat; 63 private MutableTimeStatisticImpl methodStat; 64 private MutableCountStatisticImpl successStat; 65 66 public EJBMethodStatsImpl(MethodMonitor delegate) { 67 this.delegate = delegate; 68 69 initialize(); 70 } 71 72 private void initialize() { 73 super.initialize("com.sun.enterprise.admin.monitor.stats.EJBMethodStats"); 74 75 executionStat = new MutableCountStatisticImpl( 76 new CountStatisticImpl("ExecutionTime", "Milliseconds" )); 77 errorStat = new MutableCountStatisticImpl( 78 new CountStatisticImpl("TotalNumErrors")); 79 80 long now = System.currentTimeMillis(); 81 methodStat = new MutableTimeStatisticImpl( 82 new TimeStatisticImpl(0, 0, 0, 0, 83 "MethodStatistic", "", "", now, now)); 84 successStat = new MutableCountStatisticImpl( 85 new CountStatisticImpl("TotalNumSuccess")); 86 87 delegate.setMutableTimeStatisticImpl(methodStat); 88 } 89 90 public CountStatistic getExecutionTime() { 91 executionStat.setCount(delegate.getExecutionTime()); 92 return (CountStatistic ) executionStat.modifiableView(); 93 } 94 95 public CountStatistic getTotalNumErrors() { 96 errorStat.setCount(delegate.getTotalNumErrors()); 97 return (CountStatistic ) errorStat.modifiableView(); 98 } 99 100 public TimeStatistic getMethodStatistic() { 101 return (TimeStatistic ) methodStat.modifiableView(); 102 } 103 104 public CountStatistic getTotalNumSuccess() { 105 successStat.setCount(delegate.getTotalNumSuccess()); 106 return (CountStatistic ) successStat.modifiableView(); 107 } 108 109 protected void resetAllStats() { 110 112 executionStat.reset(); 113 errorStat.reset(); 114 synchronized (methodStat) { 115 methodStat.reset(); 116 } 117 successStat.reset(); 118 119 delegate.resetAllStats(monitorOn); 120 } 121 122 } 123 | Popular Tags |