@@ -0,0 +1,1970 @@
+package com.wmz7year.synyed.net.spi;%0A%0Aimport org.springframework.beans.factory.annotation.Value;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.context.annotation.DependsOn;%0Aimport org.springframework.jmx.support.ConnectorServerFactoryBean;%0Aimport org.springframework.remoting.rmi.RmiRegistryFactoryBean;%0A%0A/**%0A * %E9%85%8D%E7%BD%AERMI%E6%94%AF%E6%8C%81%E7%9A%84bean%0A * %0A * @Title: ConfigureRMI.java%0A * @Package com.laimiya.push.spi%0A * @author jiangwei (ydswcy513@gmail.com)%0A * @date 2015%E5%B9%B412%E6%9C%888%E6%97%A5 %E4%B8%8A%E5%8D%889:58:16%0A * @version V1.0%0A */%0A@Configuration%0Apublic class ConfigureRMI %7B%0A%09/**%0A%09 * RMI%E6%9C%8D%E5%8A%A1%E5%9C%B0%E5%9D%80%0A%09 */%0A%09@Value(%22$%7Bserver.rmi.host%7D%22)%0A%09private String rmiHost;%0A%0A%09/**%0A%09 * rmi%E7%9B%91%E5%90%AC%E7%AB%AF%E5%8F%A3%0A%09 */%0A%09@Value(%22$%7Bserver.rmi.port%7D%22)%0A%09private Integer rmiPort;%0A%0A%09@Bean%0A%09public RmiRegistryFactoryBean rmiRegistry() %7B%0A%09%09// %E8%AE%BE%E7%BD%AEjmx%E9%9C%80%E8%A6%81%E7%9A%84%E7%B3%BB%E7%BB%9F%E5%8F%82%E6%95%B0%0A%09%09setJMXProperties();%0A%0A%09%09final RmiRegistryFactoryBean rmiRegistryFactoryBean = new RmiRegistryFactoryBean();%0A%09%09rmiRegistryFactoryBean.setPort(rmiPort);%0A%09%09rmiRegistryFactoryBean.setAlwaysCreate(true);%0A%09%09return rmiRegistryFactoryBean;%0A%09%7D%0A%0A%09private void setJMXProperties() %7B%0A%09%09System.setProperty(%22java.rmi.server.hostname%22, rmiHost);%0A%09%09System.setProperty(%22com.sun.management.jmxremote.port%22, String.valueOf(rmiHost));%0A%09%09System.setProperty(%22com.sun.management.jmxremote.ssl.need.client.auth%22, %22false%22);%0A%09%09System.setProperty(%22com.sun.management.jmxremote.ssl%22, %22false%22);%0A%09%09System.setProperty(%22com.sun.management.jmxremote.authenticate%22, %22false%22);%0A%09%7D%0A%0A%09@Bean%0A%09@DependsOn(%22rmiRegistry%22)%0A%09public ConnectorServerFactoryBean connectorServerFactoryBean() throws Exception %7B%0A%09%09final ConnectorServerFactoryBean connectorServerFactoryBean = new ConnectorServerFactoryBean();%0A%09%09connectorServerFactoryBean.setObjectName(%22connector:name=rmi%22);%0A%09%09connectorServerFactoryBean.setServiceUrl(%0A%09%09%09%09String.format(%22service:jmx:rmi://%25s:%25s/jndi/rmi://%25s:%25s/jmxrmi%22, rmiHost, rmiPort, rmiHost, rmiPort));%0A%09%09return connectorServerFactoryBean;%0A%09%7D%0A%7D%0A

添加远程JMX监控bean 默认暴露端口9999 不需要身份验证