Preferences API - values not being synched

A

Andrew May

I'm using the Preferences API with the 1.4.2 JDK on Solaris and my
application doesn't seem to be picking up changes to the preferences
from outside the VM.

I'm using the Preferences to configure the Logging API that I'm using
for an application running on JBoss - so it's a long running process
and I want to be able to change the configuration on the fly.

Rather than spending time writing a complex MBean to edit the
Preferences within the same VM, I've been editing the system
preferences by hand and then have a MBean that calls
LogManager.readConfiguration() which in turn calls my configuration
class that uses the preferences.

I've tried waiting for the preferences to sync automatically (i.e. >
30 seconds), and I've also tried putting calls to prefs.sync() before
retrieving any values, but neither seem to work.

Running a standalone test case that uses the same logging
configuration the changes to my configuration are picked up.

The thing that really confuses me is that I'm sure I've had things
being updated on the fly like this before.

Have I misunderstood how the preferences work? Or is it broken in my
case?

Thanks,

Andrew
 
P

Parvinder

hi there,

i had a query while i was reading your post. you said that you edited
the preferences by hand. but i could not fin anything in the api which
mentions the persistence of the preferences. all i can have read from
the newsgroups is that it stores the preferences in platform dependent
manner.

have you tried to persist the preferences in your own way ? in short
how did you figure the persistence location of the preferences and
edited them ?

thanks
~Parvinder
 
R

Rhino

Hi!

I'm sorry about butting in but I think I might be able to help a little.

I worked with Preferences a bit last year and come back to them occasionally
now. Something I found out along the way was that the backing store is
operating system dependent but, in the case of Windows, the Registry is
used. I don't recall how Preferences keys map to the Windows Registry
offhand but I used this PDF quite a bit when I first worked with
Preferences; you might find the answer in there:
http://java.sun.com/developer/Books/javaprogramming/jdk14/javapch10.PDF

Also, I found another very useful tool last year when I was first using
Preferences and I continue to use it regularly; it is a Preferences Editor.
The complete source code of this short but heavily-commented program was
posted by Dr. Heinz Kabutz on 2001-09-17 in comp.lang.java.programmer. If
you do a Google Usenet search on 'Kabutz Preferences', I'm sure you'll find
it. This handy little program lets you view the entire System and User
preference trees whenever you like. You may find this as useful as I have
;-)

Rhino
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top