简体   繁体   English

如何在Spring RMI设置中绑定IP地址?

[英]How to bind a ip address in Spring rmi settings?

How to bind a ip address in spring rmi settings? 如何在Spring RMI设置中绑定IP地址? Instead of listen all IP in Server. 而不是监听服务器中的所有IP。

Currently I am using: 目前,我正在使用:

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    <property name="serviceName" value="TestRmiService" />
    <property name="service" ref="testRmiServiceBean" />
    <property name="serviceInterface"
        value="org.test.TestRmiService" />
    <!-- defaults to 1099 -->
    <property name="registryPort" value="1099" />
    <!-- <property name="registryHost" value="127.0.0.1" /> this not working -->
</bean>

I am not sure but its not possbile to bind RMI just giving registryHost. 我不确定,但仅给registryHost绑定RMI是不可能的。 You have two alternative to bind your custom IP. 您有两种选择来绑定自定义IP。

First one is write your own implementation of RMIServerSocketFactory or just pass -Djava.rmi.server.hostname =Your.Ip.Address as a parameter. 第一个是编写您自己的RMIServerSocketFactory或者只是将-Djava.rmi.server.hostname = Your.Ip.Address作为参数传递。

For the details just review the source code of RmiServiceExporter and the Java Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4880793 有关详细信息,请查看RmiServiceExporter的源代码和Java Bug: http ://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4880793

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM