scriptReader = new EspReader(scriptReader);
}
// container for replaced properties
Map<String, Object> replacedProperties = null;
Scriptable scope = null;
boolean isTopLevelCall = false;
// create a rhino Context and execute the script
try {
final Context rhinoContext = Context.enter();
rhinoContext.setOptimizationLevel(optimizationLevel());
if (ScriptRuntime.hasTopCall(rhinoContext)) {
// reuse the top scope if we are included
scope = ScriptRuntime.getTopCallScope(rhinoContext);
} else {
// create the request top scope, use the ImporterToplevel here
// to support the importPackage and importClasses functions
scope = new ImporterTopLevel();
// Set the global scope to be our prototype
scope.setPrototype(rootScope);
// We want "scope" to be a new top-level scope, so set its
// parent scope to null. This means that any variables created
// by assignments will be properties of "scope".
scope.setParentScope(null);
// setup the context for use
WrapFactory wrapFactory = ((RhinoJavaScriptEngineFactory) getFactory()).getWrapFactory();
rhinoContext.setWrapFactory(wrapFactory);