On Mon, 6 Aug 2001, Christopher Cain wrote:

> I need a quick jumpstart on how to hook my password prompter into the
> Catalina startup process. I assume that I shouldn't implement it as a
> Valve, as those have to do with the Request/Response chain. The
> <Connector> level in server.xml appears to be the appropriate level in
> the hierarchy, but it's not really a connecter per se, since its
> lifecycle is complete before the startup process even finishes (i.e. it
> doesn't need to sit in the service and pass requests off to the engine).
> 

Valves are designed for request processing, not component startup and
shutdown.  See below for an alternative suggestion.

> So is there a more generic "module" architecture in place that I should
> implement? I just need a quick, high-level idea of what internal
> component to use and how to implement that component in the server.xml
> config.
> 

The simplest approach to your particular issue would be to create a class
that implements the org.apache.catalina.LifecycleListener interface, and
then nest a <Listener> element inside the SSL-based <Connector> element
that creates an instance of that listener, associated with the
correspondeing connector.

Now, the lifecycleEvent() method will be fired when this Connector is
started up (and when it is shut down), so you can interject your dialog
with the user at that point.  Just look for an event of type
Lifecycle.START_EVENT.

Note that the <Lifecycle> element, like most elements in server.xml, can
dynamically map the XML attributes specified in the <Listener> element to
corresponding bean properties on your LifecycleListener class.  This is
tremendously useful for configuring the behavior of your listener.  The
only required attribute is "className", which specifies the fully
qualified classname of your class itself.

It won't help for this particular use case, but lifecycle listeners can
also be nested inside <Engine>, <Host>, and <Context> elements, depending
on what kind of startup and shutdown events you care about.

> TIA
> 
> Regards,
> 
> Christopher
> 
Craig


Reply via email to