Suppose I am using Apache
Tomcat, and as Tomcat starts up for the first time I instantiate a
java class that I will pass as a
shared object for all messages that arrive. As new HTTP Requests arrive, request processing methods are passed this shared object along with the HTTP Request object, and the required work is done.
This set up works well, but I would like to change it, and I would like your advice and opinion on the wisdom of doing so.
First: the shared object (I'll call it objectX) has an array of names that are allocated for on startup (
String[ ] names = new String[nnames]). If new names are to be added to the array and objectX, then Tomcat must be brought down, and when it is restarted, the existing names and all new names are read and put in the array of names to be shared.
I would like to make adding names
dynamic, so that I can receive a message (an HTTP Request) that says "addThisName", and it adds it to objectX. I do not believe the existing array can be added to, since the size of the array was allocated at startup. However, it seems to me that instead of an pre-allocated array of names, I could use a
Vector to hold the names instead, and new names could be added to the Vector in real time, such that all subsequent users would see the new name.
Would it be dangerous to use a Vector on such a shared object that is used during all message processing? Any tips or warnings will be greatly appreciated.
David John