1 22 package org.jboss.management.j2ee; 23 24 import org.jboss.logging.Logger; 25 import org.jboss.management.j2ee.statistics.EntityBeanStatsImpl; 26 import org.jboss.management.j2ee.statistics.RangeStatisticImpl; 27 28 import javax.management.MalformedObjectNameException ; 29 import javax.management.ObjectName ; 30 import javax.management.j2ee.statistics.Stats ; 31 32 39 public class EntityBean extends EJB 40 implements EntityBeanMBean 41 { 42 43 45 private EntityBeanStatsImpl stats; 46 47 49 private static Logger log = Logger.getLogger(EntityBean.class); 50 51 53 public EntityBean(String name, ObjectName ejbModuleName, 54 ObjectName ejbContainerName) 55 throws MalformedObjectNameException , 56 InvalidParentException 57 { 58 this(name, ejbModuleName, ejbContainerName, null, null); 59 } 60 61 74 public EntityBean(String name, ObjectName ejbModuleName, 75 ObjectName ejbContainerName, String jndiName, String localJndiName) 76 throws MalformedObjectNameException , 77 InvalidParentException 78 { 79 super(J2EETypeConstants.EntityBean, name, ejbModuleName, ejbContainerName, 80 jndiName, localJndiName); 81 stats = new EntityBeanStatsImpl(); 82 } 83 84 public Stats getstats() 86 { 87 try 88 { 89 updateCommonStats(stats); 90 91 ObjectName poolName = getContainerPoolName(); 92 RangeStatisticImpl pooledCount = (RangeStatisticImpl) stats.getReadyCount(); 93 Integer poolSize = (Integer ) server.getAttribute(poolName, "CurrentSize"); 94 pooledCount.set(poolSize.longValue()); 95 96 ObjectName cacheName = getContainerCacheName(); 97 RangeStatisticImpl readyCount = (RangeStatisticImpl) stats.getReadyCount(); 98 Long count = (Long ) server.getAttribute(cacheName, "CacheSize"); 99 readyCount.set(count.longValue()); 100 } 101 catch (Exception e) 102 { 103 log.debug("Failed to retrieve stats", e); 104 } 105 return stats; 106 } 107 108 public void resetStats() 109 { 110 stats.reset(); 111 } 112 113 115 117 public String toString() 118 { 119 return "EntityBean { " + super.toString() + " } []"; 120 } 121 } 122 | Popular Tags |