Class ExecEndpoint

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasId, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    @UriEndpoint(firstVersion="2.3.0",
                 scheme="exec",
                 title="Exec",
                 syntax="exec:executable",
                 producerOnly=true,
                 category=SYSTEM,
                 headersClass=ExecBinding.class)
    public class ExecEndpoint
    extends org.apache.camel.support.DefaultEndpoint
    Execute commands on the underlying operating system.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long NO_TIMEOUT
      Indicates that no timeout is used.
      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)  
      org.apache.camel.Producer createProducer()  
      String getArgs()  
      ExecBinding getBinding()  
      ExecCommandExecutor getCommandExecutor()  
      org.apache.camel.LoggingLevel getCommandLogLevel()  
      String getExecutable()  
      String getExitValues()  
      String getOutFile()  
      long getTimeout()  
      String getWorkingDir()  
      boolean isUseStderrOnEmptyStdout()  
      void setArgs​(String args)
      The arguments may be one or many whitespace-separated tokens.
      void setBinding​(ExecBinding binding)
      A reference to a org.apache.commons.exec.ExecBinding in the Registry.
      void setCommandExecutor​(ExecCommandExecutor commandExecutor)
      A reference to a org.apache.commons.exec.ExecCommandExecutor in the Registry that customizes the command execution.
      void setCommandLogLevel​(org.apache.camel.LoggingLevel commandLogLevel)
      Logging level to be used for commands during execution.
      void setExecutable​(String executable)
      Sets the executable to be executed.
      void setExitValues​(String exitValues)
      The exit values of successful executions.
      void setOutFile​(String outFile)
      The name of a file, created by the executable, that should be considered as its output.
      void setTimeout​(long timeout)
      The timeout, in milliseconds, after which the executable should be terminated.
      void setUseStderrOnEmptyStdout​(boolean useStderrOnEmptyStdout)
      A boolean indicating that when stdout is empty, this component will populate the Camel Message Body with stderr.
      void setWorkingDir​(String dir)
      The directory in which the command should be executed.
      • Methods inherited from class org.apache.camel.support.DefaultEndpoint

        configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, doStart, doStop, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
      • Methods inherited from interface org.apache.camel.Endpoint

        getEndpointBaseUri, isSingletonProducer
      • Methods inherited from interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Method Detail

      • createProducer

        public org.apache.camel.Producer createProducer()
                                                 throws Exception
        Throws:
        Exception
      • createConsumer

        public org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)
                                                 throws Exception
        Throws:
        Exception
      • getExecutable

        public String getExecutable()
      • setExecutable

        public void setExecutable​(String executable)
        Sets the executable to be executed. The executable must not be empty or null.
      • getArgs

        public String getArgs()
      • setArgs

        public void setArgs​(String args)
        The arguments may be one or many whitespace-separated tokens.
      • getWorkingDir

        public String getWorkingDir()
      • setWorkingDir

        public void setWorkingDir​(String dir)
        The directory in which the command should be executed. If null, the working directory of the current process will be used.
      • getTimeout

        public long getTimeout()
      • setTimeout

        public void setTimeout​(long timeout)
        The timeout, in milliseconds, after which the executable should be terminated. If execution has not completed within the timeout, the component will send a termination request.
      • getExitValues

        public String getExitValues()
      • setExitValues

        public void setExitValues​(String exitValues)
        The exit values of successful executions. If the process exits with another value, an exception is raised. Comma-separated list of exit values. And empty list (the default) sets no expected exit values and disables the check.
      • getOutFile

        public String getOutFile()
      • setOutFile

        public void setOutFile​(String outFile)
        The name of a file, created by the executable, that should be considered as its output. If no outFile is set, the standard output (stdout) of the executable will be used instead.
      • setCommandExecutor

        public void setCommandExecutor​(ExecCommandExecutor commandExecutor)
        A reference to a org.apache.commons.exec.ExecCommandExecutor in the Registry that customizes the command execution. The default command executor utilizes the commons-exec library, which adds a shutdown hook for every executed command.
      • setBinding

        public void setBinding​(ExecBinding binding)
        A reference to a org.apache.commons.exec.ExecBinding in the Registry.
      • isUseStderrOnEmptyStdout

        public boolean isUseStderrOnEmptyStdout()
      • setUseStderrOnEmptyStdout

        public void setUseStderrOnEmptyStdout​(boolean useStderrOnEmptyStdout)
        A boolean indicating that when stdout is empty, this component will populate the Camel Message Body with stderr. This behavior is disabled (false) by default.
      • getCommandLogLevel

        public org.apache.camel.LoggingLevel getCommandLogLevel()
      • setCommandLogLevel

        public void setCommandLogLevel​(org.apache.camel.LoggingLevel commandLogLevel)
        Logging level to be used for commands during execution. The default value is DEBUG. Possible values are TRACE, DEBUG, INFO, WARN, ERROR or OFF. (Values of ExecCommandLogLevelType enum)