binding issues

Andreas Mueller am at iit.de
Thu Jan 12 08:12:53 UTC 2017


Will do. 

Can you tell me whether the engine is shared between scripts? Is there a way to use one engine per script and to start absolute clean (no caches, no refs from previous runs) just like when the JVM was started?

Thanks,
Andreas

> Am 12.01.2017 um 05:23 schrieb Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com>:
> 
> Will you please submit a bug with a compilable/runnable test case attached?
> 
> Thanks,
> -Sundar
> 
>> On 11/01/17, 11:09 PM, Andreas Mueller wrote:
>> Hi,
>> 
>> it seems I have a problem understanding Nashorn’s bindings...
>> 
>> I have multiple scripts, each independent of each other. They should run concurrently with their own context and engine scope bindings. This is created as follows for each script:
>> 
>> ScriptEngineManager manager = new ScriptEngineManager();
>> ScriptEngine engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue());
>> if (engine == null)
>>     throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!");
>> ScriptContext newContext = new SimpleScriptContext();
>> streamContext.engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
>> 
>> Internally we have a Java-based processor which calls Javascript functions (callbacks). It is always the same thread.
>> 
>> It works fine when I start a script the first time. If I stop it (without stopping the JVM) and restart it (it runs through the code above) or if I run another script concurrently, I’m getting problems in so far that calls inside a Javascript callback to Java objects that set data don’t work. The data is not null on the Javascript callback but null inside the Java method.
>> 
>> Here is an example callback:
>> 
>> stream.create().memoryGroup("queues", "name").onCreate(function (memoryGroup, key) {
>>     stream.create().memory(key);
>>     print("Add:"+ key+"="+stream.memory(key));
>> });
>> 
>> The above “stream.create().memory(key)” is a Java method that has a printout:
>> 
>> AddMem: orderpos, mem=HeapMemory{name='orderpos’}
>> 
>> But when I retrieve it with "stream.memory(key)” in the print statement of the Javascript function I’m getting:
>> 
>> Add:orderpos=null
>> 
>> For me this points to the bindings, e.g. a binding from a previous running instance of the script or something else. Can somebody provide some help? What do I need to do to have always a clean instance of a binding when I rerun a script without stopping the JVM?
>> 
>> Thanks,
>> Andreas
>> 



IIT Software GmbH
Münsterstr. 111, 48145 Münster, Germany
Phone: +49 (0)2506 3049340
Managing Director: Andreas Müller
District Court: Amtsgericht Münster, HRB 16294
VAT-No: DE199945912

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.




More information about the nashorn-dev mailing list