By David Delabassee-Oracle on Mar 17, 2015
Java EE defines different component/container models with their own well-defined lifecycle. Understanding the lifecycle of those different component/container might sometime be useful. Having some visibility on component lifecycle is also useful with applications that use different types of components (e.g. Servlet and EJB) and needless to stay that this is the most common uses case. Finally, it is not just about visibility. Having the ability to also trigger certain actions based on the state of a particular component/container is also sometime required (e.g. perform some specific initialisation).
So when it comes to monitoring and managing Java EE applications, Application Servers tends to provide some custom hooks to achieve that, i.e. observe internal state (e.g. state of a particular container) and trigger management actions based on events such as a state change. Obviously, this is Application Server dependent. For example, GlassFish has Life Cycle Modules/Listeners while WebLogic has, amongst different options, WLDF Watches. So overall, this type of capability (and theirs implantations) varies greatly and is Application Server dependent.
But some of the Java EE Java APIs also provide hooks that can be used to determine in which state an actual component/container is. In terms of granularity, this approach might be a bit more limited but it has the advantage of being Application Server agnostic since it is based on standardised APIs. I recently came across 2 articles that are discussing that particular topic:
- Getting notified when Java EE Application is ready (by Rudy De Busscher)
- CDI and @Startup: SOLVED! (by Romain Manni-Bucau)