Package javax.script

Examples of javax.script.ScriptException


            }
        };

        EasyMock.expect(engine.createBindings()).andReturn(new SimpleBindings());
        engine.setContext((ScriptContext) EasyMock.anyObject());
        EasyMock.expect(engine.eval((Reader) EasyMock.anyObject())).andThrow(new ScriptException("test exception"));
        EasyMock.replay(engine);

        scriptedView.setEngineName("test-engine");
        scriptedView.setScript(new ByteArrayResource("test".getBytes(), "test script"));
View Full Code Here


       * } catch (ScriptException e) { throw e;
       */
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new ScriptException(e);
    } catch (Throwable e) {
      throw new RuntimeException(e);
    } finally {
      if (env != null)
        ;//env.close();
View Full Code Here

       * } catch (ScriptException e) { throw e;
       */
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new ScriptException(e);
    } catch (Throwable e) {
      throw new RuntimeException(e);
    } finally {
      if (env != null)
        env.close();
View Full Code Here

      return new MondayCompiledScript(this, program);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new ScriptException(e);
    } catch (Throwable e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    protected ScriptEngine getScriptEngine() throws ScriptException {
        final String lang = getScriptLanguage();

        ScriptEngine scriptEngine = getInstance().getEngineByName(lang);
        if (scriptEngine == null) {
            throw new ScriptException("Cannot find engine named: "+lang);
        }

        return scriptEngine;
    }
View Full Code Here

                    }
                } finally {
                    IOUtils.closeQuietly(fileReader);
                }
            }  else {
                throw new ScriptException("Script file '"+scriptFile.getAbsolutePath()+"' does not exist or is unreadable for element:"+getName());
            }
        } else if (!StringUtils.isEmpty(getScript())){
            if (supportsCompilable && !StringUtils.isEmpty(cacheKey)) {
                CompiledScript compiledScript =
                        compiledScriptsCache.get(cacheKey);
                if (compiledScript==null) {
                    synchronized (compiledScriptsCache) {
                        compiledScript =
                                compiledScriptsCache.get(cacheKey);
                        if (compiledScript==null) {
                            compiledScript =
                                    ((Compilable) scriptEngine).compile(getScript());
                            compiledScriptsCache.put(cacheKey, compiledScript);
                        }
                    }
                }
                return compiledScript.eval(bindings);
            } else {
                return scriptEngine.eval(getScript(), bindings);
            }
        } else {
            throw new ScriptException("Both script file and script text are empty for element:"+getName());           
        }
    }
View Full Code Here

    public ScriptEngine scriptEngine(String extension) throws ScriptException {
        ScriptEngine scriptEngine = scriptEngineByExtensionCache.get(extension);
        if (scriptEngine == null) {
            scriptEngine = scriptEngineManager.getEngineByExtension(extension);
            if (scriptEngine == null) {
                throw new ScriptException("Script engine not found for extension:" + extension);
            }
            initEngine(scriptEngine);
            scriptEngineByExtensionCache.put(extension, scriptEngine);
        }
        return scriptEngine;
View Full Code Here

    public Object eval(String script, ScriptContext ctx)
            throws ScriptException {
        try {
            Class clazz = getScriptClass(script);
            if (clazz == null) throw new ScriptException("Script class is null");
            return eval(clazz, ctx);
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(),
                    e.getSourceLocator(), e.getLine());
        } catch (Exception e) {
            if (debug) e.printStackTrace();
            throw new ScriptException(e);
        }
    }
View Full Code Here

    public CompiledScript compile(String scriptSource) throws ScriptException {
        try {
            return new GroovyCompiledScript(this,
                    getScriptClass(scriptSource));
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(),
                    e.getSourceLocator(), e.getLine());
        } catch (IOException e) {
            throw new ScriptException(e);
        } catch (CompilationFailedException ee) {
            throw new ScriptException(ee);
        }
    }
View Full Code Here

                });

                return scriptObject.run();
            }
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
            // Fix for GROOVY-3669: Can't use several times the same JSR-223 ScriptContext for different groovy script
            // Groovy's scripting engine implementation adds those two variables in the binding
            // but should clean up afterwards
            ctx.removeAttribute("context", ScriptContext.ENGINE_SCOPE);
View Full Code Here

TOP

Related Classes of javax.script.ScriptException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.