For EJB3 and app server integration, I need to inject a specific
classloader that may load all classes and resources needed by Hibernate.
the current thread context classloader is meant for this purpose; why is
it required to use a 3rd classloader mechanism ?
There are 2 distinct needs for a classloader in Hibernate
Configuration time (ie until the SF is built)
Runtime (session time use)
For Configuration time, I can see 2 solutions:
1. Overriding the Thread.currentThread().setContextClassLoader() and
restore the previous one when the SF is built.
Why is the currentthread contextclassloader not already the correct one ?
2. hacking all the APIs and keep track of the classloader instance
round every ReflectHelper, SerializationHelper and so on
no will not work - especially if there is some usercode in some
callback/extension
point, they will also need to access the current classloader...and look
and behold;
that is what currentthread contextclassloader is for ;)
3. keep track of the classloader in a ThreadLocal variable
I like 1. but it requires some security relax from an app server POV
(server.policy)
the only thing that will work (and fail) consistently.
2. I think 2 is not an option
you are correct ;)
3. seems fine, but might lead to memory leaks and other weird stuffs and
it requires to change ReflectHelper a bit.
and will not work (and fail) consistently.
BTW sometimes, in Hibernate we do not use ReflectHelper, but use some
specific way to load classes or resources. Is it intentional?
as far as I know the only place we do this is some resource loading gavin
added
at some point. I saw it and wondered, but never got around verifying with
gavin
why that did not use ReflectHelper.
I'm very curious why this classloader trick is required ? Is this to apply
to something
in the spec or just to provide "transparent" hook of ejb3 into non-ejb3
appservers ?
If it is for the spec then I would argue that the spec is very wrong since
it will
break all other kind of stuff. Like how will you convince all the external
libraries hibernate
uses to use your "magic" classloader ? (e.g. log4j, dom4j, cglib, yada,
yada)
--
--
Max Rydahl Andersen
callto://max.rydahl.andersen
Hibernate
[EMAIL PROTECTED]
http://hibernate.org
JBoss Inc
[EMAIL PROTECTED]
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel