Andrew Monkhouse's and Terry Camerlengo's Denny's DVDs is an excellent example application!
But I don't understand why DvdFileAccess.database is not static?
If I start the server and then two clients the application creates two DvdFileAccess.database instances. How can the application now get the unique access to the database (for example in
the method DvdFileAccess.retrieveDvd)?
I'm not Andrew, but I'll give it a shot. Take a look at the following line in DvdDatabase:
So it doesn't matter how many DvdDatabase instances are created (one for each client), there will be just 1 shared instance of the DvdFileAccess class (and so there is no need to have DvdFileAccess.database marked static).
If you check ReservationsManager you'll see this comment:
We rely on the class which uses this ReservationManager to ensure that only one instance exists for any reservations.
Although I havn't seen Andrew Monkhouse's and Terry Camerlengo's Denny's DVDs application, I suppose that the DvdFileAccess class is on the server side since you mentioned that you are working with a server. Furthermore I suppose that this is some kind of interface implementation providing communication between client and server. If this is the case then you don't have any problem. In simplified words, when the server starts it makes its instances, clients requesting an instance of the DvdFileAccess class will all get the same instance rather than creating new DvdFileAccess for every request.