Examples of ScriptException


Examples of javax.script.ScriptException

            ScriptEngine engine = script.getEngine();
            try {
                Invocable invocableEngine = (Invocable) engine;
                result = invocableEngine.invokeFunction(functionName, args == null ? EMPTY_ARGS : args);
            } catch (ClassCastException e) {
                throw new ScriptException("Script engine " + engine.getClass().getName() + " does not support function/method invocations");
            }
        }
        return result;
    }
View Full Code Here

Examples of javax.script.ScriptException

        if (UtilValidate.isNotEmpty(functionName)) {
            try {
                Invocable invocableEngine = (Invocable) engine;
                result = invocableEngine.invokeFunction(functionName, args == null ? EMPTY_ARGS : args);
            } catch (ClassCastException e) {
                throw new ScriptException("Script engine " + engine.getClass().getName() + " does not support function/method invocations");
            }
        }
        return result;
    }
View Full Code Here

Examples of javax.script.ScriptException

    public Object eval(final String script, final String scriptLanguage) throws ScriptException
    {
      final ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName(scriptLanguage);
      if (scriptEngine == null)
      {
        throw new ScriptException(String.format
            ("DataFactoryScriptingSupport: Failed to locate scripting engine for language '%s'.", scriptLanguage));
      }

      scriptEngine.setContext(context);
      return scriptEngine.eval(script);
View Full Code Here

Examples of javax.script.ScriptException

                           final String encoding) throws ScriptException
    {
      final ResourceKey resourceKey = createKeyFromString(resourceManager, contextKey, file);
      if (resourceKey == null)
      {
        throw new ScriptException("Unable to load script");
      }
      try
      {
        final ResourceData loadedResource = resourceManager.load(resourceKey);
        final byte[] resource = loadedResource.getResource(resourceManager);
        return eval(new String(resource, encoding), defaultScriptLanguage);
      }
      catch (ResourceLoadingException e)
      {
        throw new ScriptException(e);
      }
      catch (UnsupportedEncodingException e)
      {
        throw new ScriptException(e);
      }
    }
View Full Code Here

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

Examples of javax.script.ScriptException

        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

Examples of javax.script.ScriptException

    {
        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

Examples of javax.script.ScriptException

    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

Examples of javax.script.ScriptException

  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

Examples of javax.script.ScriptException

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

        if (_appleScriptEngine == null) {
          throw new ScriptException(
            "AppleScriptEngine not available");
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.