4. For RMIRegistry it is easier to just get your startup code for the server to look for a registry and start one up if none is running. Then check that a URLyBird server is not in the registry, and if so bind your server instance to the registry. This is only a few lines of code to do.
5. Yes. I've used these as identifiers for a room in the database, as they are unique. Its probably up to you whether you use them or not. I assumed that there could be more than one room at the same hotel available through the application, so there was no other way of uniquely identifying a record.
1. I didn't make it a singleton. I have a business model class (BusinessServiceModel) that implements the business rules of the server and talks to the Data class. The Remote service (RMI) impl has an instance of this BusinessServiceModel to service any calls from clients. As there is only ever one instance of a remote server in the registry, there will only ever be one Data instance and one BusinesServiceModel instance, making it a singleton without needing code. The Data instance is kept for the lifetime of the BusinessServiceModel instance. Also to programatically make it a singleton means having extra public methods that aren't on the DBMain interface which isnt a good idea.
2. This is one I struggled on. I originally got it to read the structure and then use those indexes to find what column was what. This required either (a) my Data class to know about the structure of the database rows or (b) my Data class to have extra methods on it for extracting the schema so my BusinessServiceModel could learn the structure. Both these options seemed wrong, especially (a), as it is a database impl, and should never care about what data it is storing. (b) seemed wrong too, as the interface they had provided in DBMain does not allow for this. So the solution is to document this in my choices file, and to hard code my BusinessServiceModel to know that when it gets a String record, that index x gives me column x from a row.
I promise I will be the best, most loyal friend ever! All for this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton