Another possible way is to include in the Remote Interface only things the client can do
abt 1) It seems difficult to have multiple Data instances, how to synchronize access to the DB file?
This would allow me to throw InvalidArgumentException from method calls createRecord(), findByCriteria() and not change the interface. I can check for this specific exception on the client side and hence the condition.
why an unchecked InvalidArgumentException
I did try this but I just wanted re assuring that this was correct behaviour !.
abt 4) Exception and all its subclasses already implement Serializable. Try to throw one in your server and look whether it arrives in the client.
This is true, but I am looking to take the approach that the business logic will reside on the client side and so I only need to publish the Sun provided methods on the remote interface. Are there pros & cons to this approach ?
What are the pros and cons for having multiple Data instances or single Data instance on the server ?
DBMain Interface is pretty restricted and i want to have the Inteface for the server-client communication at my disposal.
If you have multiple instances and synchronize the underlying file access you have two layers of locking -- this and the locking required in the interface.
If I was to have go with multiple instance, hence apply the Factory Patterm, I would lookto synchronize on a static object when accessing the physical database file, therefore, ensuring only one thread is accessing the file at any one time.
John Grabowsky wrote:Can one open multiple RandomAcessFiles on the same pyhsical DB-file?
John Grabowsky wrote:you have to coordinate the locks requested via the lock method
Pete Palmer wrote:Taking what you have said the steps for an "update" would be
1) lock record to update - first level of lock
2) lock access to the physical database file, so that only thread is accessing it - second level of lock
3) update record
4) release lock 2)
5) release lock 1)
Is that about right ?
Don't forget that randomAccessFile.length()
I think somebody talked (here or on some other thread) about synchronizing the entire update/delete/read methods for the second level of locking
Don't you also have to call length() when verifying that you should throw a RecordNotFoundException or not?
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton