java.util.prefs.Preferences question

M

Me

Hi...

I was working with the Preferences class, and I was wondering about the
importPreferences method. Specifically, after you do an
importPreferences, do the elements loaded get kept in the runtime space
and used for later prefs.node() calls and the like?

Or are they persisted to the backing store right away and all pref
fetching operations operate from the backing store?

The sun doc page on it says "This method is an exception to the general
rule that the results of concurrently executing multiple methods in
this class yields results equivalent to some serial execution. The
method behaves as if implemented on top of the other public methods in
this class, notably node(String) and put(String, String)." which
doesn't seem clear to me. What do they mean by "on top of."

I would expect that node() and put()s followed by gets would be working
from in-memory copies, as those methods don't say when they get flushed
to the backing store. The fact that flush() exists implies that
there's potentially some kind of disconnect between the two. I'd also
imagine that once fetched, re-fetches come from memory instead of the
backing store.

But importPreferences() is such a wholesale operation, I wasn't sure
what would happen there.

Thanks
-Mark
 
M

Manish Pandit

Hi,

You can look at the source as a part of src.zip that came with your
JDK. Based on my understanding of the code, I did not see the imported
prefs being flushed. The method reads the XML, parses it out, and does
a 'put' with no calls to flush() whatsoever. So I guess you've to
explicitly call flush after the import. And yes - the prefs are
available in memory after import.

-cheers,
Manish
 

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

Similar Threads

Question about loggers 26
Tasks 1
Enum Idiom Question 27
Question regarding methods and classes 9
Import order question 0
java programming blueJ help 0
Javadoc question 4
Concept question about JUnit Failures 10

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top