Class ScriptedPolicy

java.lang.Object
org.jppf.node.policy.ExecutionPolicy
org.jppf.node.policy.ScriptedPolicy
All Implemented Interfaces:
Serializable

public class ScriptedPolicy extends ExecutionPolicy
A policy which executes an aribtrary script in its accepts() method.
Author:
Laurent Cohen
See Also:
  • Field Details

    • spec

      protected final ScriptDefinition spec
      The script specification.
    • evaluationError

      protected boolean evaluationError
      Flag set if an error is raised while executing the script, to avoid evaluating the script again.
  • Constructor Details

    • ScriptedPolicy

      public ScriptedPolicy(String language, String script)
      Initialize this policy with a script language and a script.
      Parameters:
      language - the script language to use.
      script - the script to execute.
    • ScriptedPolicy

      public ScriptedPolicy(String language, Reader scriptReader) throws IOException
      Initialize this policy with a script language and a script read from a reader.
      Parameters:
      language - the script language to use.
      scriptReader - a reader from which to read the script to execute.
      Throws:
      IOException - if any error occurs while reading the script from the reader.
    • ScriptedPolicy

      public ScriptedPolicy(String language, File scriptFile) throws IOException
      Initialize this policy with a script language and a script read from a file.
      Parameters:
      language - the script language to use.
      scriptFile - the file containing the script to execute.
      Throws:
      IOException - if any error occurs while reading the script from the reader.
  • Method Details

    • accepts

      public boolean accepts(PropertiesCollection<String> info)
      Description copied from class: ExecutionPolicy
      Determines whether this policy accepts the specified node. This method must be overriden in subclasses.
      Specified by:
      accepts in class ExecutionPolicy
      Parameters:
      info - system information for the node on which the tasks will run if accepted.
      Returns:
      true if the node is accepted, false otherwise.
    • toString

      public String toString(int n)
      Description copied from class: ExecutionPolicy
      Get an xml string representation of this policy with the specified starting indentation level.
      Specified by:
      toString in class ExecutionPolicy
      Parameters:
      n - the size of the indent to startwith.
      Returns:
      an indented string depending on the value of toStringIndent.