Documentation versions (currently viewingVaadin 23)
New Acceleration Kits: Observability Kit, SSO Kit, and Swing Kit. Read the blog post.

Session and UI Listeners

Listening for session and UI instantiation with SessionInitListener and UIInitListener.

A SessionInitListener can be used to receive an event each time a new VaadinSession is initialized. Similarly, a UIInitListener can be used to receive an event each time a new UI is instantiated.

The ideal place to add both SessionInitListener and UIInitListener is inside a VaadinServiceInitListener.

public class ServiceListener implements VaadinServiceInitListener {

    public void serviceInit(ServiceInitEvent event) {

                initEvent -> LoggerFactory.getLogger(getClass())
                        .info("A new Session has been initialized!"));

                initEvent -> LoggerFactory.getLogger(getClass())
                        .info("A new UI has been initialized!"));