User: starksm
Date: 01/11/20 01:42:55
Modified: src/main/org/jboss/monitor Tag: Branch_2_4
BeanCacheMonitor.java
Log:
Change to the unified log4j based org.jboss.logging.Logger class.
Revision Changes Path
No revision
No revision
1.1.6.1 +74 -82 jboss/src/main/org/jboss/monitor/BeanCacheMonitor.java
Index: BeanCacheMonitor.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/monitor/BeanCacheMonitor.java,v
retrieving revision 1.1
retrieving revision 1.1.6.1
diff -u -r1.1 -r1.1.6.1
--- BeanCacheMonitor.java 2000/12/18 10:25:06 1.1
+++ BeanCacheMonitor.java 2001/11/20 09:42:55 1.1.6.1
@@ -25,93 +25,85 @@
import org.jboss.ejb.EntityContainer;
import org.jboss.ejb.StatefulSessionContainer;
import org.jboss.monitor.client.BeanCacheSnapshot;
+import org.jboss.util.ServiceMBeanSupport;
/**
- *
+ *
* @see Monitorable
* @author Simone Bordet ([EMAIL PROTECTED])
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.1.6.1 $
*/
-public class BeanCacheMonitor
- implements BeanCacheMonitorMBean, MBeanRegistration
+public class BeanCacheMonitor extends ServiceMBeanSupport
+ implements BeanCacheMonitorMBean
{
- // Constants ----------------------------------------------------
-
- // Attributes ---------------------------------------------------
- MBeanServer m_mbeanServer;
-
- // Static -------------------------------------------------------
-
- // Constructors -------------------------------------------------
- public BeanCacheMonitor() {}
-
- // Public -------------------------------------------------------
-
- // MBeanRegistration implementation -----------------------------------
- public ObjectName preRegister(MBeanServer server, ObjectName name)
- throws Exception
- {
- m_mbeanServer = server;
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {}
- public void preDeregister() throws Exception {}
- public void postDeregister() {}
-
- // CacheMonitorMBean implementation -----------------------------------
- public BeanCacheSnapshot[] getSnapshots()
- {
- Iterator applications = null;
- // Get map of deployed applications
- try
- {
- applications = (Iterator)m_mbeanServer.invoke(new
ObjectName(ContainerFactoryMBean.OBJECT_NAME), "getDeployedApplications", new Object[]
{}, new String[] {});
- }
- catch (JMException x)
- {
- org.jboss.logging.Logger.exception(x);
- return null;
- }
-
- ArrayList cacheSnapshots = new ArrayList();
-
- // For each application, getContainers()
- while (applications.hasNext())
- {
- Application app = (Application)applications.next();
- String name = app.getName();
-
- // Loop on each container of the application
- for (Iterator containers = app.getContainers().iterator();
containers.hasNext();)
- {
- // Get the cache for each container
- InstanceCache cache = null;
- Object container = containers.next();
- if (container instanceof EntityContainer)
- {
- cache =
((EntityContainer)container).getInstanceCache();
- }
- else if (container instanceof
StatefulSessionContainer)
- {
- cache =
((StatefulSessionContainer)container).getInstanceCache();
- }
-
- // Take a cache snapshot
- if (cache instanceof Monitorable)
- {
- BeanCacheSnapshot snapshot = new
BeanCacheSnapshot();
- snapshot.m_application = name;
- snapshot.m_container =
((Container)container).getBeanMetaData().getEjbName();
- ((Monitorable)cache).sample(snapshot);
- cacheSnapshots.add(snapshot);
- }
- }
- }
-
- return (BeanCacheSnapshot[])cacheSnapshots.toArray(new
BeanCacheSnapshot[0]);
- }
-
- // Inner classes -------------------------------------------------
+ // Constants ----------------------------------------------------
+
+ // Static -------------------------------------------------------
+
+ // Constructors -------------------------------------------------
+ public BeanCacheMonitor()
+ {}
+
+ // Public -------------------------------------------------------
+ public String getName()
+ {
+ return "BeanCacheMonitor";
+ }
+ // CacheMonitorMBean implementation -----------------------------------
+ public BeanCacheSnapshot[] getSnapshots()
+ {
+ Iterator applications = null;
+ // Get map of deployed applications
+ try
+ {
+ applications = (Iterator)server.invoke(new
ObjectName(ContainerFactoryMBean.OBJECT_NAME), "getDeployedApplications", new Object[]
+ {}, new String[]
+ {});
+ }
+ catch (JMException x)
+ {
+ log.warn("getDeployedApplications", x);
+ return null;
+ }
+
+ ArrayList cacheSnapshots = new ArrayList();
+
+ // For each application, getContainers()
+ while (applications.hasNext())
+ {
+ Application app = (Application)applications.next();
+ String name = app.getName();
+
+ // Loop on each container of the application
+ for (Iterator containers = app.getContainers().iterator();
containers.hasNext();)
+ {
+ // Get the cache for each container
+ InstanceCache cache = null;
+ Object container = containers.next();
+ if (container instanceof EntityContainer)
+ {
+ cache = ((EntityContainer)container).getInstanceCache();
+ }
+ else if (container instanceof StatefulSessionContainer)
+ {
+ cache = ((StatefulSessionContainer)container).getInstanceCache();
+ }
+
+ // Take a cache snapshot
+ if (cache instanceof Monitorable)
+ {
+ BeanCacheSnapshot snapshot = new BeanCacheSnapshot();
+ snapshot.m_application = name;
+ snapshot.m_container =
((Container)container).getBeanMetaData().getEjbName();
+ ((Monitorable)cache).sample(snapshot);
+ cacheSnapshots.add(snapshot);
+ }
+ }
+ }
+
+ return (BeanCacheSnapshot[])cacheSnapshots.toArray(new BeanCacheSnapshot[0]);
+ }
+
+ // Inner classes -------------------------------------------------
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development