Reputation: 1896
In a dialog (window) let 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?
Upvotes: 1
Views: 125
Reputation: 691635
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.
Upvotes: 4