コード例 #1
0
  /**
   * Create a script from a file.
   *
   * @param file a file containing the script's source code.
   * @param parameters script's execution arguments.
   * @throws InvalidScriptException if the creation fails.
   */
  public Script(File file, Serializable[] parameters) throws InvalidScriptException {
    this.scriptEngineLookup = FileUtils.getExtension(file.getPath());

    try {
      script = readFile(file);
    } catch (IOException e) {
      throw new InvalidScriptException("Unable to read script : " + file.getAbsolutePath(), e);
    }
    this.id = file.getPath();
    this.parameters = parameters;
    this.scriptName = file.getName();
  }
コード例 #2
0
  /**
   * Create a script from an URL.
   *
   * @param url representing a script source code.
   * @param parameters execution arguments.
   * @throws InvalidScriptException if the creation fails.
   */
  public Script(URL url, Serializable[] parameters) throws InvalidScriptException {
    this.scriptEngineLookup = FileUtils.getExtension(url.getFile());

    try {
      storeScript(url);
    } catch (IOException e) {
      throw new InvalidScriptException("Unable to read script : " + url.getPath(), e);
    }

    this.id = url.toExternalForm();
    this.parameters = parameters;
    this.scriptName = url.getFile();
  }