On Fri, 14 Jun 2002, Jeremy Prellwitz wrote:

> Date: Fri, 14 Jun 2002 08:37:06 -0800
> From: Jeremy Prellwitz <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: Starter Action?  Where to find Plugin Documentation?
>
> Can someone give me a hint where to find documentation on
> this topic? (i.e. Plugins, how they are configured, and how
> you attach them to events.)
>

Right now it's just documented in the javadocs and the DTD -- but it's
really simple.  When the controller servlet is first stated, it will
instantiate all the plugins you have defined and call the init() method of
each one.  Likewise, when the controller shuts down, it will call the
destroy() method of each previously instantiated plugin.  Essentially,
your plugin has exactly the same lifecycle characteristics as the
controller servlet itself.

The struts-config.xml file for the struts-example application in 1.1 has a
plugin for the "user database" object.  You can take a look at this to see
how plugins are configured.

One detail I glossed over, though -- you cannot actually call an Action in
your plugin's initialization, because that requires having a request and
response available.  However, you can do whatever initialization that you
would have done in that action, by pulling that logic out into separate
classes.

> Thanks.
>

Craig


>
> ---- Original message ----
> >Date: Fri, 14 Jun 2002 08:57:50 -0700 (PDT)
> >From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
> >Subject: Re: Starter Action?
> >To: Struts Users Mailing List <struts-
> [EMAIL PROTECTED]>
> >
> >
> >
> >On Thu, 13 Jun 2002, Struts Newsgroup wrote:
> >
> >> Date: Thu, 13 Jun 2002 23:10:02 -0700
> >> From: Struts Newsgroup <[EMAIL PROTECTED]>
> >> Reply-To: Struts Users Mailing List <struts-
> [EMAIL PROTECTED]>
> >> To: [EMAIL PROTECTED]
> >> Subject: Starter Action?
> >>
> >> Subject: Starter Action?
> >> From: "Christopher Cheng" <[EMAIL PROTECTED]>
> >>  ===
> >> Is it possbile to define one of the actions to be executed
> during startup
> >> instead of defining a new servlet in web.xml?
> >>
> >
> >In Struts 1.1, you can define and register a PlugIn that is
> notified when
> >the Struts controller servlet is started and stopped.  The
> init() method
> >can do whatever setup things you need.
> >
> >In Struts 1.0, you can accomplish the same thing by
> subclassing
> >org.apache.struts.action.ActionServlet and overriding the
> init() method --
> >something like this:
> >
> >  public void init() throws ServletException {
> >    super.init();
> >    ... do my own setup ...
> >  }
> >
> >and using this class as the "action" servlet in web.xml.
> >
> >Craig
> >
> >
> >--
> >To unsubscribe, e-mail:   <mailto:struts-user-
> [EMAIL PROTECTED]>
> >For additional commands, e-mail: <mailto:struts-user-
> [EMAIL PROTECTED]>
> >
>
>
> ===================================
>  Experience is something you don't
>  get until just after you need it.
> ===================================
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to