Multithreaded daemon? High level help needed.
For starters, I'm pretty new to Java. My background is mostly with PHP. This is really my first Java application save for hello world type stuff.
I'm in the process of writing a multi-threaded web crawler with a very specific purpose - not SE type stuff. I've got the basic functionality written including all of the threading using a thread pool executor, but what I'm not sure about is the deployment.
I need this to run as a daemon or service, so to speak. I want to be able to issue stop, start, restart commands and have it be able to intercept those interrupts and be able to shut down cleanly - each thread needs to either abandon or finish its work in a clean manner.
I was wondering what the best approach for this is?
I also would like the API to be available from many interfaces: a web GUI, a web service, and possibly a desktop GUI. Mostly for administration purposes. This includes the ability to issue stop, start, restart commands as well as having access to other methods which give me information about the status and progress.
I was told by one Java developer that using an MBean to kick off the process and exposing methods from the MBean for shut down, etc. might be one way of doing this. I also have read about EJBs a bit and they seem to be meant for exposing an API to many front ends, but I'm just not sure how they apply here.
I'm really just not sure what is the best solution for what I'm trying to do, so I figured I would garner some feedback from a larger community. Any help or suggestions are greatly appreciated.
Thanks!
- Jason