Class AbstractCommandSupport

    • Field Detail

      • cmdRunner

        protected volatile java.lang.Thread cmdRunner
      • cbCalled

        protected boolean cbCalled
      • command

        private final java.lang.String command
      • in

        private java.io.InputStream in
      • out

        private java.io.OutputStream out
      • err

        private java.io.OutputStream err
      • cmdFuture

        private java.util.concurrent.Future<?> cmdFuture
    • Constructor Detail

      • AbstractCommandSupport

        protected AbstractCommandSupport​(java.lang.String command,
                                         CloseableExecutorService executorService)
    • Method Detail

      • getCommand

        public java.lang.String getCommand()
      • getInputStream

        public java.io.InputStream getInputStream()
      • getOutputStream

        public java.io.OutputStream getOutputStream()
      • getErrorStream

        public java.io.OutputStream getErrorStream()
      • setErrorStream

        public void setErrorStream​(java.io.OutputStream err)
        Description copied from interface: CommandDirectErrorStreamAware
        Set the error stream that can be used by the shell to write its errors.
        Specified by:
        setErrorStream in interface CommandDirectErrorStreamAware
        Parameters:
        err - The OutputStream 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 interface Command
        Parameters:
        callback - The ExitCallback to call when shell is closed
      • getStartedCommandFuture

        protected java.util.concurrent.Future<?> getStartedCommandFuture()
      • 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 implement Runnable, and this method should spawn a new thread like:
         Thread(this).start(); 
         
        Specified by:
        start in interface CommandLifecycle
        Parameters:
        channel - The ChannelSession through which the command has been received
        env - The Environment
        Throws:
        java.io.IOException - If failed to start
      • destroy

        public void destroy​(ChannelSession channel)
                     throws java.lang.Exception
        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 interface CommandLifecycle
        Parameters:
        channel - The ChannelSession through which the command has been received
        Throws:
        java.lang.Exception - if failed to destroy
      • onExit

        protected void onExit​(int exitValue)
      • onExit

        protected void onExit​(int exitValue,
                              java.lang.String exitMessage)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object