Preferences API working with multiple ClassLoaders?

旧城冷巷雨未停 提交于 2019-12-13 04:40:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!