简体   繁体   English

如何从RMI运行时中删除远程对象

[英]How can i remove the remote object from the RMI runtime

When i shutdown the RMI server program by using, serverReg.unbind("LibraryServer"); 当我通过使用关闭RMI服务器程序时, serverReg.unbind("LibraryServer"); it only remove the bound of remote object and it's key ' LibraryServer . 它只删除远程对象的边界,关键是' LibraryServer If i start the server same time it give me an exception ObjID already in use . 如果我同时启动服务器,则会给我一个ObjID already in use异常。 How can i entirety remove remote object from the registry ?. 我如何从注册表中整体删除远程对象? Binding statement of Remote object and it's key is, 远程对象的绑定语句及其关键是,

serverReg.rebind("LibraryServer", new RemoteFactoryImpl());

When I shutdown the RMI server program by using, serverReg.unbind("LibraryServer"); 当我通过使用关闭RMI服务器程序时,serverReg.unbind(“ LibraryServer”); it only remove the [binding] of remote object and it's key 'LibraryServer. 它仅删除远程对象的[binding]及其键'LibraryServer。

Correct. 正确。

If i start the server same time it give me an exception ObjID already in use. 如果我同时启动服务器,则会给我一个已经在使用的异常ObjID。

I'd like to see that exception and stack trace. 我希望看到该异常和堆栈跟踪。

How can I entirety remove remote object from the registry? 如何从注册表中整体删除远程对象?

You have already done so. 您已经这样做了。 You may be looking for a way to unexport the remote object, which is given by UnicastRemoteObject.unexportObject() . 您可能正在寻找一种取消导出远程对象的方法,该方法由UnicastRemoteObject.unexportObject()

However the ObjID already in use error can realistically only be coming from trying to export another Registry from a JVM in which you have already exported one. 但是,实际上, ObjID already in useObjID already in use错误只能是由于尝试从已经导出了JVM的JVM中导出另一个注册表而引起的。 Which doesn't correspond with your description at all. 这根本与您的描述不符。

Ok, i found an answer for that, unbined method only removes connection between remote object and its key. 好的,我找到了答案, unbined方法只会删除远程对象及其键之间的连接。 So cannot restart the rmi server with same remote object because first remote object still in the registry. 因此无法使用相同的远程对象重新启动rmi服务器,因为第一个远程对象仍在注册表中。 By using unexportObject method of UnicastRemoteObject class can be entirely remove remote object from registry. 通过使用UnicastRemoteObject类的unexportObject方法,可以从注册表中完全删除远程对象。 I found it from a post of this . 我从这篇文章中找到了它。

UnicastRemoteObject.unexportObject(serverReg, false);

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

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