aspose file tools*
The moose likes Tomcat and the fly likes spawning a daemon thread on Tomcat startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "spawning a daemon thread on Tomcat startup" Watch "spawning a daemon thread on Tomcat startup" New topic
Author

spawning a daemon thread on Tomcat startup

Ajay Saxena
Ranch Hand

Joined: Nov 13, 2006
Posts: 154
I'm exploring the possibility of spawning a daemon thread, that would act as a heartbeat listener,at the Tomcat server startup.

The tomcat server ,on startup, spawns the following threads,among others.

- the main thread that listens on 8005 and awaits SHUTDOWN requests

- the JIOEndpoint Acceptor thread that listens on 8080 for incoming TCP/IP connections

- A processor thread that listens on 8009 for Apache webserver connections

- Other processor threads

I intend to spawn my heartbeat listener thread from the main thread.

Is there a way to achieve that by supplying my code and patching it up with the tomcat binaries? In other words, is it possible to write some sort of plugin?

Or do I need to build the tomcat code along with the hearbeat listener code?

-thanks a lot for your comments.

[ July 08, 2008: Message edited by: Ajay Saxena ]
[ July 08, 2008: Message edited by: Ajay Saxena ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
That seems unnecessarily complicated. Why not just start the daemon Thread from - say - a ServletContextListener for an app that gets initialized on server startup?

Bill
Ajay Saxena
Ranch Hand

Joined: Nov 13, 2006
Posts: 154
Well, that would probably be a cleaner approach. In fact I came across such a suggestion on the web somewhere. But still wanted to explore other alternatives. Looks like it's time I revisited the servlet container features of Tomcat. I was actually viewing Tomcat from a management/monitoring perspective,so didn't quite consider this approach.

-thanks for your time and suggestion!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spawning a daemon thread on Tomcat startup