2008/11/26 Gili Tzabari <[EMAIL PROTECTED]>
>
> Stuart McCulloch wrote:
> > my main concern is how you'd handle the situation where someone else is
> > using class (A) but Guice wants to "proxy" it by rewriting - the new
> > definition
> > (A') would need to be loaded into another classloader, but that means
> that
> > class A and class A' are incompatible, and people who expect A wouldn't
> be
> > able to use A'
>
> There are two cases:
>
> 1) A is shared between different webapps. I am not particularly
> interested in this use-case but I'm sure you can come up with
> workarounds for it too.
>
> 2) A is used exclusively by one webapp, but someone else might load it
> before Guice. We can solve this quite easily by proxying it eagerly
> before anyone else without instantiating any instances.
>
it's the eager proxying that I'm worried about - could get hairy
for example: how do I tell Guice about the class that should be proxied
without actually loading that class (as Guice works primarily on types)
My only concern is what happens if another framework sits on the same
> webapp and also has a custom ClassLoader. Is there such a thing as
> ClassLoaders cooperating?
>
classloaders can delegate requests between each other - typically this
is done as a tree (child->parent) but OSGi also supports graph based
delegation, which is how it controls visibility and manages updates
however, two classes of the same name defined by two different loaders
are distinct and incompatible (!A.equals(A')) which is the problem I have
with redefining the class at runtime - as Johan says, it has to go into a
separate classloader, unless you use an instrumentation agent
there are also visibility limitations - if I have non-public classes A and B
in the same package "foo" then they can only see each other if they're
loaded by the same classloader (delegation doesn't help here)
Gili
>
--
Cheers, Stuart
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---