You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Justin Edelson <ju...@gmail.com> on 2010/08/17 22:53:53 UTC

what classloader should a ScriptEngine use?

I implemented a simple GSP/GString ScriptEngine today and got tripped up
with what ClassLoader to use during script evaluation. Currently, the
code is using the ClassLoader of the groovy-all bundle. This has a
dynamic import of *, so it works fine, but this seemed wrong for some
reason.

Is there a better classloader to use in this context?

Thanks,
Justin

Re: what classloader should a ScriptEngine use?

Posted by Justin Edelson <ju...@gmail.com>.
On 8/18/10 1:40 AM, Carsten Ziegeler wrote:
> Justin Edelson  wrote
>> I implemented a simple GSP/GString ScriptEngine today and got tripped up
>> with what ClassLoader to use during script evaluation. Currently, the
>> code is using the ClassLoader of the groovy-all bundle. This has a
>> dynamic import of *, so it works fine, but this seemed wrong for some
>> reason.
>>
>> Is there a better classloader to use in this context?
>>
> Yes :)
> 
> We have the commons dynamic classloader which is more intelligent than a
> dynamic import *. It has the same functionality as that import but the
> class loading can be extended through class loader providers like our
> jcr based class loader.
> The benefits of this classloader are when it comes to reloads/updates of
> bundles. In this case the scripting bundle does not need to be reloaded
> and the dynamic classloader service only restarts if an updated class
> has actually been loaded. So service restarts are kept to an minimum.
> 
> Our jsp and javascript implementations use this classloader.

Thanks for the pointer.

Justin
> 
> Regards
> Carsten


Re: what classloader should a ScriptEngine use?

Posted by Carsten Ziegeler <cz...@apache.org>.
Justin Edelson  wrote
> I implemented a simple GSP/GString ScriptEngine today and got tripped up
> with what ClassLoader to use during script evaluation. Currently, the
> code is using the ClassLoader of the groovy-all bundle. This has a
> dynamic import of *, so it works fine, but this seemed wrong for some
> reason.
> 
> Is there a better classloader to use in this context?
> 
Yes :)

We have the commons dynamic classloader which is more intelligent than a
dynamic import *. It has the same functionality as that import but the
class loading can be extended through class loader providers like our
jcr based class loader.
The benefits of this classloader are when it comes to reloads/updates of
bundles. In this case the scripting bundle does not need to be reloaded
and the dynamic classloader service only restarts if an updated class
has actually been loaded. So service restarts are kept to an minimum.

Our jsp and javascript implementations use this classloader.

Regards
Carsten
-- 
Carsten Ziegeler
cziegeler@apache.org