Interface IProcessWrapper
- All Known Implementing Classes:
ProcessWrapperImpl
A wrapper of process associated with some key. Manages starting and killing the process during all the application life and provides it's services.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Specifies that given instance is no longer used.Returns the input stream piped to the process's standard errors stream.Returns the input stream piped to the process's standard output stream.<T> T
getInstance
(Class<T> service) Returns a proxy to given service running within the process.getKey()
Returns a key associated with the process.Returns the output stream piped to the process's standard input stream.Returns the process binder.boolean
isAlive()
Returns whether the process is currently running.void
kill()
Kills the process.
-
Method Details
-
getKey
String getKey()Returns a key associated with the process.
- Returns:
- a key associated with the process (not
null
)
-
getProcessBinder
ProcessBinder getProcessBinder()Returns the process binder.
- Returns:
- the process binder (not
null
)
-
isAlive
boolean isAlive()Returns whether the process is currently running.
- Returns:
- whether the process is currently running (
true
offalse
)
-
getInstance
<T> T getInstance(Class<T> service) throws InstantiationException, IllegalAccessException, IOException, InterruptedException, ProcessStartingTimedOut, ProcessExitedWithErrorException Returns a proxy to given service running within the process.
- Parameters:
service
- given service (notnull
)- Returns:
- a proxy to service running within the process (not
null
) - Throws:
IllegalStateException
- if 'java.security.policy' system property is not set (System.getProperty("java.security.policy")
returns null), or service for key is not bound.RuntimeException
- if could not initially start the processInstantiationException
- if the implementation represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reasonIllegalAccessException
- if could not instantiate the implementation by it's default constructor (for instance, if the default constructor is unaccessible)IOException
- if request of starting a new process is failed due to I/O exceptionInterruptedException
- if request of starting a new process is interruptedProcessStartingTimedOut
- if process has not already started, and now start operation timed outProcessExitedWithErrorException
- if process has not already started, and just after it started, it has exited with error code
-
getOutputStream
OutputStream getOutputStream()Returns the output stream piped to the process's standard input stream. The specification is the same as for
IProcessManager.getOutputStream(String)
.- Returns:
- the output stream piped to the process's standard input stream (see
IProcessManager.getOutputStream(String)
) - See Also:
-
getInputStream
InputStream getInputStream()Returns the input stream piped to the process's standard output stream. The specification is the same as for
IProcessManager.getInputStream(String)
.- Returns:
- the input stream piped to the process's standard output stream (see
IProcessManager.getInputStream(String)
) - See Also:
-
getErrorsStream
InputStream getErrorsStream()Returns the input stream piped to the process's standard errors stream. The specification is the same as for
IProcessManager.getErrorsStream(String)
.- Returns:
- the input stream piped to the process's standard errors stream (see
IProcessManager.getErrorsStream(String)
) - See Also:
-
dispose
Specifies that given instance is no longer used. If there are no used instances in the process within some period of time, the process is killed.
-
kill
void kill()Kills the process.
- Throws:
ProcessDestroyingInterruptedException
- when process destroying operation's thread was interrupted
-