Gets instance of the scriptEngine for the given scripting language @param scriptingLang ScriptEngine classname or keyword for the scriptingLang @return scriptengine for the given scripting language @throws IOException
(String scriptingLang)
| 279 | * @throws IOException |
| 280 | */ |
| 281 | public static ScriptEngine getInstance(String scriptingLang) |
| 282 | throws IOException { |
| 283 | String scriptingEngine = scriptingLang; |
| 284 | try { |
| 285 | if (SupportedScriptLang.contains(scriptingLang)) { |
| 286 | SupportedScriptLang supportedScriptLang = SupportedScriptLang.valueOf(scriptingLang); |
| 287 | scriptingEngine = supportedScriptLang.getEngineClassName(); |
| 288 | } |
| 289 | return (ScriptEngine) Class.forName(scriptingEngine).newInstance(); |
| 290 | } catch (Exception e) { |
| 291 | throw new IOException("Could not load ScriptEngine: " |
| 292 | + scriptingEngine + " for "+scriptingLang+" (Supported langs: "+SupportedScriptLang.supportedScriptLangs+") : " + e, e); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Runs a script file. |