-
Notifications
You must be signed in to change notification settings - Fork 1
Home
万大龙 edited this page Mar 29, 2017
·
1 revision
Welcome to the jmxtrans-integration wiki!
embedded-jmxtrans 整合 Spring、Servlet、InfluxDB
参考EmbeddedJmxTransLoaderListener对象注解
<context-param>
<param-name>jmxtrans.config</param-name>
<param-value>
classpath:jmxtrans.json
classpath:org/jmxtrans/embedded/config/jmxtrans-internals-servlet-container.json
classpath:org/jmxtrans/embedded/config/tomcat-7.json
classpath:org/jmxtrans/embedded/config/jvm-sun-hotspot.json
</param-value>
</context-param>
<listener>
<listener-class>org.jmxtrans.embedded.servlet.EmbeddedJmxTransLoaderListener</listener-class>
</listener>
本人参考 embedded-jmxtrans 的github地址(https://github.com/jmxtrans/embedded-jmxtrans/wiki)配置后,测试完全无效。 阅读代码后采用另种方式:
配置EmbeddedJmxTransFactory
<bean id="jmxtrans" class="org.jmxtrans.embedded.spring.EmbeddedJmxTransFactory" destroy-method="destroy" scope="singleton">
<!-- JMX对象名称 -->
<property name="beanName" value="jmxtrans"/>
<!-- 监听配置文件变化: 每60秒检测一次 -->
<property name="configurationScanPeriodInSeconds" value="60"/>
<!-- 如果未发现指定的配置文件 ,是否忽略 -->
<property name="ignoreConfigurationNotFound" value="true"/>
<!-- 初始配置文件 -->
<property name="configurationUrls">
<list>
<value>classpath:jmxtrans.json</value>
<value>classpath:org/jmxtrans/embedded/config/tomcat-7.json</value>
<value>classpath:org/jmxtrans/embedded/config/jmxtrans-internals.json</value>
<value>classpath:org/jmxtrans/embedded/config/jvm-sun-hotspot.json</value>
</list>
</property>
</bean>
使用EmbeddedJmxTransFactory;此处发现如果不引用上面的对象,则无法调用getObject方法实现对象初始化
<bean class="org.jmxtrans.embedded.EmbeddedJmxTransLauncher">
<property name="jmxtrans" ref="jmxtrans"/>
</bean>
待续...