Long time ago we had a discussion with Andriy about a need for a usable
preferences API in Java (beyond the java.util.prefs "invention"). Now
that I had an immediate need for such API to use for Modeler
Preferences, I had to actually design one myself. I needed the
following features:
* Hierarchical preferences with the ability to easily locate a
preference object for a given Java object in a certain context.
* Platform independent storage format that is human-readable and
editable in a simple text editor.
* An ability to retrieve typed objects, not just some key value pairs
(e.g. have a "db connection" preference object for a DataNode that
stores URL, driver, password, etc.)
Looking at this list I couldn't think of a better way, but to use
Cayenne itself as a base for such preference API implementation. So I
created a small preference framework that has a "common" part (DataMap)
used for preference organization and lookup and a "domain-specific"
part (which is a DataMap created by developer for her specific
application). Here is an implementation of this idea:
http://objectstyle.org/downloads/cayenne/demos/ModelerPreferences.tar.gz
This is an Eclipse project that depends on Cayenne, that contains a
common preferences library and a small Swing app that implements a
preference editor for DataSources. It uses an embedded HSQLDB (with
files created under ~/.cayenne/pref/ - no need to do "generate DB", it
bootstraps itself automatically). This actually worked *very* well, and
I think such approach should work with any GUI application. My only
concern is HSQL DB itself - we can't use a standalone server, as this
will hurt Modeler usability. And the embedded DB mode doesn't allow
multiple processes to modify the same DB. So I had to implement various
tricks to get around this limitation. E.g. if you open multiple
instances of the app, I am cloning the DB. I guess at some point we
should open multiple frames of in the SAME JVM, instead of multiple
instances.
As this implementation will be a part of the Modeler in Cayenne RC1, I
appreciate comments on the tool and general approach.
Andrus
This archive was generated by hypermail 2.0.0 : Wed Sep 22 2004 - 13:38:55 EDT