As I'm sure many GAE users know, the startup time is a big problem especially for low traffic apps, and having to load a framework such as Wicket on startup is damaging to the request time for an App.
To avoid having to start the WicketFilter every time the app starts I have extended the WicketFilter to only initialize when the first Wicket page is hit:
public class RequestWicketFilter extends WicketFilter { private static boolean requestMade = false; private static boolean initialized = false; private static FilterConfig fConf; @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!requestMade) requestMade = true; init(fConf); super.doFilter(req, res, chain); } @Override public void init(FilterConfig fC) throws ServletException { if (fConf == null) fConf = fC; if (requestMade && !initialized) { super.init(fConf); initialized = true; } } }
1 comments:
Code updated.
Post a Comment