Java Preferences

J

jaj_developer

All,

Currently I am using Java Preferences to store preferences to the
default location (on windows the registry).

The issue is that some users will move from machine to machine and in
some cases the registry is locked down.

So the question is : Is there any easy way of altering the way Java
Preferences are stored (e.g. xml flat file, csv etc..) or do you have
to cut some code (e.g. impliment your own PreferencesFactory)??

Ta

Jaj
 
R

Roedy Green

So the question is : Is there any easy way of altering the way Java
Preferences are stored (e.g. xml flat file, csv etc..) or do you have
to cut some code (e.g. impliment your own PreferencesFactory)??

What you might do is suck the preferences out for backup and dump them
in a platform independent format. XML should do, or perhaps a
serialised tree.

I don't think you have any control how the system preferences are
implemented.
 
J

jaj_developer

Roedy,

Yeah that's what I thought. I think that I will have to implement my
own version of the PreferenceFactory and the AbstractPreferences.

*sigh*

Jaj
 
J

jaj_developer

Does anyone know of a good tutorial (or any tutorial) or any GPL code
that I can look at to show me how to do my own Factory ???

Ta

Jaj
 
R

Roedy Green

Yeah that's what I thought. I think that I will have to implement my
own version of the PreferenceFactory and the AbstractPreferences.

Since you are tossing Sun's preference mechanism aside, you could just
do this with a class with a static get and save method where you
specify the full node name on each get/save.

Another thought is JDK 1.5 Preferences has an xml import/export built
in.

If you want to replace the official preferences here is what to do:

Write yourself a JAIPreferences class that extends the abstract
Preferences class.

Then write a class that implements the PreferencesFactory interface.
basically all it does is return new JAIPreferences().

If the system property java.util.prefs.PreferencesFactory is defined,
then it is taken to be the fully-qualified name of a class
implementing the PreferencesFactory interface.

there is another method of registering your factory with a magic jar
entry described under Preferences.
 
J

jaj_developer

Roedy,

Thanks for your wise words....

Have implemented a system based upon the info above

Ta

Jaj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,282
Latest member
RoseannaBa

Latest Threads

Top