I have the following problem:
I have to write an application which makes modifications on databases. I have to deploy it on Glassfish 2.
This application would not recieve any external calls, it just looks at the database let’s say every 10 seconds and makes some modifications.
I shouldn’t write a servlet, since they are not indended to be used for these purposes. (From the init() start a thread, which does the work for us). I read, that this is against the standard.
What do you suggest?
What kind of EE application should I write to solve this issue within the “borders” of the Java EE standard?
Thanks in advance!
Create your task via a ServerletContextListener class and then may be run a thread (safely via an ExecutorService) that would watch your database. It should be similar to this. It is done in Tomcat but should not be different on Glassfish.
http://kahimyang.info/kauswagan/howto_blogs/1314-asynchronous_tasks_in_jsf_applications