Hello all;
I have been going through the platform and wanting to understand how classes and resources are dynamically loaded into the jvm at runtime basing on their demand .I see openmrs uses the Java EE delegation model
(correct me if am wrong on this) were it looks into the local loader first for the needed classes and resources before delegating to the parent class loader. The main class loader used here is the OpenmrsClassLoader
as the ContextClassLoader
in each thread of the running instance of openmrs , the ModuleClassLoader
being used for loading classes and resources in modules running on openmrs.
I have a few questions that i need some enlightenment on.
a) The OpenmrsClassLoader
is always aware of all module class loaders in openmrs through the loadClass()
method ,under what circumstances does it attempt to load classes form them since the URLClassLoader
is parent to the ModuleClassLoader
and i would expected the delegation to be passed to the parent if the child class loader can’t find the resource/class in its classpath in the Java EE delegation model
?. In otherword when does the openmrs class loader chip in to load classes in modules which i think are loaded by the module class loader
b) During refreshing of the spring context does the refresh go through the modules first ?, if so then does it only refresh and load classes in the modules api and then wait for the refreshing of the openmrs applicationContext
to load the service classes?
Help me understand the magic happening behind the scenes here .