Question

I have a small JSF app and would like to keep some state on the server, without using a DB. It will just be a small string for every user so I don't see the point in deploying an RDMS for that.

Was it helpful?

OTHER TIPS

Check out the Java Preferences API which can store info per-system, or per-user (not so relevant for this scenario)

Applications require preference and configuration data to adapt to the needs of different users and environments. The java.util.prefs package provides a way for applications to store and retrieve user and system preference and configuration data. The data is stored persistently in an implementation-dependent backing store. There are two separate trees of preference nodes, one for user preferences and one for system preferences.

You could use Derby which makes the deployment of an RDBMS less of a "point".

Alternatively, you could use a diskPersistent Ehcache - you use it similarly to a Map but data persists during restarts. You'll have to make sure that your JVM is cleanly closed or element in memory might get lost (you can make sure that elements are written immediately to a file by setting maxElementsInMemory to 0 though)

I think it's also make sense to utilize some caching solution for this case. jBoss tree cache for example, you can define some specific region to store small entries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top