Top Description Fields Constructors Methods
org.apache.sshd.server.command

public abstract Class AbstractCommandSupport

extends AbstractLoggingBean
implements Command, Runnable, ExecutorServiceCarrier, ServerSessionAware, SessionHolder<ServerSession>, ServerSessionHolder
Class Inheritance
All Implemented Interfaces
org.apache.sshd.server.session.ServerSessionHolder, org.apache.sshd.common.session.SessionHolder, org.apache.sshd.common.session.SessionContextHolder, org.apache.sshd.server.session.ServerSessionAware, org.apache.sshd.common.util.threads.ExecutorServiceCarrier, java.lang.Runnable, org.apache.sshd.server.command.Command, org.apache.sshd.server.command.CommandDirectStreamsAware, org.apache.sshd.server.command.CommandDirectErrorStreamAware, org.apache.sshd.server.command.CommandDirectOutputStreamAware, org.apache.sshd.server.command.CommandDirectInputStreamAware, org.apache.sshd.server.command.CommandLifecycle
Known Direct Subclasses
org.apache.sshd.server.command.AbstractFileSystemCommand
Imports
java.io.IOException, .InputStream, .OutputStream, java.util.Collection, java.util.concurrent.Future, org.apache.sshd.common.session.Session, .SessionHolder, org.apache.sshd.common.util.GenericUtils, org.apache.sshd.common.util.logging.AbstractLoggingBean, org.apache.sshd.common.util.threads.CloseableExecutorService, .ExecutorServiceCarrier, .ThreadUtils, org.apache.sshd.server.Environment, .ExitCallback, org.apache.sshd.server.channel.ChannelSession, org.apache.sshd.server.session.ServerSession, .ServerSessionAware, .ServerSessionHolder

Provides a basic useful skeleton for Command executions
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private ExitCallback
protected boolean
private Future<?>
protected volatile Thread
private final String
private Environment
private OutputStream
protected CloseableExecutorService
private InputStream
private OutputStream
private ServerSession
Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
log

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
destroy(ChannelSession
The ChannelSession through which the command has been received
channel
)

Implements org.apache.sshd.server.command.CommandLifecycle.destroy.

This method is called by the SSH server to destroy the command because the client has disconnected somehow.

public String
public Environment
public OutputStream
public CloseableExecutorService
public ExitCallback
public InputStream
public OutputStream
public ServerSession
public ServerSession
protected Future<?>
protected void
onExit(int exitValue)

protected void
onExit(int exitValue, String exitMessage)

public void
setErrorStream(OutputStream
The OutputStream used by the shell to write its errors
err
)

Implements org.apache.sshd.server.command.CommandDirectErrorStreamAware.setErrorStream.

Set the error stream that can be used by the shell to write its errors.

public void
setExitCallback(ExitCallback
The ExitCallback to call when shell is closed
callback
)

Implements org.apache.sshd.server.command.Command.setExitCallback.

Set the callback that the shell has to call when it is closed.

public void
setInputStream(InputStream
The InputStream used by the shell to read input.
in
)

Implements org.apache.sshd.server.command.CommandDirectInputStreamAware.setInputStream.

Set the input stream that can be used by the shell to read input.

public void
setOutputStream(OutputStream
The OutputStream used by the shell to write its output
out
)

Implements org.apache.sshd.server.command.CommandDirectOutputStreamAware.setOutputStream.

Set the output stream that can be used by the shell to write its output.

public void
setSession(ServerSession
The ServerSession in which this shell will be executed.
session
)

Implements org.apache.sshd.server.session.ServerSessionAware.setSession.

public void
start(ChannelSession
The ChannelSession through which the command has been received
channel
,
Environment env)

Implements org.apache.sshd.server.command.CommandLifecycle.start.

Starts the command execution.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
debugdebugdebugdebugdebugerrorerrorerrorerrorerrorgetSimplifiedLoggerinfoinfowarnwarnwarnwarnwarnwarnwarnwarn

Field Detail

callbackback to summary
private ExitCallback callback
cbCalledback to summary
protected boolean cbCalled
cmdFutureback to summary
private Future<?> cmdFuture
cmdRunnerback to summary
protected volatile Thread cmdRunner
commandback to summary
private final String command
environmentback to summary
private Environment environment
errback to summary
private OutputStream err
executorServiceback to summary
protected CloseableExecutorService executorService
inback to summary
private InputStream in
outback to summary
private OutputStream out
serverSessionback to summary
private ServerSession serverSession

