-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tom,
Tom Kobialka wrote: > I have a web service which is running under the Tomcat container. [snip] > I need to implement some sort of serialization such that only one > request is processed from each instance at a time. Is your web service synchronous or asynchronous? If it's asynchronous, then you have the option of queuing all requests and having a single processor thread process them in order. If you have th handle these requests synchronously, then you will need to use some sort of synchronization monitor to control access to the hardware device. This is not as simple as merely marking a method as "synchronized", as another respondent suggested. You need to make sure that the object being used as the synchronization lock (the "monitor") is the one that is always being used. You have several options: 1. Throw an object in the appropriate scope (probably 'application') and do something like: synchronized(application.getAttribute("MY_HARDWARE_LOCK")) { /// do your hardware call } 2. Better than that, you could use a "hardware access" class that knew how to manage its own synchronization, and put *that* into the application scope: application.getAttribute("MY_HARDWARE_CONTROLLER").doSomething(); In this case, make sure that you are only creating one instance of your hardware controller and that you make the doSomething method synchronized (synchronizing a method makes /this/ the monitor for the synchronization). 3. Use a singleton like #2 above, which won't require you to have a scope like the application available for storage. This is useful when you have to access something like this from deep within different components and you don't have a convenient place to store your hardware controller. > Is it possible to serialize between service instances, which have > been created by tomcat? Yes, you can do this too. Although I recommend using a single instance of this hardware service, you can use multiple instances of you wish. You just need to make sure that all instances are using the same monitor for synchronization. > Is there some external library to tomcat shared memory object which > will allow me to do this? No. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGB8yb9CaO5/Lv0PARAs57AJsGBLY27n0sklGDJ61SgspEr1GagQCeKahP qOeDAwzkg/wSsEqFkC+BXdA= =5Zwc -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]