java

位置:IT落伍者 >> java >> 浏览文章

spring和jmx


发布日期:2019年06月08日
 
spring和jmx

<?xml version= encoding=UTF?>

<beans xmlns=

xmlns:xsi=instance

xsi:schemaLocation= beansxsd>

<bean id=mbeanManager

class=servermbeanMBeanManager />

<bean id=mbeanTest

class=servermbeanMBeanTest />

<bean id=mbeanServer

class=orgspringframeworkjmxsupportMBeanServerFactoryBean>

</bean>

<bean id=assembler

class=orgspringframeworkjmxexportassemblerMetadataMBeanInfoAssembler>

<property name=attributeSource ref=jmxAttributeSource />

</bean>

<bean id=jmxAttributeSource

class=orgspringframeworkjmxexportannotationAnnotationJmxAttributeSource />

<bean id=mBeanExporter

class=orgspringframeworkjmxexportMBeanExporter>

<property name=server ref=mbeanServer />

<property name=assembler ref=assembler />

<property name=beans>

<map>

<entry key=eci:name=testBean

valueref=mbeanTest />

<entry key=eci:name=manageBean

valueref=mbeanManager />

</map>

</property>

<property name=notificationListeners>

<list>

<bean

class=orgspringframeworkjmxexportNotificationListenerBean>

<constructorarg ref=testNotificationListener />

<property name=mappedObjectNames>

<list>

<value>eci:name=testBean</value>

<value>eci:name=manageBean</value>

</list>

</property>

<property name=notificationFilter

ref=testNotificationListener />

</bean>

</list>

</property>

</bean>

<bean id=testNotificationListener class=servernotificationTestNotificationListener/>

<bean id=registry class=orgspringframeworkremotingrmiRmiRegistryFactoryBean>

<property name=port value=/>

</bean>

<bean id=serverConnector

class=orgspringframeworkjmxsupportConnectorServerFactoryBean >

<property name=serviceUrl value=service:jmx:rmi://localhost/jndi/rmi://localhost:/eci/>

<!<property name=environment>

<map>

<entry key=jmxremotexpasswordfile>

<value>jmxremotepassword</value>

</entry>

<entry key=jmxremotexaccessfile>

<value>jmxremoteaccess</value>

</entry>

</map>

</property>>

</bean>

</beans>

针对environment设置需要补充下

这是针对安全设置的jmxremotepasswordjmxremoteaccess分别是保存的访问权限的信息和密码这两个是文 件这两个文件可以参考在jdk目录下的\jre\lib\management下的模板我们可以根据不同的安全来确定是否需要设置用户名和密码

java文件读入spring配置文件并启动jmx server

Java 代码

package servermain;

import orgntextsupport*;

public class ServerMain {

public static void main(String[] args) {

@SuppressWarnings(unused)

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(

/jmxServerContextxml);

while (true) {

try {

Threadsleep();

} catch (InterruptedException e) {

eprintStackTrace();

}

}

}

}

               

上一篇:详解Spring的配置文件

下一篇:Spring中的四种声明式事务的配置