Class Exec

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, EnvironmentVariablesHandler, WorkingDirectoryHandler, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, Serializable, Comparable

    public class Exec
    extends AbstractSink
    implements EnvironmentVariablesHandler, WorkingDirectoryHandler
    Pipes the incoming data, after converting it using the provided conversion scheme, into the started process.

    Input/output:
    - accepts:
       adams.flow.core.Unknown


    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: Exec
     
    -annotation <adams.core.base.BaseAnnotation> (property: annotations)
        The annotations to attach to this actor.
        default:
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow execution at this level gets stopped in case this
        actor encounters an error; the error gets propagated; useful for critical
        actors.
        default: false
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console; Note: the enclosing
        actor handler must have this enabled as well.
        default: false
     
    -cmd <adams.core.base.BaseText> (property: command)
        The external command to pipe the data into.
        default: mysql test
     
    -working-directory <java.lang.String> (property: workingDirectory)
        The current working directory for the command.
        default:
     
    -env-var <adams.core.base.BaseKeyValuePair> [-env-var ...] (property: envVars)
        The environment variables to overlay on top of the current ones.
        default:
     
    -conversion <adams.data.conversion.ConversionToString> (property: conversion)
        The conversion scheme to apply to the input tokens.
        default: adams.data.conversion.AnyToString
     
    -delimiter <java.lang.String> (property: delimiter)
        The delimiter string to forward to the process after each token; uses backquoted 
        strings, ie you can use \n for new line and \r for carriage return.
        default: \\n
     
    -finished-signal <java.lang.String> (property: finishedSignal)
        The string to signal the process that the processing has finished; gets 
        ignored if empty string; you can use \\uXXXX for unicode characters (with 
        XXXX being a hexadecimal number), eg \\u001a for EOF.
        default: 
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • BACKUP_PROCESS

        public static final String BACKUP_PROCESS
        the key for storing the process in the backup.
        See Also:
        Constant Field Values
      • BACKUP_WRITER

        public static final String BACKUP_WRITER
        the key for storing the writer in the backup.
        See Also:
        Constant Field Values
      • BACKUP_OUTPUTPROCESSOR_STDOUT

        public static final String BACKUP_OUTPUTPROCESSOR_STDOUT
        the key for storing the stdout output processor.
        See Also:
        Constant Field Values
      • BACKUP_OUTPUTPROCESSOR_STDERR

        public static final String BACKUP_OUTPUTPROCESSOR_STDERR
        the key for storing the stderr output processor.
        See Also:
        Constant Field Values
      • m_Command

        protected BaseText m_Command
        the command to run.
      • m_WorkingDirectory

        protected String m_WorkingDirectory
        the current working directory.
      • m_Conversion

        protected ConversionToString m_Conversion
        the conversion scheme to turn the input into strings.
      • m_Delimiter

        protected String m_Delimiter
        the string to forward to the process after each token.
      • m_FinishedSignal

        protected String m_FinishedSignal
        the string to signal the process that flow has finished.
      • m_Process

        protected Process m_Process
        the process to pipe the data in.
      • m_Writer

        protected BufferedWriter m_Writer
        for writing to stdin of the process.
    • Constructor Detail

      • Exec

        public Exec()
    • Method Detail

      • setCommand

        public void setCommand​(BaseText value)
        Sets the command to run.
        Parameters:
        value - the command
      • getCommand

        public BaseText getCommand()
        Returns the command to run.
        Returns:
        the command
      • commandTipText

        public String commandTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setWorkingDirectory

        public void setWorkingDirectory​(String value)
        Sets the current working directory for the command.
        Specified by:
        setWorkingDirectory in interface WorkingDirectoryHandler
        Parameters:
        value - the directory, ignored if empty
      • workingDirectoryTipText

        public String workingDirectoryTipText()
        Returns the tip text for this property.
        Specified by:
        workingDirectoryTipText in interface WorkingDirectoryHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • envVarsTipText

        public String envVarsTipText()
        Returns the tip text for this property.
        Specified by:
        envVarsTipText in interface EnvironmentVariablesHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setConversion

        public void setConversion​(ConversionToString value)
        Sets the conversion to apply to the input.
        Parameters:
        value - the conversion
      • getConversion

        public ConversionToString getConversion()
        Returns the conversion to apply to the input.
        Returns:
        the conversion
      • conversionTipText

        public String conversionTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setDelimiter

        public void setDelimiter​(String value)
        Sets the delimiter to write to forward to the process after each token. Uses a backquoted string.
        Parameters:
        value - the delimiter
      • getDelimiter

        public String getDelimiter()
        Returns the delimiter to write to the process after each token. Backquoted string.
        Returns:
        the delimiter
      • delimiterTipText

        public String delimiterTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFinishedSignal

        public void setFinishedSignal​(String value)
        Sets the string to send to the process when the flow finishes. Uses a backquoted string.
        Parameters:
        value - the signal string, ignored if empty string
      • getFinishedSignal

        public String getFinishedSignal()
        Returns the string to signal the process the end of flow execution. Backquoted string.
        Returns:
        the signal string, ignored if empty string
      • finishedSignalTipText

        public String finishedSignalTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getActualFinishedSignal

        protected String getActualFinishedSignal()
        Returns the "end of execution" signal string to send to the process. Processes any unicode characters.
        Returns:
        the string
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        the Class of objects that can be processed
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message
      • wrapUp

        public void wrapUp()
        Cleans up after the execution has finished. Graphical output is left untouched.
        Specified by:
        wrapUp in interface Actor
        Overrides:
        wrapUp in class AbstractSink