File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Connection Factory objects RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Connection Factory objects RMI" Watch "Connection Factory objects RMI" New topic

Connection Factory objects RMI

Dan Myers

Joined: Aug 20, 2002
Posts: 7
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
Nate Johnson
Ranch Hand

Joined: May 13, 2002
Posts: 301
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.

scwcd, scjd, scjp<br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: Connection Factory objects RMI
It's not a secret anymore!