Class OutputStreamConnector
java.lang.Object
java.lang.Thread
com.oracle.bedrock.runtime.remote.windows.winrm.OutputStreamConnector
- All Implemented Interfaces:
Closeable,AutoCloseable,Runnable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOutputStreamConnector(WindowsSession session, OutputStream stdOut, OutputStream stdErr) Create anOutputStreamConnectorto link the output streams of the remote process controlled by theWindowsSession. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisOutputStreamConnectorand stops the run loop.Obtain theOutputStreamthis connector pipes the remote process stderr to.intObtain the exit value of the remote process or -1 if the process has not yet terminated.Obtain theOutputStreamthis connector pipes the remote process stdout to.Obtain theWindowsSessionrunning the remote process.booleanPoll for the current process output from the remote command.voidrun()The run loop for thisThread.waitFor(com.oracle.bedrock.Option... options) Causes the current thread to wait, if necessary, until the remote command has terminated.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
OutputStreamConnector
Create anOutputStreamConnectorto link the output streams of the remote process controlled by theWindowsSession.- Parameters:
session- theWindowsSessionrunning the remote processstdOut- theOutputStreamto write the process stdout stream tostdErr- theOutputStreamto write the process stderr stream to
-
-
Method Details
-
getOutputStream
Obtain theOutputStreamthis connector pipes the remote process stdout to.- Returns:
- the
OutputStreamthis connector pipes the remote process stdout to
-
getErrorStream
Obtain theOutputStreamthis connector pipes the remote process stderr to.- Returns:
- the
OutputStreamthis connector pipes the remote process stderr to
-
getSession
Obtain theWindowsSessionrunning the remote process.- Returns:
- the
WindowsSessionrunning the remote process
-
close
public void close()Closes thisOutputStreamConnectorand stops the run loop.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
waitFor
Causes the current thread to wait, if necessary, until the remote command has terminated.- Parameters:
options- theOptions for waiting, includingTimeout- 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
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 thisThread.
-