after having become enthousiastic for the Spring Framework, I am finding that it does not offer support for custom classloader. I came across another reference to the topic on this forum:
making me believe that Spring indeed does not support the feature.
I will explain what I mean in detail:
If you want to use Spring to support a plugin architecture that allows different versions of the same plugin to run concurrently, you would need to organise a classloading architecture. The same is true if you have components that use different versions of a library ( in my case JAXB, but the issue is general) you also need custom classloader support.
Java is beautiful because it is not that hard once you get the hang of it. You can organise a classloader hierarchy that supports the beans to share a common set of classes to allow IOC while still allowing each bean to use a different implementation version, and different libraries.
The problem you experience if you want to do this in Spring is that the Application Context only uses a single classloader for all beans: the Thread's Context Classloader.
The solution I will work on will try to achieve the following: alter the config XML in such a way that you can name the classloader that you want to use to load a bean. And to stay with the Spring concepts, it would be nice if the classloader could be configured as a bean itself.
For my first experiements I am using Classworlds (http://classworlds.codehaus.org) which allows me to name classloaders by strings. However, all you would really need is any mapping from string to ClassLoader, so a Map could also do the trick, and not tie in with a specific Classloader framework.
I would like to hear if this is making sense, if others also would like features like this, and wheter or not anything is scheduled for next releases. Barring further input I will work on adding Classloader support in the fashion described above.
I agree with you.
The alternative is to delegate to a loader bean (using classworlds API for loading another bean. realm and class configured by properties using spring)