Re: How to remotely construct a remote object with RMI
On 07/23/2010 03:41 AM, Esmond Pitt wrote:
On 23/07/2010 4:22 AM, Screamin Lord Byron wrote:
public interface Foo extends Remote {
public Bar constructBar(String name);
// other stuff
}
This is a remote factory pattern, and Foo is the factory. You need to
register that in the Registry.
Yes. That's exactly what I need, but I haven't find a way how to do it
(register Foo as a factory). Is this done with some additional
parameters to the Context object?
For now I have something like:
Context initialContext = new InitialContext();
initialContext.bind("rmi:my_foo", myFoo);
I see that there is a constant InitialContext.INITIAL_CONTEXT_FACTORY.
Has that something to do with what I need to do? I suppose it hasn't, as
InitialContext() is just a factory for contexts.
Sorry if I'm asking dumb questions, but I only just started with RMI
yesterday, so there's still quite a mess inside my head.
Could you please give me some pointers on how to register Foo as a
factory in the Registry. I couldn't find any examples of it on Oracle's
site or my books (Core Java I and II - Horstmann/Cornell) either.
Some short example of the registration would be very helpful and
appreciated.
Thank you.
public interface Bar extends Remote {
public void mutate();
}
You don't need to create *any* implementations of BarImpl until somebody
calls constructBar(), and you never need to bind them to the Registry.
Good news. :)
Thanks.