Multiple Servlets/Same information
843833Sep 17 2001 — edited Sep 18 2001Okay folks, I could use any advice on this situation. I thought I had it but realized I was thinking in another language other than Java (this needs to be done using Java Servlets). Essentially, I have this class called Region which holds information for part of a network. This information can be edited at any time and I have worked out the synchronization issues for the file writing without any problems.
Essentially, I would like to have several servlets that work with these Regions:
a user servlet
an administrator edit servlet
an administrator search servlet
an administrator configuration servlet
Now, in order for this to work, I can have only one instance of each Region ever. Otherwise, file synching becomes too costly and complicated. I have written this code as one giant servlet that does the work of all 4 servlets that I mentioned before. However, this is really ugly and I would like to make it more modular.
My idea was to create a class called RegionDaemon that had the individual regions declared statically. Each of the four servlets would work through it through static methods to get the information they needed or to change whatever info in the region needs changing. I was thinking that the calls would be like RegionDaemon.editRegion( ... ).
To do this, I would need to be able initialize this class somehow so that the regions would load their information from files as they already do in my "ugly" code. Is there any way to do this that I am missing?
Otherwise, any ideas to get me jumpstarted in thinking of a different way to design this large servlet project?
thanks.
sporkwarrior