Package javax.script

Examples of javax.script.ScriptException


      // First attempt
      initializeEngine();
     
      // Oh for ..
      if (!isInitialized()) {
        throw new ScriptException("A JavaScript engine could not be found.");
      } else {
        plugin.getLogger().info("Loaded command filter engine.");
      }
    } catch (ScriptException e1) {
      // It's not a huge deal
View Full Code Here


        Object result = ((Invocable) context).invokeFunction(name, event, event.getPacket().getHandle());
       
        if (result instanceof Boolean)
          return (Boolean) result;
        else
          throw new ScriptException("Filter result wasn't a boolean: " + result);
       
      } catch (NoSuchMethodException e) {
        // Must be a fault with the script engine itself
        throw new IllegalStateException("Unable to compile " + name + " into current script engine.", e);
      }
View Full Code Here

    {
        when(muleContext.getRegistry()).thenReturn(muleRegistry);
        when(muleRegistry.lookupObject(SCRIPT_NAME)).thenReturn(script);
        when(script.getScriptEngine()).thenReturn(scriptEngine);
        when(scriptEngine.createBindings()).thenReturn(bindings);
        when(script.runScript(bindings)).thenThrow(new ScriptException("error"));

        new FlowResultFunction().call(new Object[] {SCRIPT_NAME}, context);
    }
View Full Code Here

    try {
      while ((count = reader.read(array, 0, array.length)) > 0) {
        strBuffer.append(array, 0, count);
      }
    } catch (IOException exp) {
      throw new ScriptException(exp);
    }
    return strBuffer.toString();
  }
View Full Code Here

  private ValueExpression parse(String script, ScriptContext scriptContext) throws ScriptException {
    try {
      return expressionFactory.createValueExpression(createElContext(scriptContext), script, Object.class);
    } catch (ELException ele) {
      throw new ScriptException(ele);
    }
  }
View Full Code Here

      if (_appleScriptEngine == null) {
        _appleScriptEngine = _scriptEngineManager.getEngineByName(
          "AppleScript");

        if (_appleScriptEngine == null) {
          throw new ScriptException(
            "AppleScriptEngine not available");
        }
      }
    }
View Full Code Here

  private ScriptEvaluator createNewScriptEvaluator(String languageName) throws ScriptException {

    ScriptEngine engine = new ScriptEngineManager().getEngineByName( languageName );

    if ( engine == null ) {
      throw new ScriptException( "No JSR 223 script engine found for language \"" + languageName + "\"." );
    }

    return new ScriptEvaluator( engine );
  }
View Full Code Here

            globalClosures.setBundle(bundle);
        } catch (ClassCastException cce) { /*ignore.*/ }

        try {
            final Class clazz = getScriptClass(script);
            if (null == clazz) throw new ScriptException("Script class is null");
            return eval(clazz, context);
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine());
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

    @Override
    public CompiledScript compile(final 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);
        }
    }
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.