Skip to content

Instantly share code, notes, and snippets.

@avarabyeu
Created October 23, 2014 15:04
Show Gist options
  • Save avarabyeu/4bbfcbf8b84b818783bf to your computer and use it in GitHub Desktop.
Save avarabyeu/4bbfcbf8b84b818783bf to your computer and use it in GitHub Desktop.
Custom spark filter with ServletContextListener implementation
@WebFilter(urlPatterns = {"/*"})
@WebListener
public class YourCustomFilter extends SparkFilter implements ServletContextListener {
@Override
protected SparkApplication getApplication(FilterConfig filterConfig) throws ServletException {
return //your SparkApplication;
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
//startup stuff
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
//shutdown stuff
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment