PDA

View Full Version : Exposing multiple interfaces using RMI Proxy



kapilgupta
May 22nd, 2006, 01:20 AM
Hi,
I have a requirement to expose two interfaces implemented by my bean using Spring RMI exporter. But Spring documentation says that it is not possible, see
http://www.springframework.org/docs/reference/remoting.html
The design requires that my beans implements one generic interfaces and one specific interface. I need to typecast bean to the specific interface on certain condition. Is there any way to achieve this?
Thanks,
Kapil

Andreas Senft
May 22nd, 2006, 02:37 AM
As far as I know, that is a limitation of RMI where you are supposed to export an instance with one specific remote interface. However, you are able to export an instance more than once. Then you could export it each time with another interface. On the client side you have then, however, multiple instances of incompatible types.

Regards,
Andreas

kapilgupta
May 22nd, 2006, 05:45 AM
Thanks for your quick reply Andreas!
I do not want multiple instances of same bean at client side. Is there any other way to achieve this?

Andreas Senft
May 22nd, 2006, 06:17 AM
Maybe you could try to have a Remote interface extending both interfaces.
When exposing that interface remotely, the extended interfaces should be visible as well.

E.g.:



public interface Foo1 {

void bar1() throws RemoteException;
}

public interface Foo2 {

void bar2() throws RemoteException;
}

public interface FooRemote extends Remote, Foo1, Foo2 {}


Regards,
Andreas

kapilgupta
May 22nd, 2006, 08:00 AM
I tried extending my specific interface from the generic one and exposing the specific one from RMI, and it works. But now I have to check its implication on my design.
Thanks,
Kapil