mil.dod.th.ose.core/src/mil/dod/th/ose/core/impl/mp/MissionProgramManagerImpl.java
public void scriptInitialization(final ProgramImpl program)
    {
        // thread context class loader is used by script engine to access the TH API, set it to the runtime's class 
        // loader
        Thread.currentThread().setContextClassLoader(m_MissionProgramRuntime.getClassLoader());

        try
        {
            // put base bindings together with arguments for all bindings
            final Bindings bindings = m_ScriptEngine.createBindings();
            bindings.putAll(m_BaseBindings);
            bindings.put("TestResult", new MissionScript.TestResultConversionClass());
            bindings.putAll(program.getExecParams());

            synchronized (m_ScriptEngine)
            {
                m_ScriptEngine.put(ScriptEngine.FILENAME, program.getProgramName());
                m_Logging.info("Starting to initialize [%s]", program.getProgramName());

                final ScriptContext context = new SimpleScriptContext();
                context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);                

                try (InputStream is = m_UpgradeSource.openStream())
                {
                    m_ScriptEngine.eval(new InputStreamReader(is), context);
                }

                final Object result = m_ScriptEngine.eval(program.getSource(), context);
                final Invocable inv = (Invocable) m_ScriptEngine;
                final MissionScript scriptObj = inv.getInterface(result, MissionScript.class);
                program.setMissionScript(scriptObj);
            }

            m_Logging.info("Mission program [%s] initialized successfully. "
                    + "The program is waiting to execute.", program.getProgramName());
            program.changeStatus(ProgramStatus.WAITING_INITIALIZED);
        }
        catch (final ScriptException | IOException e)
        {
            program.changeStatus(ProgramStatus.INITIALIZATION_ERROR);
            m_Logging.error(e, "Mission program %s has failed initialization, this will prevent the "
                    + "script from ever executing. Check the script and reload the mission. This error "
                    + "does NOT mean that the dependencies could not be fulfilled.", program.getProgramName());
        }
    }
/**
     * Initial evaluation of the script. This must be called immediately once a script's dependencies are satisfied, 
     * and before the script is called to be executed.
     * @param program
     *     the program to containing the script to initialize
     */
Initial evaluation of the script. This must be called immediately once a script's dependencies are satisfied,
and before the script is called to be executed.
@param program
the program to containing the script to initialize
Initial evaluation of the script . This must be called immediately once a script ' s dependencies are satisfied and before the script is called to be executed . @param program the program to containing the script to initialize
public void scriptInitialization(final ProgramImpl program)
    {
        Thread.currentThread().setContextClassLoader(m_MissionProgramRuntime.getClassLoader());
        try
        {
            final Bindings bindings = m_ScriptEngine.createBindings();
            bindings.putAll(m_BaseBindings);
            bindings.put("TestResult", new MissionScript.TestResultConversionClass());
            bindings.putAll(program.getExecParams());
            synchronized (m_ScriptEngine)
            {
                m_ScriptEngine.put(ScriptEngine.FILENAME, program.getProgramName());
                m_Logging.info("Starting to initialize [%s]", program.getProgramName());
                final ScriptContext context = new SimpleScriptContext();
                context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);                
                try (InputStream is = m_UpgradeSource.openStream())
                {
                    m_ScriptEngine.eval(new InputStreamReader(is), context);
                }
                final Object result = m_ScriptEngine.eval(program.getSource(), context);
                final Invocable inv = (Invocable) m_ScriptEngine;
                final MissionScript scriptObj = inv.getInterface(result, MissionScript.class);
                program.setMissionScript(scriptObj);
            }
            m_Logging.info("Mission program [%s] initialized successfully. "
                    + "The program is waiting to execute.", program.getProgramName());
            program.changeStatus(ProgramStatus.WAITING_INITIALIZED);
        }
        catch (final ScriptException | IOException e)
        {
            program.changeStatus(ProgramStatus.INITIALIZATION_ERROR);
            m_Logging.error(e, "Mission program %s has failed initialization, this will prevent the "
                    + "script from ever executing. Check the script and reload the mission. This error "
                    + "does NOT mean that the dependencies could not be fulfilled.", program.getProgramName());
        }
    }
public void scriptInitialization ( final ProgramImpl program ) { Thread . currentThread ( ) . setContextClassLoader ( m_MissionProgramRuntime . getClassLoader ( ) ) ; try { final Bindings bindings = m_ScriptEngine . createBindings ( ) ; bindings . putAll ( m_BaseBindings ) ; bindings . put ( "TestResult" , new MissionScript . TestResultConversionClass ( ) ) ; bindings . putAll ( program . getExecParams ( ) ) ; synchronized ( m_ScriptEngine ) { m_ScriptEngine . put ( ScriptEngine . FILENAME , program . getProgramName ( ) ) ; m_Logging . info ( "Starting to initialize [%s]" , program . getProgramName ( ) ) ; final ScriptContext context = new SimpleScriptContext ( ) ; context . setBindings ( bindings , ScriptContext . ENGINE_SCOPE ) ; try ( InputStream is = m_UpgradeSource . openStream ( ) ) { m_ScriptEngine . eval ( new InputStreamReader ( is ) , context ) ; } final Object result = m_ScriptEngine . eval ( program . getSource ( ) , context ) ; final Invocable inv = ( Invocable ) m_ScriptEngine ; final MissionScript scriptObj = inv . getInterface ( result , MissionScript . class ) ; program . setMissionScript ( scriptObj ) ; } m_Logging . info ( "Mission program [%s] initialized successfully. " + "The program is waiting to execute." , program . getProgramName ( ) ) ; program . changeStatus ( ProgramStatus . WAITING_INITIALIZED ) ; } catch ( final ScriptException | IOException e ) { program . changeStatus ( ProgramStatus . INITIALIZATION_ERROR ) ; m_Logging . error ( e , "Mission program %s has failed initialization, this will prevent the " + "script from ever executing. Check the script and reload the mission. This error " + "does NOT mean that the dependencies could not be fulfilled." , program . getProgramName ( ) ) ; } }
Initial evaluation of the script.
Initial evaluation of the script .
// thread context class loader is used by script engine to access the TH API, set it to the runtime's class  // loader // put base bindings together with arguments for all bindings