On Mon, 25 Feb 2002, Alessandro Vananti wrote:

> Date: Mon, 25 Feb 2002 19:02:21 +0100
> From: Alessandro Vananti <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Start services after starting Tomcat.
>
> Hi all,
> I want to start Tomcat4.0 using the Bootstrap class so that the
> configuration parameters are read from the Server.xml file.
> But after I call:
>
> bootstrap.main(new String[] {"start"})
>
> I would like to go on and create other services I need. But this is not
> possible because after Tomcat is started, the thread blocks, waiting for
> a shutdown command.
> Any suggestion?
>

Here's two very different approaches for you to consider:

* In your own startup class, start a new thread to execute the
  bootstrap.main() method call -- when that method returns, you
  will know that Tomcat has been shut down.

* Invert the whole startup approach and use Tomcat as the "outer"
  service, and tell it to start your inner services when Tomcat
  starts up.

An example of the latter approach can be seen in the nightly builds of
Tomcat 4, where there is a commented-out <Listener> element just inside
the <Server> element.  This declares an instance of
org.apache.catalina.LifecycleListener, which will receive notification
when Tomcat's Server element starts up and shuts down (calls to the
start() and stop() methods, respectively), which you can use to start up
and shut down your other application services.

If you want to take this approach, simply define your own
LifecycleListener implementations, put them in
$CATALINA_HOME/server/classes (or in a JAR file in
$CATALINA_HOME/server/lib), and use the standard Tomcat startup procedure.

> Alessandro
>

Craig


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to