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). What I did (and I know it's inelegant) is to create a static initializer block. One main difference to remember between servlets and actions is that servlets are initialized once and remain in memory. Actions seem to be on a one-per-request lifecycle. So, if you have a factory that you want to use, it has to be either static in your action, or static in another class.
-Wes > -----Original Message----- > From: Roger Varley [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 22, 2007 9:10 AM > To: user@struts.apache.org > Subject: [S2] Equivalent of Servlet init() method? > > Hi > > I'm a struts2 newbie & I've just got the hello world app running. I'm > now trying to convert a simple servlet app to struts2. In the original > servlet I use a singleton factory class which I initialise/setup in > the servlets init() method and use it in the servlet service() method. > What is the equivalent means of achieving this on Struts2 so that I > can set up the factory once and simply "use" it in my action class. > > In addition, other than the wiki I'd be grateful if anyone could > recommend other documentation/tutorial sources. Should I also be > reading up on WebWork &/or Struts 1? > > Regards > Roger > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
smime.p7s
Description: S/MIME cryptographic signature