• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

urlybird local vs remote connection

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic