Session & 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 {
@Override
public void serviceInit(ServiceInitEvent event) {
event.getSource().addSessionInitListener(
initEvent -> LoggerFactory.getLogger(getClass())
.info("A new Session has been initialized!"));
event.getSource().addUIInitListener(
initEvent -> LoggerFactory.getLogger(getClass())
.info("A new UI has been initialized!"));
}
}
32F7CB22-D229-4B91-A3A5-F2EC4B028AD1