简体   繁体   English

没有Java静态方法的RMI

[英]No RMI for Java static methods

RMI, Remote Method Invocation, works only on Java object methods. RMI(远程方法调用)仅适用于Java对象方法。 In order to make an object remoteable, it has to be exported for stub generation, bind to a rmiregistry, and so on. 为了使对象可远程运行,必须将其导出以生成存根,绑定到rmiregistry等。

And on the user side the object has to be look up and so on. 在用户方面,必须查找对象,依此类推。 The whole instantiation process is needed in oder to realize RMI for a Java object. 为实现Java对象的RMI,整个实例化过程是必需的。

But why are Java static methods not enabled to be invoked remotely? 但是为什么不启用Java静态方法才能远程调用呢? Are there reasons, which would have been critical to the semantic, that Java classes/static methods are not remoteable? 是否存在Java类/静态方法不可远程的原因(对于语义至关重要)?

RMI uses Java interfaces to describe remote operations. RMI使用Java接口描述远程操作。 Static methods can't be expressed via interfaces, and therefore cannot be remoted. 静态方法无法通过接口表示,因此无法远程进行。 That's the way it was designed. 这就是它的设计方式。

If you need to access static methods via RMI, you need to wrap them in something that can be exported. 如果需要通过RMI访问静态方法,则需要将它们包装在可以导出的内容中。

Java接口不支持静态方法,要使用RMI调用对象,它必须实现和接口,然后将其作为服务公开在RMI注册表中。

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

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