Class InvertedShellWrapper

    • Field Detail

      • executor

        private final java.util.concurrent.Executor executor
      • bufferSize

        private int bufferSize
      • pumpSleepTime

        private java.time.Duration pumpSleepTime
      • in

        private java.io.InputStream in
      • out

        private java.io.OutputStream out
      • err

        private java.io.OutputStream err
      • shellIn

        private java.io.OutputStream shellIn
      • shellOut

        private java.io.InputStream shellOut
      • shellErr

        private java.io.InputStream shellErr
      • shutdownExecutor

        private boolean shutdownExecutor
    • Constructor Detail

      • InvertedShellWrapper

        public InvertedShellWrapper​(InvertedShell shell,
                                    java.util.concurrent.Executor executor,
                                    boolean shutdownExecutor,
                                    int bufferSize)
        Parameters:
        shell - The InvertedShell
        executor - The Executor to use in order to create the streams pump thread. If null one is auto-allocated and shutdown when wrapper is destroy()-ed.
        shutdownExecutor - If true the executor is shut down when shell wrapper is destroy()-ed. Ignored if executor service auto-allocated
        bufferSize - Buffer size to use - must be above min. size (Byte.SIZE)
    • Method Detail

      • 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
      • 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
      • pumpStreams

        protected void pumpStreams()
      • pumpStream

        protected boolean pumpStream​(java.io.InputStream in,
                                     java.io.OutputStream out,
                                     byte[] buffer)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

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