Session and UI Listeners
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!"));
}
}
2C1B0CB9-2315-4E97-B2DD-49BBB49459EE