INT-3653: JMX: Add Pluggable Metrics Factory

JIRA: https://jira.spring.io/browse/INT-3653

Also switch to using `System.nanoTime()` for deltas.

INT-3653: Polishing; PR Comments

INT-3653: Polishing

* Fix `NullChannel` for the generic type
* Add `Assert.notNull` for metrics setters and for the result of `MetricsFactory`
* Fix compile and JavaDocs warnings
This commit is contained in:
Gary Russell
2015-02-20 20:20:34 +02:00
committed by Artem Bilan
parent 8cba6e6d67
commit a4a6b7094b
25 changed files with 733 additions and 301 deletions

View File

@@ -21,7 +21,8 @@
object-name-static-properties="appProperties"
object-naming-strategy="keyNamer"
counts-enabled="foo, !baz, ba*"
stats-enabled="fiz, buz" />
stats-enabled="fiz, buz"
metrics-factory="mf" />
<util:properties id="appProperties">
<prop key="foo">foo</prop>
@@ -42,4 +43,6 @@
<si:channel id="buz" />
<bean id="mf" class="org.springframework.integration.monitor.DefaultMetricsFactory" />
</beans>

View File

@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.channel.management.MessageChannelMetrics;
import org.springframework.integration.monitor.IntegrationMBeanExporter;
import org.springframework.integration.monitor.MetricsFactory;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
@@ -82,6 +83,8 @@ public class MBeanExporterParserTests {
metrics = context.getBean("buz", MessageChannelMetrics.class);
assertTrue(metrics.isCountsEnabled());
assertTrue(metrics.isStatsEnabled());
MetricsFactory factory = context.getBean(MetricsFactory.class);
assertSame(factory, TestUtils.getPropertyValue(exporter, "metricsFactory"));
exporter.destroy();
}