Intercepting life cycle callback events 

The interceptor methods that are used for the life cycle callback events (AroundConstruct, PostConstruct, and PreDestroy) follow the same model for implementing the interceptors as previously described in regards to location. This may be defined in the target class, in interceptor classes, or in both classes. In this chapter, we will only see examples of PostConstruct and PreDestroy callback events.

As described in the previous table containing the interceptor annotations, a method with the @PostConstruct annotation is used to intercept the PostConstruct life cycle event, and a method with a @PreDestroy annotation is used to intercept the PreDestroy life cycle event. Intercepting classes have the same ...

Get Java EE 8 Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.