Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Alternative to using a static field
I have a Jetty server embedded in an application. The application has a data structure instance (singleton) that exists while the application is running. I want to provide a UI via Vaadin for viewing and modifying the data structure. It seems like the only way to achieve this easily is to store a reference to the data structure in a static field so that I can access it from my UI class.
Is there any alternative way to achieve this? I would rather each UI instance receives a reference to the (same) data structure instance instead of using a static field.
I actually add the servlet manually like so.
context.addServlet(new ServletHolder(new MyUI.MyUIServlet()), "/ui/*");
context.addServlet(new ServletHolder(new VaadinServlet()), "/VAADIN/*");
At this point, I have the the data structure reference, but I can't see a way to ensure that each UI instance gets this reference.