So, I'm writing my choices about the Lock and I have a doubt...
My solution use the Channel to Lock the database file to restrict at one access for time... I specifys...
When application run as Server & Client (run the server and run some client), the Server lock the database, and, if I start the application in Standalone mode too, I throws an Exception with "File alredy open..." (my choice)
The Server can receive any number of Client's connection... The Standalone can execute only one for time...
My assignment clearly says (and i guess yours too):
You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server.
So using a Channel to restrict access to database file is not necessary and you are doing more than you should do. You will nog get any extra points for doing so, only get points deducted if you made a mistake or if you have very complicated code for doing that.
And it's totally ok for your standalone application to be executed only one time, because there is at most 1 program accessing the db-file. So it's your standalone application or your server application or another application that's using that database-file.
Hi Laura, if I am correct the Channel you are referring to is in the java.nio package which is not allowed for the SCJD. And the instructions clearly stated "assume only one program assess the database file at any moment".
All I have said in my choices.txt in my assumptions is something on the line:
* The stand-alone version and networked version will not run at the same time on the same computer
The only lock issue you do need to worry is the record locking (eg those lock, unlock, isLocked methods). What you are doing with Channel is more of file locking which can be assumed.