Constructor Detail

AbstractCommandSupportback to summary
protected AbstractCommandSupport(String command, CloseableExecutorService executorService)

Method Detail

destroyback to summary
public void destroy(ChannelSession channel) throws Exception

Implements org.apache.sshd.server.command.CommandLifecycle.destroy.

Doc from org.apache.sshd.server.command.CommandLifecycle.destroy.

This method is called by the SSH server to destroy the command because the client has disconnected somehow.

Parameters
channel:ChannelSession

The ChannelSession through which the command has been received

Annotations
@Override
Exceptions
Exception:
if failed to destroy
getCommandback to summary
public String getCommand()
getEnvironmentback to summary
public Environment getEnvironment()
getErrorStreamback to summary
public OutputStream getErrorStream()
getExecutorServiceback to summary
public CloseableExecutorService getExecutorService()

Implements org.apache.sshd.common.util.threads.ExecutorServiceCarrier.getExecutorService.

Returns:CloseableExecutorService

Doc from org.apache.sshd.common.util.threads.ExecutorServiceCarrier.getExecutorService.

The CloseableExecutorService to use

Annotations
@Override
getExitCallbackback to summary
public ExitCallback getExitCallback()
getInputStreamback to summary
public InputStream getInputStream()
getOutputStreamback to summary
public OutputStream getOutputStream()
getServerSessionback to summary
public ServerSession getServerSession()

Implements org.apache.sshd.server.session.ServerSessionHolder.getServerSession.

Returns:ServerSession

Doc from org.apache.sshd.server.session.ServerSessionHolder.getServerSession.

The underlying ServerSession used

Annotations
@Override
getSessionback to summary
public ServerSession getSession()

Implements org.apache.sshd.common.session.SessionHolder.getSession.

Annotations
@Override
getStartedCommandFutureback to summary
protected Future<?> getStartedCommandFuture()
onExitback to summary
protected void onExit(int exitValue)
onExitback to summary
protected void onExit(int exitValue, String exitMessage)
setErrorStreamback to summary
public void setErrorStream(OutputStream err)

Implements org.apache.sshd.server.command.CommandDirectErrorStreamAware.setErrorStream.

Doc from org.apache.sshd.server.command.CommandDirectErrorStreamAware.setErrorStream.

Set the error stream that can be used by the shell to write its errors.

Parameters
err:OutputStream

The OutputStream used by the shell to write its errors

Annotations
@Override
setExitCallbackback to summary
public void setExitCallback(ExitCallback callback)

Implements org.apache.sshd.server.command.Command.setExitCallback.

Doc from org.apache.sshd.server.command.Command.setExitCallback.

Set the callback that the shell has to call when it is closed.

Parameters
callback:ExitCallback

The ExitCallback to call when shell is closed

Annotations
@Override
setInputStreamback to summary
public void setInputStream(InputStream in)

Implements org.apache.sshd.server.command.CommandDirectInputStreamAware.setInputStream.

Doc from org.apache.sshd.server.command.CommandDirectInputStreamAware.setInputStream.

Set the input stream that can be used by the shell to read input.

Parameters
in:InputStream

The InputStream used by the shell to read input.

Annotations
@Override
setOutputStreamback to summary
public void setOutputStream(OutputStream out)

Implements org.apache.sshd.server.command.CommandDirectOutputStreamAware.setOutputStream.

Doc from org.apache.sshd.server.command.CommandDirectOutputStreamAware.setOutputStream.

Set the output stream that can be used by the shell to write its output.

Parameters
out:OutputStream

The OutputStream used by the shell to write its output

Annotations
@Override
setSessionback to summary
public void setSession(ServerSession session)

Implements org.apache.sshd.server.session.ServerSessionAware.setSession.

Parameters
session:ServerSession

Doc from org.apache.sshd.server.session.ServerSessionAware.setSession.

The ServerSession in which this shell will be executed.

Annotations
@Override
startback to summary
public void start(ChannelSession channel, Environment env) throws IOException

Implements org.apache.sshd.server.command.CommandLifecycle.start.

Doc from org.apache.sshd.server.command.CommandLifecycle.start.

Starts the command execution. All streams must have been set before calling this method. The command should implement java.lang.Runnable, and this method should spawn a new thread like:

Thread(this).start();

Parameters
channel:ChannelSession

The ChannelSession through which the command has been received

env:Environment

The Environment

Annotations
@Override
Exceptions
IOException:
If failed to start
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override