Class OutputStreamConnector

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Runnable

    public class OutputStreamConnector
    extends Thread
    implements Closeable
    An implementation of a Thread that polls a remote WinRM shell command for the contents of its output streams and then pipes that data to corresponding OutputStreams.

    Copyright (c) 2015. All Rights Reserved. Oracle Corporation.
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

    Author:
    Jonathan Knight
    • Method Detail

      • getOutputStream

        public OutputStream getOutputStream()
        Obtain the OutputStream this connector pipes the remote process stdout to.
        Returns:
        the OutputStream this connector pipes the remote process stdout to
      • getErrorStream

        public OutputStream getErrorStream()
        Obtain the OutputStream this connector pipes the remote process stderr to.
        Returns:
        the OutputStream this connector pipes the remote process stderr to
      • waitFor

        public Integer waitFor​(com.oracle.bedrock.Option... options)
        Causes the current thread to wait, if necessary, until the remote command has terminated.
        Parameters:
        options - the Options for waiting, including Timeout
        Returns:
        the exit code of the remote command. By convention, the value 0 indicates normal termination
        Throws:
        RuntimeException - if there was a problem waiting for termination
      • getExitCode

        public int getExitCode()
        Obtain the exit value of the remote process or -1 if the process has not yet terminated.
        Returns:
        the exit value of the remote process or -1 if the process has not yet terminated
      • pollOutput

        public boolean pollOutput()
                           throws IOException
        Poll for the current process output from the remote command.
        Returns:
        true if the process is still running otherwise false.
        Throws:
        IOException - if an error occurs.
      • run

        public void run()
        The run loop for this Thread.
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread