Package org.apache.camel.component.exec
Class ExecEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.exec.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 notimeout
is used.
-
Constructor Summary
Constructors Constructor Description ExecEndpoint(String uri, ExecComponent component)
-
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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
NO_TIMEOUT
public static final long NO_TIMEOUT
Indicates that notimeout
is used.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExecEndpoint
public ExecEndpoint(String uri, ExecComponent component)
-
-
Method Detail
-
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 ornull
.
-
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.
-
getCommandExecutor
public ExecCommandExecutor getCommandExecutor()
-
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.
-
getBinding
public ExecBinding getBinding()
-
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)
-
-