• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI Design : Following Max's Book

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Gurus !! I have completed my Database Server degign/coding and now penetraitng to the RMI space.
While I was following Max's book, I got confused on the following topics.
Page 133 : Explains about DBClient interface. The name is somewhat misleading. It should be something like DBService.
Page 173 : DBClient interface doesn't throw RemoteException for the interface methods.
Here is my RMI design for Bodgitt and Scarper. Please comment.
DataService.java

DataAdapter.java

DataConnector.java

DataRemote.java

[ October 02, 2003: Message edited by: Suds Pati ]
[Andrew: Removed lots of code - see comment below]
[ October 02, 2003: Message edited by: Andrew Monkhouse ]
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suds,
Sorry, I deleted a lot of your code.
In general we allow people to ask for comments on one or two methods, or ask for comments on code that is "proof of concept" (that is, it gives an example of how to do something, but cannot be used directly in an assignment).
I think you provided nearly all the code necessary for the network interface to the database, and as such it was a bit too much. I have reduced it so that someone cannot copy your code and have a working network solution - they will still have to do some development work themselves. I have tried to leave some sample methods so that people can make comments.
You will generally get better comments if you try to restrict the scope of your questions. It appears that you have two separate questions: one regarding Max's book, and one generic request for peer review. I think the question about Max's book could be a separate topic, and I think you are better asking for a comment on one specific item of your code, for instance asking for "comments on the interface you are providing", or asking for comments on the "booking" method.
Now for some comments on your post ...
Regards, Andrew
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suds,
DBClient should not throw RemoteException - DBClient is used for other connections than just RMI.
DVDDatabaseRemote extends DBClient and DBClient. This is the interface that is used for RMI.
But DVDDatabaseRemote also does not throw RemoteException. This is a very nice trick - since DBClient throws IOException (which is a parent of RemoteException) DVDDatabaseRemote does not need to explicitly throw RemoteException.
Regards, Andrew
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suds,
A couple of quick questions on your code, then I will stop posting in just this one thread
Why do you have both an update() method and a book() method?
What happens if a record has already been updated? According to the code you posted, the original update will be lost.
Regards, Andrew
 
Sudhansu Pati
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andrew,

Why do you have both an update() method and a book() method?
What happens if a record has already been updated? According to the code you posted, the original update will be lost.

It is not clear how Sun wants us to implement update(). The interface requirement asks to provide update on all fields.
But the UI requirement doesn't ask to create any screens to update a record. The only time a record can be updated is when the CSR book a contractor, i.e updating just the owner field of the record.
I am not sure if I need to provide update() as a public method for client layer. But you are right. If I keep it, I will be responsible for providing thread safety between book() and update().
What is your opinion ?
I will open another discussion for the RMI question.
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suds,
My opinion is in the thread Should lock methods be callable by the client. Although that topic centers on locking, the same logic applies to all the other methods in Sun's interface. I will let you read it and make up your own mind rather than stating my opinion again.
Apart from the possible interaction between the update() and bookContractor() methods, you also have to make sure that two calls to the same method with the same record will work correctly. That is, the first call to bookContractor() with record #1 will update the record while the second call to bookContractor() with record #1 will fail because the record has already been updated. It is not obvious in your code that you are catering for this.
Regards, Andrew
 
Sudhansu Pati
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andrew,
Thank you for your quick response.
[B]
Apart from the possible interaction between the update() and bookContractor() methods, you also have to make sure that two calls to the same method with the same record will work correctly. That is, the first call to bookContractor() with record #1 will update the record while the second call to bookContractor() with record #1 will fail because the record has already been updated. It is not obvious in your code that you are catering for this.
[B]
I am glad that you metioned this. At this moment the simplest solution I have to modify the update() method of Data.java as follows.
[I]Data.java[I]
[/CODE]
public synchronized void update(int recNo, String[] data, long lockCookie) throws
RecordNotFoundException, SecurityException {
1. dbRecord = the database record recNo
2. String dbOwner = owner field of dbRecord
3. String owner = the owner field of data.
4. If ((dbOwner !=null) && (owner!= null )) -> throw exception "contractor is already booked"
else -> proceed with update.
[/CODE]
Do you think this will work ?
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suds,
Yep, that looks pretty good.
Regards, Andrew
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic