开发者

What is the proper way of using RMI remote objects on the client side?

In a dialog (window) let开发者_如何学Python suppose we have some buttons and when a button is pressed a remote method invocation take place.

How it is better:

  • create the remote object (registry.lookup()) one time and use this object every time we need a remote method invocation?

  • each time we need a remote method invocation we execute registry.lookup() and after this we call the remote method?


Just do your lookup once, and cache the reference to the remote object somewhere. The rmiregistry is just used for bootstrapping. Doing a lookup every time will cause lots of unnecessary network calls.

The ServiceLocator pattern talks about it:

The Service Locator pattern centralizes distributed service object lookups, provides a centralized point of control, and may act as a cache that eliminates redundant lookups.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