Package org.apache.sshd.server.shell
Class UnknownCommand
- java.lang.Object
-
- org.apache.sshd.server.shell.UnknownCommand
-
- All Implemented Interfaces:
java.lang.Runnable
,Command
,CommandLifecycle
public class UnknownCommand extends java.lang.Object implements Command, java.lang.Runnable
Implementation of an unknown command that can be returned byCommandFactory
when the command is not known, as it is supposed to always return a validCommand
object.
-
-
Constructor Summary
Constructors Constructor Description UnknownCommand(java.lang.String command)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy(ChannelSession channel)
This method is called by the SSH server to destroy the command because the client has disconnected somehow.boolean
equals(java.lang.Object obj)
java.lang.String
getCommand()
java.lang.String
getMessage()
int
hashCode()
void
run()
void
setErrorStream(java.io.OutputStream err)
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
setInputStream(java.io.InputStream in)
Set the input stream that can be used by the shell to read input.void
setOutputStream(java.io.OutputStream out)
Set the output stream that can be used by the shell to write its output.void
start(ChannelSession channel, Environment env)
Starts the command execution.java.lang.String
toString()
-
-
-
Field Detail
-
command
private final java.lang.String command
-
message
private final java.lang.String message
-
in
private java.io.InputStream in
-
out
private java.io.OutputStream out
-
err
private java.io.OutputStream err
-
callback
private ExitCallback callback
-
-
Method Detail
-
getCommand
public java.lang.String getCommand()
-
getMessage
public java.lang.String getMessage()
-
setInputStream
public void setInputStream(java.io.InputStream in)
Description copied from interface:Command
Set the input stream that can be used by the shell to read input.- Specified by:
setInputStream
in interfaceCommand
- Parameters:
in
- TheInputStream
used by the shell to read input.
-
setOutputStream
public void setOutputStream(java.io.OutputStream out)
Description copied from interface:Command
Set the output stream that can be used by the shell to write its output.- Specified by:
setOutputStream
in interfaceCommand
- Parameters:
out
- TheOutputStream
used by the shell to write its output
-
setErrorStream
public void setErrorStream(java.io.OutputStream err)
Description copied from interface:Command
Set the error stream that can be used by the shell to write its errors.- Specified by:
setErrorStream
in interfaceCommand
- Parameters:
err
- TheOutputStream
used by the shell to write its errors
-
setExitCallback
public void setExitCallback(ExitCallback callback)
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
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
start
public void start(ChannelSession channel, Environment env) throws java.io.IOException
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:
java.io.IOException
- If failed to start
-
destroy
public void destroy(ChannelSession channel)
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
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-