• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection Factory objects RMI

 
Dan Myers
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have a little question on the Connection Factory and RMI.
On the client i call all business functionality by a Interface IDataAccess which contains
methods lik book(), criteriasearch().
Based on the operating mode the client member variable of IDataAccess references a local (DataAccessLocal) or remote Implementation
(DataAccessRemote which is returned by the Factory). So i do not have to distinguish what source(local or remote) is connected at the client.
My Problem:
==========
Both classes implement the same Interface IDataAccess (Not Remote)
-DataAccessLocal must not be declared as remoteobject
-DataAccessRemote must be declared as remoteObject, how can i do it without adding a new Interface with the same
content like IDataAccess +RemoteInterface declarations ?
Thanks for
comments
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dan Myers:
how can i do it without adding a new Interface with the same
content like IDataAccess +RemoteInterface declarations?

I used 2 interfaces... others have made their one interface implement Remote.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan,
I had only a single interface which extened Remote and all of the public Data methods were tagged to throw RemoteException, even though when locally connected, no RemoteException could be thrown. I used a Bulider Pattern to deal with the problem you mention. The Bulider Pattern is a great way to shift compile time decisions to runtime. At the point in your client bootstrap code that you know which mode you want, then you simply "build" that type of connection. As you mentioned, for remote mode you would build an object that most likely extended UnicastRemote object and not for the local variety.

Hope this helps,
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic