1 22 package org.jboss.management.j2ee; 23 24 import org.jboss.logging.Logger; 25 import org.jboss.management.j2ee.statistics.RangeStatisticImpl; 26 import org.jboss.management.j2ee.statistics.StatefulSessionBeanStatsImpl; 27 28 import javax.management.MalformedObjectNameException ; 29 import javax.management.ObjectName ; 30 import javax.management.j2ee.statistics.Stats ; 31 32 39 public class StatefulSessionBean extends SessionBean 40 implements StatefulSessionBeanMBean 41 { 42 private static Logger log = Logger.getLogger(StatefulSessionBean.class); 43 44 private StatefulSessionBeanStatsImpl stats; 45 46 48 50 52 54 public StatefulSessionBean(String name, ObjectName ejbModuleName, 55 ObjectName ejbContainerName) 56 throws MalformedObjectNameException , 57 InvalidParentException 58 { 59 this(name, ejbModuleName, ejbContainerName, null, null); 60 } 61 74 public StatefulSessionBean(String name, ObjectName ejbModuleName, 75 ObjectName ejbContainerName, String jndiName, String localJndiName) 76 throws MalformedObjectNameException , 77 InvalidParentException 78 { 79 super(J2EETypeConstants.StatefulSessionBean, name, ejbModuleName, 80 ejbContainerName, jndiName, localJndiName); 81 stats = new StatefulSessionBeanStatsImpl(); 82 } 83 84 86 95 public Stats getstats() 96 { 97 try 98 { 99 updateCommonStats(stats); 100 101 ObjectName poolName = getContainerPoolName(); 102 RangeStatisticImpl readyCount = (RangeStatisticImpl) stats.getMethodReadyCount(); 103 Integer poolSize = (Integer ) server.getAttribute(poolName, "CurrentSize"); 104 readyCount.set(poolSize.longValue()); 105 106 ObjectName cacheName = getContainerCacheName(); 107 RangeStatisticImpl passiveCount = (RangeStatisticImpl) stats.getPassiveCount(); 108 Long passive = (Long ) server.getAttribute(cacheName, "PassivatedCount"); 109 passiveCount.set(passive.longValue()); 110 } 111 catch (Exception e) 112 { 113 log.debug("Failed to retrieve stats", e); 114 } 115 return stats; 116 } 117 118 public void resetStats() 119 { 120 stats.reset(); 121 } 122 124 126 public String toString() 127 { 128 return "StatefulSessionBean { " + super.toString() + " } []"; 129 } 130 131 } 132 | Popular Tags |