Esempio n. 1
0
 /**
  * Create a script mediator for the given language and given script entry key and function
  *
  * @param language the BSF language
  * @param includeKeysMap Include script keys
  * @param key the registry entry key to load the script
  * @param function the function to be invoked
  */
 public ScriptMediator(
     String language, Map<Value, Object> includeKeysMap, Value key, String function) {
   this.language = language;
   this.key = key;
   this.includes = includeKeysMap;
   if (function != null) {
     this.function = function;
   }
   initScriptEngine();
   if (!(scriptEngine instanceof Invocable)) {
     throw new SynapseException(
         "Script engine is not an Invocable" + " engine for language: " + language);
   }
   invocableScript = (Invocable) scriptEngine;
 }
Esempio n. 2
0
  /** Initialise the Mediator for the inline script */
  protected void initInlineScript() {
    try {
      initScriptEngine();

      if (scriptEngine instanceof Compilable) {
        if (log.isDebugEnabled()) {
          log.debug("Script engine supports Compilable interface, " + "compiling script code..");
        }
        compiledScript = ((Compilable) scriptEngine).compile(scriptSourceCode);
      } else {
        // do nothing. If the script engine doesn't support Compilable then
        // the inline script will be evaluated on each invocation
        if (log.isDebugEnabled()) {
          log.debug(
              "Script engine does not support the Compilable interface, "
                  + "in-lined script would be evaluated on each invocation..");
        }
      }

    } catch (ScriptException e) {
      throw new SynapseException("Exception initializing inline script", e);
    }
  }