User: starksm
Date: 01/09/11 11:35:03
Modified: src/main/org/jboss/monitor BeanCacheMonitor.java
Log:
Convert all logging to org.jboss.logging.Logger which is a subclass of
org.apache.log4j.Category.
Revision Changes Path
1.4 +88 -81 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BeanCacheMonitor.java 2001/08/03 17:15:54 1.3
+++ BeanCacheMonitor.java 2001/09/11 18:35:03 1.4
@@ -24,94 +24,101 @@
import org.jboss.ejb.Container;
import org.jboss.ejb.EntityContainer;
import org.jboss.ejb.StatefulSessionContainer;
+import org.jboss.logging.Logger;
import org.jboss.monitor.client.BeanCacheSnapshot;
/**
- *
+ *
* @see Monitorable
* @author <a href="mailto:[EMAIL PROTECTED]">Simone Bordet</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class BeanCacheMonitor
- implements BeanCacheMonitorMBean, MBeanRegistration
+ implements BeanCacheMonitorMBean, MBeanRegistration
{
- // 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 ----------------------------------------------------
+
+ // Attributes ---------------------------------------------------
+ static Logger log = Logger.create(BeanCacheMonitor.class);
+ 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)
+ {
+ log.error("getDeployedApplications failed", 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