aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes client being aware of the mode 'local' or 'remote' 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 "client being aware of the mode Watch "client being aware of the mode New topic
Author

client being aware of the mode 'local' or 'remote'

Rasika Chitnis
Ranch Hand

Joined: Jun 19, 2001
Posts: 131
I have read some postings in this forum which say that the client should not be aware of the mode in which it connects to the database. I agree to it. But then, as I was finishing my client code, I came across a need to look at the mode. I want to call the 'close' method in Data class, from client only when the mode is local. That made me think again, and I realized that my client is using 'mode' for one more thing i.e. to decide if to instantiate Data or do a lookup for remote object.
why are we saying then, that client should not be aware of the mode ?
any feedback is appreciated. thanks
Angus MacCuish
Greenhorn

Joined: Nov 21, 2001
Posts: 22
You'll need to know the mode to decide whether to use Local vs Remote, but other than that the mode should be irrelevant.
In remote mode close() can be an empty no-op implementation of this interface method, or it can call a similar method on the RMI object to notidy the server that the client has disconnected - may or may not be useful depending on your design.
Cheers
Gus


SCJP, SCJD, SCWCD, SCEA(I)
Angus MacCuish
Greenhorn

Joined: Nov 21, 2001
Posts: 22
For 'notidy' read 'notify' !!
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Indeed. You have this DataInterface (or whatever you called it) with a method called "close()". Now you have to carefully distinguish semantics (meaning) from implementation.
  • The meaning of the close() method is "I'm through with you, release all my resources".
  • In local mode, the entire database file is yours, so the implementation will be to close the file.
  • In networked mode, the database file is shared, but you may own a couple of locks because of application bugs or whatever. The implementation of close() may clean up any locks held by the client.
  • In other words, when you specify an interface you do not just specify a bunch of method signatures. You also specify what these methods mean, allowing code that uses the interface not to worry about the implementation. If this is not true, you may have correctly implemented the methods but you have failed to correctly implement the semantics.
    - Peter
    [This message has been edited by Peter den Haan (edited December 05, 2001).]
Rasika Chitnis
Ranch Hand

Joined: Jun 19, 2001
Posts: 131
thanks, guys, for your feedback. It helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client being aware of the mode 'local' or 'remote'