[jboss-dev-forums] [Design the new POJO MicroContainer] - Context ClassLoader - POJO
adrian@jboss.org
do-not-reply at jboss.com
Tue Jan 22 09:25:32 EST 2008
Most of the containers are already setting the correct context classloader,
e.g. MBeans and EJB do it
But the POJO deployment runs with a "random" context classloader.
The changes required to fix this are:
1) Set the context classloader in the callbacks (e.g. instantiate, configure, create, start, etc.)
2) Add ClassLoaderMetaData - the POJO version of this class, not be confused with the
deployment metadata with the same name :-( - to use the classloader of the deployment
(if the -beans.xml or bean does not already override it to use an explicit classloader).
My preference in the past would be to make this an aspect (since it should arguably do it
for methods that are not part of the IOC protocol, e.g. runtime methods),
but I'm now convinced that the MC should be doing it itself.
First the MC should be able to run without AOP, so it isn't really the full solution.
(Of course you could argue that the feature is only available with AOP :-)
Second, there are times when you might want the correct classloader during
configuration, but use the caller's context classloader at runtime.
Third, configuring the aspect (even with a simple annotation) on every relevant POJO
would be a configuration nightmare.
So the solution I propose is set the context classloader in the IOC callbacks,
but require the aspect for this behaviour at runtime.
Also, this won't change the behaviour for standalone MC usage
since if the classloader is not configured (it will be always inside JBoss
since it will set to the deployment classloader when not configured)
it will just "redundantly" reset the classloader to context classloader, i.e. no change
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122221#4122221
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122221
More information about the jboss-dev-forums
mailing list