java - Significance of class loader in loading resource bundle -
i having difficulty in understanding significance of classloader in resourcebundle.getbundle(bundlename, locale, classloader)
api .
what practical scenario want provide custom loader api?
a java application might have multiple class loaders. example, j2ee application running on tomcat or glassfish has multiple tiers of classloaders - belonging j2ee server itself, being made webapp (otherwise webapp able access classes belonging other webapps) , custom classloaders might have instantiated yourself.
standalone java apps might have multiple classloaders. example, if application supports plugins , each of these plugins contained in own jar file (local or remote) in order load plugin's classes @ runtime have create own classloaders so.
therefore, when load resourcebundle
have select appropriate classloader ensure resource loaded correct source. here's simple example... imagine application contains /version.properties
file , jvm has similar, yet different, /version.properties
(e.g. ibm's java has properties file). trying load resource file using system's default classloader returns version.properties
included in jvm , in order load own version of file, must use custom classloader or 1 context specific app.
there old still interesting explanation of how class loaders work , how hierarchies , loading contexts useful in practice. more info, check internals of java class loading.
Comments
Post a Comment