Best practice to share data

Hi!

If I have data that can be shared by all application instances, for example configuration data (changeable at runtime), what is the best way in Vaadin?

(1) In a classical Java web application I could use the application context (ServletContext) to put and read attributes. I already know that I can use the TransactionListener interface in Vaadin to access the WebApplicationContext, and so the ServletContext, as well …

(2) I could introduce a singleton that can be accessed by every Vaadin application.

Is there a favorite option for Vaadin? Maybe more suggestions?

Thanks,
Dirk

To share data the number one choice has always been a database. SQL, NoSQL, flat-file… something. But I’ve also seen both your methods being used in Vaadin apps.

However, with statics (like the singleton pattern) you have to remember that they only work within a single JVM and AFAIK this is the case with the ServletContext attributes also.