3 Replies Latest reply on Jul 23, 2002 8:03 PM by Aaron Rustad

    Starting another Thread of execution...

    Aaron Rustad Newbie


      I have a need to start a thread that will monitor the contents of a directory, if the directory changes, a certain action to take place (much like how jboss does hot-deploys).

      What I need to know is what the best place to start this thread would be. Right now I am thinking that I would just extend GenericServlet and start the thread in there. I could configure the servlet to execute with the app server starts up. This to me sounds like a "alright" way of doing it....anyone think of a better way. It has to stay app server independent.

      Thanks!
      BCOT.

        • 1. Re: Starting another Thread of execution...
          Greg Turner Apprentice

          Why look at Servlet. You got the source, just do it the way JBoss does it, in an MBean. Perhaps there is some code you can borrow, or even extend from JBoss. Make a class that does what you want. Make an MBean wrapper for that class. You can then deploy your MBean in JBoss and any other app server that supports JMX - they most all do because they are all playing catch up to JBoss. If you run into a app server that does not have JMX, then you can call your class from a servlet, I guess.

          • 2. Re: Starting another Thread of execution...
            Joel Vogt Master

            The only issue you might have with an mbean is if it needs to talk to a deployed application.
            If your directory scanner is generic I would go the mbean, but if it is only talking to one deployed app for instance, I would go the servlet.

            • 3. Re: Starting another Thread of execution...
              Aaron Rustad Newbie

              Thanks, that probably is the "correct" way of doing it...if I had more time, I would implement it that.

              I am going to continue to use a servlet, but instead of extneding GenericServlet, I will use HTTPServlet and allow the developement team to post requests to the servlet to monitor the status of the thread.

              Thanks!