In my current application we are using Glassfish to deploy my ear file and We read the user specific values from different places and store it into java.util.prefs.Preference to user it latter. We also have options to change the java.util.prefs.Preference externally. Now the questions are:
a) Recently I found, whenever I am starting my application in Glassfish, Glassfish creating a prefs.xml file containing all the preference I set under /.java/.userPrefs/. But no where I have written code to store the same in this location. So, is that Glassfish's default behavior to store the preferences in this location? or is there any settings?
b) Now if the answer is yes for the question a. Then I am changing the prefernce value in the prefs.xml but after that if I am fetching the values from java.util.Preference, I am getting the old values only not the new value. Why java not refreshing the values? or prefs.xml is only for import/Export prefernces?
c) Whenever I am changing my Preference value externally, its not refreshing the value in prefs.xml. Is that a one time process of server restart?
Any help on the questing would be very much helpful to me.
a) Recently I found, whenever I am starting my application in Glassfish, Glassfish creating a prefs.xml file containing all the preference I set under /.java/.userPrefs/. But no where I have written code to store the same in this location. So, is that Glassfish's default behavior to store the preferences in this location? or is there any settings?
Answer: Glass fish do it automatically. It fetch the preference and then store into the same.
b) Now if the answer is yes for the question a. Then I am changing the prefernce value in the prefs.xml but after that if I am fetching the values from java.util.Preference, I am getting the old values only not the new value. Why java not refreshing the values? or prefs.xml is only for import/Export prefernces?
Ans: Only for import and export.
c) Whenever I am changing my Preference value externally, its not refreshing the value in prefs.xml. Is that a one time process of server restart?
Ans: prefs.xml only used as a back up copy. If you update the through java.util.Preference then also it will not be reflected in prefs.xml. Fir better understanding, change value in prefs.xml then restart server. You will find glassfish replaces your values with the value set through java code.