[jboss-cvs] JBossAS SVN: r77167 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 18 15:41:08 EDT 2008
Author: pferraro
Date: 2008-08-18 15:41:08 -0400 (Mon, 18 Aug 2008)
New Revision: 77167
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ObjectNamePatternLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadCountLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
Log:
Allow mbean server injection - to allow mock object injection for tests.
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -35,7 +35,7 @@
*/
public class HeapMemoryUsageLoadMetric extends SingleLoadMetricSource
{
- private final MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
+ private final MemoryMXBean bean;
/**
* Create a new SystemLoadBalanceMetricProvider.
@@ -44,7 +44,19 @@
*/
public HeapMemoryUsageLoadMetric(LoadMetricSourceRegistration registration)
{
+ this(registration, ManagementFactory.getMemoryMXBean());
+ }
+
+ /**
+ * Create a new SystemLoadBalanceMetricProvider.
+ *
+ * @param registration
+ */
+ public HeapMemoryUsageLoadMetric(LoadMetricSourceRegistration registration, MemoryMXBean bean)
+ {
super(registration);
+
+ this.bean = bean;
}
/**
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ObjectNamePatternLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ObjectNamePatternLoadMetricSource.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ObjectNamePatternLoadMetricSource.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -40,14 +40,21 @@
*/
public abstract class ObjectNamePatternLoadMetricSource extends AbstractLoadMetricSource
{
- private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ private final MBeanServer server;
private volatile ObjectName objectNamePattern;
private transient Set<ObjectName> objectNames;
protected ObjectNamePatternLoadMetricSource(LoadMetricSourceRegistration registration)
{
+ this(registration, ManagementFactory.getPlatformMBeanServer());
+ }
+
+ protected ObjectNamePatternLoadMetricSource(LoadMetricSourceRegistration registration, MBeanServer server)
+ {
super(registration);
+ this.server = server;
+
try
{
this.objectNamePattern = ObjectName.getInstance(this.defaultObjectNamePattern());
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -42,7 +42,7 @@
*/
public class OperatingSystemLoadMetricSource extends AbstractLoadMetricSource
{
- private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ private final MBeanServer server;
private final ObjectName name;
/**
@@ -52,7 +52,19 @@
*/
public OperatingSystemLoadMetricSource(LoadMetricSourceRegistration registration)
{
+ this(registration, ManagementFactory.getPlatformMBeanServer());
+ }
+
+ /**
+ * Create a new OperatingSystemLoadMetricSource.
+ *
+ * @param registration
+ */
+ public OperatingSystemLoadMetricSource(LoadMetricSourceRegistration registration, MBeanServer server)
+ {
super(registration);
+
+ this.server = server;
try
{
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
+import javax.management.MBeanServer;
+
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetricSourceRegistration;
/**
@@ -42,6 +44,17 @@
}
/**
+ * Create a new GlobalRequestProcessorLoadMetricSource.
+ *
+ * @param registration
+ * @param server
+ */
+ public RequestProcessorLoadMetricSource(LoadMetricSourceRegistration registration, MBeanServer server)
+ {
+ super(registration, server);
+ }
+
+ /**
* @{inheritDoc}
* @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.ObjectNamePatternLoadMetricSource#defaultObjectNamePattern()
*/
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
+import javax.management.MBeanServer;
+
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetricSourceRegistration;
/**
@@ -42,6 +44,17 @@
}
/**
+ * Create a new SessionLoadMetricSource.
+ *
+ * @param registration
+ * @param server
+ */
+ public SessionLoadMetricSource(LoadMetricSourceRegistration registration, MBeanServer server)
+ {
+ super(registration, server);
+ }
+
+ /**
* @{inheritDoc}
* @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.ObjectNamePatternLoadMetricSource#defaultObjectNamePattern()
*/
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadCountLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -32,7 +32,7 @@
*/
public class ThreadCountLoadMetric extends SingleLoadMetricSource
{
- private ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ private final ThreadMXBean bean;
/**
* Create a new ThreadCountLoadMetric.
@@ -41,7 +41,19 @@
*/
public ThreadCountLoadMetric(LoadMetricSourceRegistration registration)
{
+ this(registration, ManagementFactory.getThreadMXBean());
+ }
+
+ /**
+ * Create a new ThreadCountLoadMetric.
+ *
+ * @param registration
+ */
+ public ThreadCountLoadMetric(LoadMetricSourceRegistration registration, ThreadMXBean bean)
+ {
super(registration);
+
+ this.bean = bean;
}
/**
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-08-18 17:58:04 UTC (rev 77166)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-08-18 19:41:08 UTC (rev 77167)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
+import javax.management.MBeanServer;
+
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetricSourceRegistration;
/**
@@ -41,6 +43,17 @@
super(registration);
}
+ /**
+ * Create a new ThreadPoolLoadMetricSource.
+ *
+ * @param registration
+ * @param server
+ */
+ public ThreadPoolLoadMetricSource(LoadMetricSourceRegistration registration, MBeanServer server)
+ {
+ super(registration, server);
+ }
+
protected String defaultObjectNamePattern()
{
return "Catalina:type=ThreadPool,name=*";
More information about the jboss-cvs-commits
mailing list