Interface Spawnable

  • All Known Implementing Classes:
    AbstractSpawnable, ProcessSpawn, SshSpawn, SshSpawn2

    public interface Spawnable
    Spawn interface, can use this interface manage Spawan object, obtain functions such as: start / stop, get stdout /stdin / stderr stream, and set close listener
    • Method Detail

      • start

        void start()
            throws java.io.IOException
        This method launches the Spawn. It starts the StreamPipers that enable copying of process stream contents to standard streams.
        Throws:
        java.io.IOException - on trouble.
      • getStdout

        java.io.InputStream getStdout()
        Get a stream from which the Spawn's stdout can be read.
        Returns:
        A stream that represents stdout of a spawned process.
        See Also:
        Process.getInputStream()
      • getStdin

        java.io.OutputStream getStdin()
        Get a stream through which the Spawn's stdin can be written to.
        Returns:
        A stream that represents stdin of a spawned process.
        See Also:
        Process.getOutputStream()
      • getStderr

        java.io.InputStream getStderr()
        Get a stream from which the Spawn's stderr can be read.
        Returns:
        A stream that represents stderr of a spawned process, or null if there is no stderr.
        See Also:
        Process.getErrorStream()
      • isClosed

        boolean isClosed()
        Find out whether the Spawn has finished.
        Returns:
        true if a spawned process has finished.
      • getExitValue

        int getExitValue()
                  throws ExpectJException
        If the Spawn has exited, its exit code is returned.
        Returns:
        The exit code of the finished spawn.
        Throws:
        ExpectJException - if the spawn is still running.
        See Also:
        isClosed(), System.exit(int)
      • stop

        void stop()
        Stops a running Spawn. After this method returns, isClosed() must return true.
      • setCloseListener

        void setCloseListener​(Spawnable.CloseListener closeListener)
        Register a listener that will be called when this spawnable closes.
        Parameters:
        closeListener - The listener that will be notified when this spawnable closes.