I guess you're right, it's not that they aren't struts-2-ish... But, one
significant advantage of a static initializer block vs. servlet context
listeners is easier unit testing. I found it much easier to write the unit
tests for my actions if the JVM is in charge of initialization duties. I
don't know much about Spring and shied away from servlet context listeners
because I didn't want the external dependencies. I'm not suggesting that my
way is the best way, but if you have a requirement to write unit tests for
all of your code, then it's easier to stay away from the Servlet API.

-Wes 

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
> Behalf Of Joe Germuska
> Sent: Thursday, February 22, 2007 11:58 AM
> To: Struts Users Mailing List; [EMAIL PROTECTED]
> Subject: Re: [S2] Equivalent of Servlet init() method?
> 
> On 2/22/07, Wesley Wannemacher <[EMAIL PROTECTED]> wrote:
> 
> > I looked for something similar a while back and didn't find anything
> > simple.
> > There are servlet context listeners (but that isn't really 
> struts-2-ish).
> >
> 
> I would strongly disagree that ServletContextListeners are "not really
> struts-2-ish".  They are probably the best way to do any one-time
> initialization for an application, unless there's already 
> some other code to
> do what you need...
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to