struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes Geppert <jo...@apache.org>
Subject Re: Servlet init() equivalent in Struts 1.3.8
Date Sat, 19 Nov 2011 09:32:34 GMT
You can use your own Struts2 FilterDispatcher to solve this.

Like this Example which is loading Configs via an SpringDAO and put it into
the Application Scope:

public class FilterDispatcher extends StrutsPrepareAndExecuteFilter {
  private static final Log log = LogFactory.getLog(FilterDispatcher.class);
  private ConfigDAO        configDAO;

  public void init(FilterConfig filterConfig) throws ServletException
  {
    super.init(filterConfig);
    log.info("Init Application Configuration");
    XmlWebApplicationContext xwac = (XmlWebApplicationContext)
filterConfig.getServletContext().getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
    configDAO = ConfigDAO.getFromApplicationContext(xwac);
    List<Config> configs = configDAO.findApplicationConfig();
    for (Config c : configs)
    {
      filterConfig.getServletContext().setAttribute(c.getName(),
c.getValue());
    }
  }
}

Johannes


-----
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep
--
View this message in context: http://struts.1045723.n5.nabble.com/Servlet-init-equivalent-in-Struts-1-3-8-tp5005400p5006530.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message