INT-2541: Fix @ManagedResource JMX registration

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

The `IntegrationMBeanExporter` doesn't register any `@ManagedResource` automatically.
Its `autoDetection` is disabled by default.
Hence such a components like `AbstractMessageGroupStore`
or `WireTap` aren't exposed to the JMX by the `IntegrationMBeanExporter`.
From other side `MBeanExporterHelper` aims to help to avoid duplicate exposing if
an `MBeanExporter` is presented in the CTX.
But `MBeanExporterHelper` did that unconditionally just for the whole `org.springframework.integration` package.
Therefore components which aren't EIP ones aren't exposed to the JMX at all.

* Fix `MBeanExporterHelper` to deal for exclusion based on the `@IntegrationManagedResource` annotation.
* Remove `@IntegrationManagedResource` from those components which aren't EIP.
* Make some polishing in the JMX tests.
This commit is contained in:
Artem Bilan
2015-10-12 15:34:32 -04:00
committed by Gary Russell
parent f049541b00
commit ccc1568b89
11 changed files with 69 additions and 94 deletions

View File

@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jmx
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
<context:mbean-server id="mbs" />
<context:mbean-server id="mbs"/>
<context:mbean-export server="mbs" default-domain="test.MessageStore"/>
<jmx:mbean-export server="mbs" default-domain="test.MessageStore"/>
<bean id="messageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
</beans>

View File

@@ -13,8 +13,10 @@
http://www.springframework.org/schema/integration/jmx
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
<context:mbean-export default-domain="#{T(java.util.UUID).randomUUID().toString()}"/>
<context:mbean-server/>
<context:mbean-export default-domain="#{T(java.util.UUID).randomUUID().toString()}"/>
<jmx:mbean-export default-domain="#{T(java.util.UUID).randomUUID().toString()}"/>
<si:message-history/>
@@ -26,7 +28,7 @@
object-name="test.publisher:name=publisher"
default-notification-type="default.type">
<jmx:request-handler-advice-chain>
<bean class="org.springframework.integration.jmx.config.NotificationPublishingChannelAdapterParserTests$FooADvice"/>
<bean class="org.springframework.integration.jmx.config.NotificationPublishingChannelAdapterParserTests.FooAdvice"/>
</jmx:request-handler-advice-chain>
</jmx:notification-publishing-channel-adapter>

View File

@@ -173,14 +173,14 @@ public class NotificationPublishingChannelAdapterParserTests {
}
public static class FooADvice extends AbstractRequestHandlerAdvice {
public static class FooAdvice extends AbstractRequestHandlerAdvice {
@Override
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) throws Exception {
adviceCalled++;
new RuntimeException("foo").printStackTrace();
return callback.execute();
}
}
}