File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes urlybird local vs remote connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "urlybird local vs remote connection" Watch "urlybird local vs remote connection" New topic
Author

urlybird local vs remote connection

berry westover
Greenhorn

Joined: Dec 24, 2004
Posts: 5
Boy do I need some help....

Need some help with pseudocode here. How does the GUI client get the local or remote database connection? Does it get the connection thru a factory? If that's the case it seems like the factory must return an interface back to the GUI client. That interface must be common to both the local database connection as well as the remote database connection. Since DBAccess can't be modified I don't see how you can do that becuase you need an interface to extend Remote if you plan on using RMI.

Or does the GUI client maintain two different instance variables one for a local database connection and the other for a remote database connection....and it knows which one to reference to get the actual database operation to be performed based upon how it was started or launched.

HELP!!!
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by berry westover:
Boy do I need some help....

Need some help with pseudocode here. How does the GUI client get the local or remote database connection? Does it get the connection thru a factory? If that's the case it seems like the factory must return an interface back to the GUI client. That interface must be common to both the local database connection as well as the remote database connection. Since DBAccess can't be modified I don't see how you can do that becuase you need an interface to extend Remote if you plan on using RMI.

Or does the GUI client maintain two different instance variables one for a local database connection and the other for a remote database connection....and it knows which one to reference to get the actual database operation to be performed based upon how it was started or launched.

HELP!!!


The answer is in the reply I posted to the "Local Adapter Issue" thread. If you are going the orthodox fat client route, you need to provide the DBAccess interface to your client, regardless of whether its local or remote.

You can do this by using two adapters, the first adapter (DataAdapter) is the interface that extends Remote and adds RemoteException to the method signitures in DBAccess, it might need to add some methods to manage the networking as well. The second adapter (DataProxy) readapts the first one to re-implement DBAccess, this can be done by catching the RemoteException and throwing an unchecked exception. You will need to throw unchecked exceptions in your Data class anyway to handle IOException, so just use the one you used there.

I use a Factory Method in my BookingModel to create an instance of DBAccess that is either a Data object or a DataProxy object based on a standAlone property that was set by the startup aguments.

If you are using the thin client model, you would not expose DBAccess to you client. The Business class on the server would wrap a Data object and the Business class would be exposed over RMI to the client, again using the Proxy pattern and a Factory method. You get to define that one yourself so you can code it as you see fit. People have passed using this model, but I wouldn't risk it since I don't fell I could honestly justify the choice.
berry westover
Greenhorn

Joined: Dec 24, 2004
Posts: 5
Thanks for the reply Peter....

I believe I'm using a fat client. I'm not really sure I understand what this means exactly. My GUI client will be doing alot of the calls to the database directly...is this what u mean by fat client?

I have done the following: I have a class called Data.java that implements the DBAccess interface. I have another interface called RemoteDBAccess which lists the same declarations as DBAccess and adds "throws RemoteException" to each of them. This interface also extends Remote.
I have an adapter called RemoteDBAdapter wich extends UnicastRemoteObject and implements RemoteDBAccess.

I'm totally lost on the second adapter you alluded to. How does the second adapter (DataProxy) readadapt the first one to re-implement DBAccess? I'm not sure what this looks like, could you explain this part to me better...perhaps some pseudo code?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urlybird local vs remote connection
 
Similar Threads
comment design please
Connection Factory pls explain
All of URLy Bird 1.1.3 how to use the same GUI and Data in alone or netword client
Local Mode Considerations
nx:All of URLy Bird1.1.3 about record lock