GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Local or Network based connection 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 "Local or Network based connection" Watch "Local or Network based connection" New topic
Author

Local or Network based connection

Sanjeev Kumar
Greenhorn

Joined: Dec 22, 2000
Posts: 8
Hi,
Can somebody explain the following paragraph from the FBN assignment!
"The user interface should connect to the database using either a local or a network based connection according to user choice."
I am using RMI for network communication.
Sanjeev
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
I believe that this refers to you determining where the client is located - if in the same JVM, do not use RMI, but if remote, use it. That's the way I'm going to approach it, anyway...
Sanjeev Kumar
Greenhorn

Joined: Dec 22, 2000
Posts: 8
Thanks Paul,
But, why double work. Even if you are working with single VM the RMI network will support that.
Sanjeev
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
In my instructions under "Overall Architecture" it says:
"Additionally, the program must be able to work in a non-networked mode. In this mode, the database and user interface run in the same VM and no networking is performed. The user must be able to select the operating mode, although it is acceptable that the program stay in one mode once it has started up."
So - my instructions at least - say that you have to code it both ways, with one passing the networking (sockets or RMI) altogether. This makes sense in the real world also, as someone local shouldn't have to go through the overhead of networking for a local client.
Sounds like a good place for overloaded methods...


[This message has been edited by Paul Smiley (edited December 29, 2000).]
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
...or the Adapter pattern
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
Not familiar with that Jerry. Do you have a link or a reference to info about it?
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
Paul,
Yes, go to http://c2.com/cgi/wiki?PatternIndex for tons of useful pattern info. In fact, be sure and bookmark http://www.cetus-links.de, it's a gold mine.
I used Adapter here because I had both Database and RemoteDatabase interfaces - they were almost identical but RemoteDatabase had a RemoteException on every method (of course). By writing an adapter class I'm able to program the client UI solely in terms of Database. In local mode, I use a subclass of Data which implements Database. In RMI mode, I get a RemoteDatabase from the server and plug it into the adapter, which handles all the RemoteExceptions.
Jerry
[This message has been edited by Jerry Pulley (edited December 29, 2000).]
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
Thanks Jerry! That's a LOT of information!
Paul
Sanjeev Kumar
Greenhorn

Joined: Dec 22, 2000
Posts: 8
Thanks Jerry and Paul!
Using Adapter class is a great idea. I will follow that.
Sanjeev
 
GeeCON Prague 2014
 
subject: Local or Network based connection