package org.jboss.management.j2ee;
import org.jboss.logging.Logger;
import org.jboss.management.j2ee.statistics.RangeStatisticImpl;
import org.jboss.management.j2ee.statistics.StatefulSessionBeanStatsImpl;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.j2ee.statistics.Stats;
public class StatefulSessionBean
extends SessionBean
implements StatefulSessionBeanMBean
{
private static Logger log = Logger.getLogger(StatefulSessionBean.class);
private StatefulSessionBeanStatsImpl stats;
public StatefulSessionBean(String name, ObjectName ejbModuleName,
ObjectName ejbContainerName)
throws MalformedObjectNameException,
InvalidParentException
{
super(J2EETypeConstants.StatefulSessionBean, name, ejbModuleName, ejbContainerName);
stats = new StatefulSessionBeanStatsImpl();
}
public Stats getstats()
{
try
{
updateCommonStats(stats);
ObjectName poolName = getContainerPoolName();
RangeStatisticImpl readyCount = (RangeStatisticImpl) stats.getMethodReadyCount();
Integer poolSize = (Integer) server.getAttribute(poolName, "CurrentSize");
readyCount.set(poolSize.longValue());
ObjectName cacheName = getContainerCacheName();
RangeStatisticImpl passiveCount = (RangeStatisticImpl) stats.getPassiveCount();
Long passive = (Long) server.getAttribute(cacheName, "PassivatedCount");
passiveCount.set(passive.longValue());
}
catch (Exception e)
{
log.debug("Failed to retrieve stats", e);
}
return stats;
}
public void resetStats()
{
stats.reset();
}
public String toString()
{
return "StatefulSessionBean { " + super.toString() + " } []";
}
}