Я использую Spring @Configuration
, и заметил, что @Bean
не регистрируется с использованием JMX.
Боб подключен как
@Bean
protected CountingHttpInterceptor countingHttpInterceptor() {
return new CountingHttpInterceptor();
}
и определение класса
@ManagedResource
public class CountingHttpInterceptor implements HttpRequestInterceptor, HttpResponseInterceptor { /* code here*/ }
Этот файл @Configuration
обрабатывается после создания основного контекста приложения на основе XML и не имеет возможности принять участие в процессе обнаружения, который активируется с помощью определений XML-бинов (org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource
и frieds) .
Как я могу JMX-включить бины из файла @Configuration
?
Обновление : конфигурация xml
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="assembler" ref="assembler"/>
<property name="namingStrategy" ref="namingStrategy"/>
<property name="autodetect" value="true"/>
</bean>
<bean id="jmxAttributeSource" class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/>
<bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>
<bean id="namingStrategy" class="org.springframework.jmx.export.naming.MetadataNamingStrategy">
<property name="attributeSource" ref="jmxAttributeSource"/>
</bean>