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 ExitCallback
protected boolean
private Future
<?> protected Thread
private final String
private Environment
private OutputStream
protected CloseableExecutorService
private InputStream
private OutputStream
private ServerSession
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCommandSupport
(String command, CloseableExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy
(ChannelSession channel) This method is called by the SSH server to destroy the command because the client has disconnected somehow.protected Future
<?> protected void
onExit
(int exitValue) protected void
void
Set the error stream that can be used by the shell to write its errors.void
setExitCallback
(ExitCallback callback) Set the callback that the shell has to call when it is closed.void
Set the input stream that can be used by the shell to read input.void
Set the output stream that can be used by the shell to write its output.void
setSession
(ServerSession session) void
start
(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, warn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
getSession
in interfaceSessionHolder<ServerSession>
-
getServerSession
- Specified by:
getServerSession
in interfaceServerSessionHolder
- Returns:
- The underlying
ServerSession
used
-
setSession
- Specified by:
setSession
in interfaceServerSessionAware
- Parameters:
session
- TheServerSession
in which this shell will be executed.
-
getExecutorService
- Specified by:
getExecutorService
in interfaceExecutorServiceCarrier
- Returns:
- The
CloseableExecutorService
to use
-
getInputStream
-
setInputStream
Description copied from interface:CommandDirectInputStreamAware
Set the input stream that can be used by the shell to read input.- Specified by:
setInputStream
in interfaceCommandDirectInputStreamAware
- Parameters:
in
- TheInputStream
used by the shell to read input.
-
getOutputStream
-
setOutputStream
Description copied from interface:CommandDirectOutputStreamAware
Set the output stream that can be used by the shell to write its output.- Specified by:
setOutputStream
in interfaceCommandDirectOutputStreamAware
- Parameters:
out
- TheOutputStream
used by the shell to write its output
-
getErrorStream
-
setErrorStream
Description copied from interface:CommandDirectErrorStreamAware
Set the error stream that can be used by the shell to write its errors.- Specified by:
setErrorStream
in interfaceCommandDirectErrorStreamAware
- Parameters:
err
- TheOutputStream
used by the shell to write its errors
-
getExitCallback
-
setExitCallback
Description copied from interface:Command
Set the callback that the shell has to call when it is closed.- Specified by:
setExitCallback
in interfaceCommand
- Parameters:
callback
- TheExitCallback
to call when shell is closed
-
getEnvironment
-
getStartedCommandFuture
-
start
Description copied from interface:CommandLifecycle
Starts 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:
start
in interfaceCommandLifecycle
- Parameters:
channel
- TheChannelSession
through which the command has been receivedenv
- TheEnvironment
- Throws:
IOException
- If failed to start
-
destroy
Description copied from interface:CommandLifecycle
This method is called by the SSH server to destroy the command because the client has disconnected somehow.- Specified by:
destroy
in interfaceCommandLifecycle
- Parameters:
channel
- TheChannelSession
through which the command has been received- Throws:
Exception
- if failed to destroy
-
onExit
protected void onExit(int exitValue) -
onExit
-
toString
-