It is popular to use static "log" field, this field is
shared by all contexts in shared deployment but first 
loaded context will be used to configure logger or
"warn,indo,debug, ..." must be wrapped to cache and to
select "current configuration" using context loader on
every call (probably commons logging doe's it, but it
looks bit expensive for logging). So library must be
designed in very special way for this use case.
Probably there is no good common way and
parametrization or ClassLoader injection can help.

--- Max Rydahl Andersen <[EMAIL PROTECTED]>
wrote:

> On Thu, 02 Feb 2006 22:00:39 +0100, Scott M Stark
> <[EMAIL PROTECTED]>  
> wrote:
> 
> > Because the there may be serveral class loaders
> associated with a
> > deployment. I'm missing the exact context of this
> discussion and how it
> > correlates with the entity manager spi. Has there
> been a definition of
> > what the tcl must be for the entity manager spi
> lifecycle? I don't see
> > it browsing through the current ejb3 spec.
> 
> the problem is that if it is really necessary to
> have a *third* external  
> classloader
> which is neither available via someclass.forName nor
> TCL then we need to
> carry this classloader around and pass it on to hard
> to reach places.
> 
> /max
> 
> >
> > -----Original Message-----
> > From: Max Andersen
> > Sent: Thursday, February 02, 2006 3:09 PM
> > To: Scott M Stark; Emmanuel Bernard; Bill Burke
> > Cc: Hibernate development
> > Subject: Re: [Hibernate] ClassLoader injection
> >
> > hi,
> >
> > Why is the tcl not the right one even when
> generating classes ?
> >
> > if we don't use the same how can you have
> consistent resource loading,
> > annotation searching and code invocation ?
> >
> > /max
> >
> >> The general problem is that the thread context
> class loader can be too
> >> generic when you have a mesh of class loaders. As
> is mentioned in
> > latter
> >> replies in this thread, if classes from a given
> package namespace have
> >> already been loaded via one class loader,
> generally all subsequent
> >> classes in the same package should be
> loaded/defined using the same
> >> class loader. Not doing so will lead to security
> and type consistency
> >> problems.
> >>
> >> In the case of the ejb3 entity manager spi, it
> does make sense that
> > you
> >> would ask it for the correct class loader for
> byte code manipulation
> > vs
> >> a class loader to query for resources and do
> annotation searching.
> >>
> >> -----Original Message-----
> >> From: Max Andersen
> >> Sent: Tuesday, January 31, 2006 11:53 PM
> >> To: Emmanuel Bernard; Bill Burke
> >> Cc: Hibernate development; Scott M Stark
> >> Subject: Re: [Hibernate] ClassLoader injection
> >>
> >> Hi,
> >>
> >> to bill, yes I know ctx current thread is the
> only way, that was my
> >> whole
> >> point (using ctx current thread in
> >> hibernate was actually the first patch i provided
> to hibernate core ;)
> >>
> >> and yes, having a third classloader concept in
> the spec sounds like a
> >> very
> >> broken thing.
> >> I would love to hear why it is needed.
> >>
> >> /max
> >>
> >>> The RI team is going to creak, but I'm inclined
> to remove it as well.
> >>>
> >>> AS for your first remark, what's wrong with
> doing getResource with
> > the
> >>
> >>> regular classloader? I don't get it.
> >>>
> >>>
> >>> Bill Burke wrote:
> >>>> I understand the need for
> PUInfo.getNewTempClassLoader() as
> >>>> getResource("META-INF/persistence.xml")
> may/will return multiples.
> >>>> Also, you may want to introspect the class for
> annotations before
> > you
> >>
> >>>> decide what needs to be bytecode massaged.
> >>>>
> >>>> As for getClassLoader()?  I'm not sure of the
> reasoning.  I know
> >> Scott
> >>>> has some spec input on this.  Maybe we should
> get it removed?
> >>>>
> >>>> Emmanuel Bernard wrote:
> >>>>> Year I'm aware of that Bill :-)
> >>>>> But in this case, and like Max said, why on
> earth the
> >>>>> PersistenceUnitInfo has a getClassLoader()
> method instead of using
> >> the
> >>>>> context CL?
> >>>>>
> >>>>>
> >>>>> Bill Burke wrote:
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>> Max Rydahl Andersen wrote:
> >>>>>>
> >>>>>>> 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)
> >>>>>>>
> >>>>>>
> >>>>>> Thread.getContextCL() is the only way.  If a
> library doesn't use
> >>>>>> Thread.getCCL() then it is a poorly written
> library.  App server
> >> and
> >>>>>> J2EE in general require this because of
> classloader isolation
> >> (scoped
> >>>>>> ears or wars).  If you are within Hibernate
> code and call
> >>>>>> Class.forName() it will use the classloader
> that loaded Hibernate
> >> to
> >>>>>> load the class. (read the javadocs) and you
> could get CCE, CNF
> >>>>>> exceptions.  If you already know this, then
> apologies.
> >>>>>>
> >>>>>> The same issues effect the loading of
> resources.
> >>>>>>
> >>>>>> Bill
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>
> >>>
> >>
> >>
> >>
> >
> >
> >
> 
> 
> 
> -- 
> --
> 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
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
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

Reply via email to