Class AbstractCommandSupport
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.server.command.AbstractCommandSupport
- All Implemented Interfaces:
Runnable, org.apache.sshd.common.session.SessionContextHolder, SessionHolder<ServerSession>, org.apache.sshd.common.util.threads.ExecutorServiceCarrier, Command, CommandDirectErrorStreamAware, CommandDirectInputStreamAware, CommandDirectOutputStreamAware, CommandDirectStreamsAware, CommandLifecycle, ServerSessionAware, ServerSessionHolder
- Direct Known Subclasses:
AbstractFileSystemCommand
public abstract class AbstractCommandSupport
extends org.apache.sshd.common.util.logging.AbstractLoggingBean
implements Command, Runnable, org.apache.sshd.common.util.threads.ExecutorServiceCarrier, ServerSessionAware, SessionHolder<ServerSession>, ServerSessionHolder
Provides a basic useful skeleton for
Command executions- Author:
- Apache MINA SSHD Project
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Threadprotected org.apache.sshd.common.util.threads.CloseableExecutorServiceFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCommandSupport(String command, org.apache.sshd.common.util.threads.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.org.apache.sshd.common.util.threads.CloseableExecutorServiceorg.apache.sshd.server.ExitCallbackprotected Future<?> protected voidonExit(int exitValue) protected voidvoidSet the error stream that can be used by the shell to write its errors.voidsetExitCallback(org.apache.sshd.server.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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface SessionHolder
getSessionContext
-
Field Details
-
cmdRunner
-
executorService
protected org.apache.sshd.common.util.threads.CloseableExecutorService executorService -
cbCalled
protected boolean cbCalled
-
-
Constructor Details
-
AbstractCommandSupport
protected AbstractCommandSupport(String command, org.apache.sshd.common.util.threads.CloseableExecutorService executorService)
-
-
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
public org.apache.sshd.common.util.threads.CloseableExecutorService getExecutorService()- Specified by:
getExecutorServicein interfaceorg.apache.sshd.common.util.threads.ExecutorServiceCarrier
-
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
public org.apache.sshd.server.ExitCallback getExitCallback() -
setExitCallback
public void setExitCallback(org.apache.sshd.server.ExitCallback callback) 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
-