December 2019
Intermediate to advanced
314 pages
6h 51m
English
Controlling the application life cycle is a common requirement for your services to be able to bootstrap some external resources or verify the status of your components. One simple strategy, borrowed from the Java Enterprise API, is to include the Undertow extension (or any upper layer, such as rest services) so that you can leverage ServletContextListener, which is notified when a web application is created or destroyed. Here is a minimal implementation of it:
public final class ContextListener implements ServletContextListener { private ServletContext context = null; public void contextInitialized(ServletContextEvent event) { context = event.getServletContext(); System.out.println("Web application ...Read now
Unlock full access