private void preInvokeScript(ScriptWrapper script) throws ScriptException {
		if (script.getEngine() == null) {
			// Scripts loaded from the configs my have loaded before all of the engines
			script.setEngine(this.getEngineWrapper(script.getEngineName()));
		}
		
		if (script.getEngine() == null) {
			throw new ScriptException("Failed to find script engine: " + script.getEngineName());
		}
		
		refreshScript(script);
		script.setLastErrorDetails("");
		script.setLastException(null);
		script.setLastOutput("");
		
		for (ScriptEventListener listener : this.listeners) {
			try {
				listener.preInvoke(script);
			} catch (Exception e) {
				logScriptEventListenerException(listener, script, e);
			}
		}
	}
private void preInvokeScript ( ScriptWrapper script ) throws ScriptException { if ( script . getEngine ( ) == null ) { script . setEngine ( this . getEngineWrapper ( script . getEngineName ( ) ) ) ; } if ( script . getEngine ( ) == null ) { throw new ScriptException ( "Failed to find script engine: " + script . getEngineName ( ) ) ; } refreshScript ( script ) ; script . setLastErrorDetails ( "" ) ; script . setLastException ( null ) ; script . setLastOutput ( "" ) ; for ( ScriptEventListener listener : this . listeners ) { try { listener . preInvoke ( script ) ; } catch ( Exception e ) { logScriptEventListenerException ( listener , script , e ) ; } } }
Notifies the {@code ScriptEventListener}s that the given {@code script} should be refreshed, resets the error and
output states of the given {@code script} and notifies {@code ScriptEventListener}s of the pre-invocation.
<p>
If the script does not have an engine it will be set one (if found).

@param script the script that will be invoked after the call to this method
@throws ScriptException if the engine of the given {@code script} was not found.
@see ScriptEventListener#refreshScript(ScriptWrapper)
@see ScriptEventListener#preInvoke(ScriptWrapper)