4.5. Writing my first lifecycle interceptor

The bean can be notified of some lifecycle events. For example when a bean is created or destroyed.

In the following example, a method of the bean will received an event when an instance of the bean is built. This is done by using the @PostConstruct annotation.

Llifecycle interceptors of a bean can be defined in another class.

    /**
     * Notified of postconstruct event.
     */
    @PostConstruct
    public void notified() {
        System.out.println("New instance of this bean");
    }