felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Ziegeler <cziege...@apache.org>
Subject Re: Question about class loading and SCR (see FELIX-624)
Date Wed, 23 Jul 2008 12:27:04 GMT
Felix Meschberger wrote:
> Right, this should work as the framework should already guarantee that 
> the class object used by the service and the class object used by the 
> abstract class with the bind methods are the same.
> Nevertheless, I would think, that using the class loader from 
> Class.getClassLoader() of the class providing the bind (or unbind) 
> method to be called is probably better than using the bundle providing 
> the service. Its just cleaner IMHO.
> That is the assignment of the parameterClass in DependencyManager#734 
> would be:
>    parameterClass =
>        targetClass.getClassLoader().loadClass(parameterClassName)
> instead of using serviceBundle.loadClass.
> Of course, we would have to catch (and ignore) the 
> ClassNotFoundException here, as the loader of the target class might not 
> have the parameter class because the target class does not have the bind 
> method we are looking for.
Hmm, not sure if this is cleaner :) In the end the class loader which 
the service interface is used as this one is exporting the interface. So 
as we already have exactly this class from this class loader its easier 
(and faster?) to use this directly than to refetch this.
I guess in the end it's a matter of taste. I have no real preference as 
long as its working :)

Carsten Ziegeler

View raw message