0

I am confused a bit about Java RMI codebase property.

In here http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/codebase.html it says that codebase is set in client because client can create custom subclasses of some class so the server needs to download the class.

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? Because if it is implementing remote interface server does not need to download anything because on the server side there will be stubs.

But why there is a need for codebase needed on the server side. It says that

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.

Why does the client need to request stub class definition if it uses only stub implementation.

4

1 回答 1

1

我是否理解客户端代码库只有在远程方法的参数之一是某个未实现远程接口的类时才重要?

对,那是正确的。

但是为什么需要在服务器端需要代码库。

如果服务器想要返回未在客户端部署的类的实例,并且正如您所说,那不是远程对象。

如果仅使用存根实现,为什么客户端需要请求存根类定义。

那是没有区别的区别。它不能在没有类的情况下使用类的实例。当然,它不必下载它:您可以直接将其部署到客户端。

您需要了解整个代码库系统在两端都是可选的。这是一个部署解决方案。如果您不需要它提供的灵活性,请不要使用它。

于 2013-06-16T00:42:18.393 回答