/* (non-Javadoc) * @see org.marketcetera.strategy.ExecutionEngine#start() */ @Override public Object start() throws StrategyException { try { return scriptEngine.eval(strategy.getLanguage().name(), 0, 0, processedScript); } catch (BSFException e) { CompilationFailed failed = new CompilationFailed(strategy); if (e.getTargetException() instanceof RaiseException) { failed.addDiagnostic(Diagnostic.error(RubyExecutor.exceptionAsString(e))); } StrategyModule.log( LogEventBuilder.error() .withMessage(COMPILATION_FAILED, String.valueOf(strategy), failed.toString()) .withException(failed) .create(), strategy); throw failed; } }
/* (non-Javadoc) * @see org.marketcetera.strategy.ExecutionEngine#prepare(org.marketcetera.strategy.Strategy, java.lang.String) */ @Override public void prepare(Strategy inStrategy, String inProcessedScript) throws StrategyException { strategy = inStrategy; processedScript = inProcessedScript; SLF4JLoggerProxy.debug( this, "Preparing {}", //$NON-NLS-1$ inStrategy); registerScriptEngines(); String languageString = inStrategy.getLanguage().name(); try { synchronized (scriptManager) { if (scriptEngine == null) { String classpath = System.getProperty(Strategy.CLASSPATH_PROPERTYNAME); SLF4JLoggerProxy.debug( this, "Setting classpath to {}", //$NON-NLS-1$ classpath); scriptManager.setClassPath(classpath); scriptEngine = scriptManager.loadScriptingEngine(languageString); SLF4JLoggerProxy.debug(this, "Initializing engine..."); // $NON-NLS-1$ scriptEngine.initialize(scriptManager, languageString, new Vector<Object>()); } else { SLF4JLoggerProxy.debug(this, "Reusing intialized engine..."); // $NON-NLS-1$ } } } catch (BSFException e) { StrategyModule.log( LogEventBuilder.error() .withMessage(NO_SUPPORT_FOR_LANGUAGE, languageString) .withException(e) .create(), strategy); throw new StrategyException( e, new I18NBoundMessage1P(NO_SUPPORT_FOR_LANGUAGE, languageString)); } }