use of javax.script.SimpleScriptContext in project Lucee by lucee.
the class AbstractScriptEngine method getScriptContext.
/**
* Returns a <code>SimpleScriptContext</code>. The <code>SimpleScriptContext</code>:
*<br><br>
* <ul>
* <li>Uses the specified <code>Bindings</code> for its <code>ENGINE_SCOPE</code>
* </li>
* <li>Uses the <code>Bindings</code> returned by the abstract <code>getGlobalScope</code>
* method as its <code>GLOBAL_SCOPE</code>
* </li>
* <li>Uses the Reader and Writer in the default <code>ScriptContext</code> of this
* <code>ScriptEngine</code>
* </li>
* </ul>
* <br><br>
* A <code>SimpleScriptContext</code> returned by this method is used to implement eval methods
* using the abstract <code>eval(Reader,Bindings)</code> and <code>eval(String,Bindings)</code>
* versions.
*
* @param nn Bindings to use for the <code>ENGINE_SCOPE</code>
* @return The <code>SimpleScriptContext</code>
*/
protected ScriptContext getScriptContext(Bindings nn) {
SimpleScriptContext ctxt = new SimpleScriptContext();
Bindings gs = getBindings(ScriptContext.GLOBAL_SCOPE);
if (gs != null) {
ctxt.setBindings(gs, ScriptContext.GLOBAL_SCOPE);
}
if (nn != null) {
ctxt.setBindings(nn, ScriptContext.ENGINE_SCOPE);
} else {
throw new NullPointerException("Engine scope Bindings may not be null.");
}
ctxt.setReader(context.getReader());
ctxt.setWriter(context.getWriter());
ctxt.setErrorWriter(context.getErrorWriter());
return ctxt;
}
use of javax.script.SimpleScriptContext in project Lucee by lucee.
the class ScriptEngineImpl method getContext.
@Override
public ScriptContext getContext() {
if (context == null) {
context = new SimpleScriptContext();
// we do our own
context.setBindings(new VariablesBinding(), ScriptContext.ENGINE_SCOPE);
}
return context;
}
Aggregations