views:

99

answers:

4

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.

+1  A: 

Use a properties file: http://www.exampledepot.com/egs/java.util/Props.html

OMG Ponies
That seems unlikely to scale well, depending on the number of users.
Jherico
+1  A: 

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.

Brian Agnew
+1  A: 

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)

sfussenegger
Any embedded DB which runs entirely in the JVM and is initialized implicitly by loading the JDBC driver is likely to reduce the burden of a DB. H2 or Derby are both excellent for this.
Jherico
@Jerico: You have a point, but the OP is specific: **no** database. Requirements are requirements...
OMG Ponies
@rexem Well, it seems not to be a strict requirement: "I don't see the point in deploying an RDMS for that" is more of a search for alternatives than an actual requirement. Using an embedded DB like Derby reduces the overhead of deploying a RDBMS and therefore is an alternative worth mentioning, don't you think?
sfussenegger
A: 

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.

Maksim