开发者

RMI exportObject(Remote obj, PORT); createRegistry(PORT);

开发者 https://www.devze.com 2023-03-27 12:18 出处:网络
I\'m wondering can both the UnicastRemoteObject.exportObject(Re开发者_StackOverflow社区mote,portNo) & LocateRegistry.createRegistry(portNo);

I'm wondering can both the

UnicastRemoteObject.exportObject(Re开发者_StackOverflow社区mote,portNo) & LocateRegistry.createRegistry(portNo);

porNo be the same?

I test it works but I'm worrid if there is any complication?

Why does exportObject need to specify an object to work? when I use exportObject(Remote obj) it throws an NullPointerException.


I'm wondering can both the

UnicastRemoteObject.exportObject(Remote,portNo) &
LocateRegistry.createRegistry(portNo);

portNo be the same?

Yes, unless you are using unequal socket factories, which you aren't. If there is a problem an exception will be thrown.

I test it works but I'm worrid if there is any complication?

Not at all, in fact it's a good idea, saves on listening ports. You can use Registry.REGISTRY_PORT which is reserved at IANA, and should therefore shut down any arguments with netadmins too.

Why does exportObject need to specify an object to work?

Because it is a static method.

when I use exportObject(Remote obj) it throws an StubNotFoundException.

Because you haven't generated a stub. If you are using >= 1.5, you don't need a generated stub, but you do need to specify a port number. If you specify zero you will get a system-allocated port number but if you have already exported a remote object, in this case the Registry, you will share its port, again unless you are using unequal socket factories.

0

精彩评论

暂无评论...
验证码 换一张
取 消