Message10902

Author amak
Recipients amak, yocaba
Date 2016-08-22.12:54:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471870469.72.0.437830550041.issue2513@psf.upfronthosting.co.za>
In-reply-to
Content
JSR 223 does have facilities for dealing with these situations.

All ScriptEngine "eval" calls can take an optional ScriptContext which defines, among other things, the input and output channels. PyScriptEngine also supports this method.

https://hg.python.org/jython/file/tip/src/org/python/jsr223/PyScriptEngine.java#l30

However, ScriptContext is just an interface, and cannot be instantiated.

So you could write your own implementation of ScriptContext, which can provide separate input and output channels for every call to the eval method.

The good thing about this is that your implementation of ScriptContext would be completely reusable: you could use the same class for every JSR 223 language you might want to support.

http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptContext.html

You could simplify things by using SimpleScriptContext.

http://docs.oracle.com/javase/8/docs/api/javax/script/SimpleScriptContext.html

Hope this helps.

Alan.
History
Date User Action Args
2016-08-22 12:54:29amaksetmessageid: <1471870469.72.0.437830550041.issue2513@psf.upfronthosting.co.za>
2016-08-22 12:54:29amaksetrecipients: + amak, yocaba
2016-08-22 12:54:29amaklinkissue2513 messages
2016-08-22 12:54:28amakcreate