public class ShellCommandProcessor
extends java.lang.Object
implements org.springframework.context.Lifecycle, org.springframework.beans.factory.InitializingBean
Constructor and Description |
---|
ShellCommandProcessor(org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer serializer,
java.lang.String command)
Creates a process to invoke a shell command to send and receive messages from the processes using the process's stdin and stdout.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
boolean |
isRunning() |
java.lang.String |
receive()
Receive data from the process.
|
void |
send(java.lang.String data)
Send data as a String to stdin.
|
java.lang.String |
sendAndReceive(java.lang.String data)
Send and receive data in request/response fashion.
|
void |
setCharset(java.lang.String charset)
Set the charset name for String encoding.
|
void |
setEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
A map containing environment variables to add to the process environment.
|
void |
setRedirectErrorStream(boolean redirectErrorStream)
Set to true to redirect stderr to stdout.
|
void |
setWorkingDirectory(java.lang.String workingDirectory)
Set the process working directory
|
void |
start()
Start the process.
|
void |
stop()
Stop the process and close streams.
|
public ShellCommandProcessor(org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer serializer, java.lang.String command)
serializer
- an AbstractByteArraySerializer
to delimit messagescommand
- the shell command with command line arguments as separate stringspublic void start()
start
in interface org.springframework.context.Lifecycle
public java.lang.String receive()
public void send(java.lang.String data)
data
- the datapublic java.lang.String sendAndReceive(java.lang.String data)
data
- the inputpublic void stop()
stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void setRedirectErrorStream(boolean redirectErrorStream)
redirectErrorStream
- public void setEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
environment
- public void setWorkingDirectory(java.lang.String workingDirectory)
workingDirectory
- the file pathpublic void setCharset(java.lang.String charset)
charset
- the charset namepublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception