Package org.apache.sshd.server.command
Class AbstractCommandSupport
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.server.command.AbstractCommandSupport
- All Implemented Interfaces:
Runnable,SessionContextHolder,SessionHolder<ServerSession>,ExecutorServiceCarrier,Command,CommandDirectErrorStreamAware,CommandDirectInputStreamAware,CommandDirectOutputStreamAware,CommandDirectStreamsAware,CommandLifecycle,ServerSessionAware,ServerSessionHolder
- Direct Known Subclasses:
AbstractFileSystemCommand
public abstract class AbstractCommandSupport
extends AbstractLoggingBean
implements Command, Runnable, ExecutorServiceCarrier, ServerSessionAware, SessionHolder<ServerSession>, ServerSessionHolder
Provides a basic useful skeleton for
Command executions-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExitCallbackprotected booleanprivate Future<?> protected Threadprivate final Stringprivate Environmentprivate OutputStreamprotected CloseableExecutorServiceprivate InputStreamprivate OutputStreamprivate ServerSessionFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCommandSupport(String command, CloseableExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy(ChannelSession channel) This method is called by the SSH server to destroy the command because the client has disconnected somehow.protected Future<?> protected voidonExit(int exitValue) protected voidvoidSet the error stream that can be used by the shell to write its errors.voidsetExitCallback(ExitCallback callback) Set the callback that the shell has to call when it is closed.voidSet the input stream that can be used by the shell to read input.voidSet the output stream that can be used by the shell to write its output.voidsetSession(ServerSession session) voidstart(ChannelSession channel, Environment env) Starts the command execution.toString()Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
Field Details
-
cmdRunner
-
executorService
-
cbCalled
protected boolean cbCalled -
command
-
in
-
out
-
err
-
callback
-
environment
-
cmdFuture
-
serverSession
-
-
Constructor Details
-
AbstractCommandSupport
-
-
Method Details
-
getCommand
-
getSession
- Specified by:
getSessionin interfaceSessionHolder<ServerSession>
-
getServerSession
- Specified by:
getServerSessionin interfaceServerSessionHolder- Returns:
- The underlying
ServerSessionused
-
setSession
- Specified by:
setSessionin interfaceServerSessionAware- Parameters:
session- TheServerSessionin which this shell will be executed.
-
getExecutorService
- Specified by:
getExecutorServicein interfaceExecutorServiceCarrier- Returns:
- The
CloseableExecutorServiceto use
-
getInputStream
-
setInputStream
Description copied from interface:CommandDirectInputStreamAwareSet the input stream that can be used by the shell to read input.- Specified by:
setInputStreamin interfaceCommandDirectInputStreamAware- Parameters:
in- TheInputStreamused by the shell to read input.
-
getOutputStream
-
setOutputStream
Description copied from interface:CommandDirectOutputStreamAwareSet the output stream that can be used by the shell to write its output.- Specified by:
setOutputStreamin interfaceCommandDirectOutputStreamAware- Parameters:
out- TheOutputStreamused by the shell to write its output
-
getErrorStream
-
setErrorStream
Description copied from interface:CommandDirectErrorStreamAwareSet the error stream that can be used by the shell to write its errors.- Specified by:
setErrorStreamin interfaceCommandDirectErrorStreamAware- Parameters:
err- TheOutputStreamused by the shell to write its errors
-
getExitCallback
-
setExitCallback
Description copied from interface:CommandSet the callback that the shell has to call when it is closed.- Specified by:
setExitCallbackin interfaceCommand- Parameters:
callback- TheExitCallbackto call when shell is closed
-
getEnvironment
-
getStartedCommandFuture
-
start
Description copied from interface:CommandLifecycleStarts the command execution. All streams must have been set before calling this method. The command should implementRunnable, and this method should spawn a new thread like:Thread(this).start();- Specified by:
startin interfaceCommandLifecycle- Parameters:
channel- TheChannelSessionthrough which the command has been receivedenv- TheEnvironment- Throws:
IOException- If failed to start
-
destroy
Description copied from interface:CommandLifecycleThis method is called by the SSH server to destroy the command because the client has disconnected somehow.- Specified by:
destroyin interfaceCommandLifecycle- Parameters:
channel- TheChannelSessionthrough which the command has been received- Throws:
Exception- if failed to destroy
-
onExit
protected void onExit(int exitValue) -
onExit
-
toString
-