我对 Java RMI 代码库属性有点困惑。
在这里http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/codebase.html它说代码库是在客户端设置的,因为客户端可以创建某个类的自定义子类,因此服务器需要下载该类。
我是否理解,仅当远程方法的参数之一是某个未实现远程接口(interface)的类时,客户端代码库才重要?因为如果它实现远程接口(interface),服务器不需要下载任何东西,因为在服务器端会有 stub 。
但是为什么服务器端需要代码库。它说的是
The client requests the class definition from the codebase. The codebase the client uses is the URL that was annotated to the stub instance when the stub class was loaded by the registry. Back in step 1, the annotated stub for the exported object was then registered with the Java RMI registry bound to a name.
如果客户端仅使用 stub 实现,为什么需要请求 stub 类定义。
最佳答案
Do I understand that client codebase will matter only if one of the parameters to the remote method is some class that is not implementing remote interface?
是的,这是正确的。
But why there is a need for codebase needed on the server side.
如果服务器想要返回一个未部署在客户端的类的实例,并且正如您所说,这不是远程对象。
Why does the client need to request stub class definition if it uses only stub implementation.
这是没有区别的区别。如果没有类,它就无法使用该类的实例。当然,它不必下载:您可以将其直接部署到客户端。
您需要了解整个代码库系统在两端都是可选的。这是一个部署解决方案。如果您不需要它提供的灵 active ,请不要使用它。
关于Java RMI - 代码库使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17125262/