问题
i am currently working with the Preferences API to save settings in a Vaadin application. The application has 3 WebApps running on a Tomcat server. As i have learned, the Tomcat server has a ClassLoader for every module running on it but it is all running in one Virtual Machine.
Can anybody explain to me why Java Preferences are working on multiple ClassLoaders? I cannot find any source for this and i didn't find anything by debugging.
Thank you a lot.
回答1:
I have found the answer:
You get a Preferences-object by calling:
Preferences prefs = Preferences.userRoot().node("test);
Preferences and PreferencesFactory is loaded by the Bootstrap ClassLoader and so it is the same for every module (how ClassLoader work in Apache) and because the object is created in the PreferencesFactory it is not created in a WebApp context.
来源:https://stackoverflow.com/questions/17740925/preferences-api-working-with-multiple-classloaders