You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2008/04/02 13:56:09 UTC

Re: Disabling JavaPrimitiveWrap in flowscript

On Mar 28, 2008, at 1:47 PM, Tobia Conforto wrote:
> I'd like to disable JavaPrimitiveWrap globally in Cocoon flowscripts.
>
> JavaPrimitiveWrap is a Rhino feature that, when disabled, will  
> return strings and numbers from Java calls as native Javascript  
> types, instead of wrapped Java objects.
>
> One can disable it on a (flowscript-)thread by thread basis by  
> calling:
>
> org 
> .mozilla 
> .javascript 
> .Context 
> .getCurrentContext().getWrapFactory().setJavaPrimitiveWrap(false);
>
> but I'd like to disable it globally for all threads, continuations,  
> etc.
>
> Any hint will be welcome.

In FOM_JavaScriptInterpreter, look for Context.enter() calls. These  
are the places where you can add your initialization:

     context.getWrapFactory().setJavaPrimitiveWrap(false);


Vadim

Re: Disabling JavaPrimitiveWrap in flowscript

Posted by Tobia Conforto <to...@linux.it>.
Vadim Gritsenko wrote:
> In FOM_JavaScriptInterpreter, look for Context.enter() calls. These  
> are the places where you can add your initialization:
> context.getWrapFactory().setJavaPrimitiveWrap(false);

Thank you very much, it works like a charm.

Would you like me to try and make a patch to make it a configurable  
option, for example via properties?  I'm finding it very useful to  
write flowscripts when I can assume that all numbers, booleans and  
especially strings are native javascript objects.  I think others  
might find it useful too.


Tobia