Package org.springframework.shell.core
Class InteractiveShellRunner
java.lang.Object
org.springframework.shell.core.InteractiveShellRunner
- All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean,ShellRunner
- Direct Known Subclasses:
JLineShellRunner,SystemShellRunner
public abstract class InteractiveShellRunner
extends Object
implements ShellRunner, org.springframework.beans.factory.DisposableBean
Base class for interactive shell runners. Implementations must provide concrete methods
to print messages and flush the output.
- Since:
- 4.0.0
- Author:
- Mahmoud Ben Hassine, David Pilar
-
Constructor Summary
ConstructorsConstructorDescriptionInteractiveShellRunner(InputProvider inputProvider, CommandParser commandParser, CommandRegistry commandRegistry) Create a newInteractiveShellRunnerinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()abstract voidflush()Flush the output.abstract InputReaderGet the input reader.abstract PrintWriterGet the writer to the output.abstract voidPrint a message to the output.voidExecuteShellRunnerwith given args.voidsetDebugMode(boolean debugMode) Set debug mode.voidstop()Signal the runner to stop and wait briefly for its thread to exit.protected voidwakeup()Unblock a parkedInputProvider.readInput()sostop()can return.
-
Constructor Details
-
InteractiveShellRunner
public InteractiveShellRunner(InputProvider inputProvider, CommandParser commandParser, CommandRegistry commandRegistry) Create a newInteractiveShellRunnerinstance.- Parameters:
inputProvider- the input providercommandParser- the command parsercommandRegistry- the command registry
-
-
Method Details
-
run
Description copied from interface:ShellRunnerExecuteShellRunnerwith given args.- Specified by:
runin interfaceShellRunner- Parameters:
args- the raw arguments- Throws:
Exception- possible error during run
-
print
Print a message to the output.- Parameters:
message- the message to print
-
flush
public abstract void flush()Flush the output. -
getWriter
Get the writer to the output.- Returns:
- the print writer
-
getReader
Get the input reader.- Returns:
- the input reader
-
setDebugMode
public void setDebugMode(boolean debugMode) Set debug mode.- Parameters:
debugMode- true to enable debug mode, false otherwise
-
stop
public void stop()Signal the runner to stop and wait briefly for its thread to exit. -
wakeup
protected void wakeup()Unblock a parkedInputProvider.readInput()sostop()can return. -
destroy
public void destroy()- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-