Interface ProcessBinder
-
public interface ProcessBinder
A binder for process with specified key. All bindings for that process must be performed via instance of this interface. Get an instance of this interface via
IProcessManager.getProcessBinder(String)
, set process parameters and bind classes (seeServiceBinder
.This interface is designed to be thread-safe. Any bindings could be performed in many different threads.
This interface is not designed for implementing. New features may be added to this interface in next versions, and therefore do not create any implementations of this interface. Instance of this interface must be obtained only by calling
IProcessManager.getProcessBinder(String)
.- See Also:
ServiceBinder
,IProcessManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IProcessManager
completeBinding()
Just returns theprocess manager
on which thisprocess binder
is created.Collection<com._1c.g5.v8.dt.internal.pm.ServiceBinderImpl<?>>
getAllBoundServiceBinders()
Returns a collection with all theservice binders
those bindings are complete.Map<String,String>
getEnvironments()
Returns a map with all environments variables were set at the time of binding.ProcessBuilder.Redirect
getErrorsRedirect()
Returns the process's standard errors stream redirect, which is set byredirectError(Redirect)
.ProcessBuilder.Redirect
getInputRedirect()
Returns the process's standard input stream redirect, which is set byredirectInput(Redirect)
.String
getKey()
Returns a key of process for which thisProcessBinder
was created.long
getKillDelay()
Returns a delay after that corresponding process will be killed after all the instances created within that process were disposed.ProcessBuilder.Redirect
getOutputRedirect()
Returns the process's standard output stream redirect, which is set byredirectOutput(Redirect)
.<T> ServiceBinder<T>
getServiceBinder(Class<T> service)
Returns new or existingservice binder
for given service and corresponding process.long
getStartTimeout()
Returns a start timeout.boolean
mergeErrorsWithOutput()
Returns whether to merge process's standard errors stream with it's standard output stream.ProcessBinder
mergeErrorsWithOutput(boolean merge)
Merges errors and output streams of the process ifmerge
istrue
.ProcessBinder
redirectError(ProcessBuilder.Redirect destination)
Sets the process's standard errors destination.ProcessBinder
redirectInput(ProcessBuilder.Redirect source)
Sets the process's standard input source.ProcessBinder
redirectOutput(ProcessBuilder.Redirect destination)
Sets the process's standard output destination.ProcessBinder
setEnvironment(String variableName, String variableValue)
Sets the given environment variable with given value for corresponding process.ProcessBinder
setEnvironments(Map<String,String> environments)
Sets all the environment variables with names in given map keys with values of corresponding values in given map for corresponding values.ProcessBinder
setProcessKillDelay(long delay)
Sets a delay after that corresponding process will be killed after all the instances created within that process were disposed.ProcessBinder
setStartTimeOut(long timeout)
Sets the process starting timeout.
-
-
-
Method Detail
-
getKey
String getKey()
Returns a key of process for which this
ProcessBinder
was created.- Returns:
- a key of process for which this
ProcessBinder
was created
-
setEnvironment
ProcessBinder setEnvironment(String variableName, String variableValue)
Sets the given environment variable with given value for corresponding process.
If this method is called when the corresponding process is running, nothing will happen and a variable were just set will be actually set to the corresponding process when a process will be killed and started again.
- Parameters:
variableName
- given environment variable namevariableValue
- given environment variable value- Returns:
- this instance
-
setEnvironments
ProcessBinder setEnvironments(Map<String,String> environments)
Sets all the environment variables with names in given map keys with values of corresponding values in given map for corresponding values. Calling this method with another map will add additional variables containing in map and rewrite existing if they are placed in given map with different values, all the variables were set in previous calling those are not containing in given map would be saved as they are and set to separate process when it will start.
If this method is called when the corresponding process is running, nothing will happen and all the variables were just set will be actually set to the corresponding process when a process will be killed and started again.
- Parameters:
environments
- given map of environment variables (notnull
). Do not placenull
keys or values into the given map.- Returns:
- this instance
-
setProcessKillDelay
ProcessBinder setProcessKillDelay(long delay)
Sets a delay after that corresponding process will be killed after all the instances created within that process were disposed. Next
IProcessManager.getInstance(String, Class)
calling after killing will start the process again.If this method is called after the binding was completed,
IllegalStateException
will be thrown.- Parameters:
delay
- given delay- Returns:
- this instance
-
setStartTimeOut
ProcessBinder setStartTimeOut(long timeout)
Sets the process starting timeout. If process has not successfully started (for
IProcessManager.getInstance(String, Class)
) or exited within that timeout aRuntimeException
is thrown fromIProcessManager.getInstance(String, Class)
.- Parameters:
timeout
- given timeout (notnull
)- Returns:
- this instance
-
redirectInput
ProcessBinder redirectInput(ProcessBuilder.Redirect source)
Sets the process's standard input source. When the process will start, it will read from the given source.
If given source isProcessBuilder.Redirect.PIPE
, than process will read as a standard input the data written to output stream obtained byIProcessManager.getOutputStream(String)
method, called with key of the process.If given source is
ProcessBuilder.Redirect.INHERIT
, than process will use host process's standard input stream as it's standard input, andIProcessManager.getOutputStream(String)
will returnnull output stream
.If given source is
ProcessBuilder.Redirect.from(java.io.File)
, than the process will use that file as a standard input.IProcessManager.getOutputStream(String)
will also returnnull output stream
.- Parameters:
source
- given standard input source of the process- Returns:
- this instance
- Throws:
IllegalArgumentException
- if the redirect does not correspond to a valid source of data, that is, has typeWRITE
orAPPEND
- See Also:
IProcessManager.getOutputStream(String)
-
redirectOutput
ProcessBinder redirectOutput(ProcessBuilder.Redirect destination)
Sets the process's standard output destination. When the process will start, it will write it's standard output to the given destination.
If given destination isProcessBuilder.Redirect.PIPE
, than all the data, process has written to it's standard output could be read from input stream obtained byIProcessManager.getInputStream(String)
called with key of the process.If given destination is
ProcessBuilder.Redirect.INHERIT
, than process will use host process's standard output stream as it's standard output, andIProcessManager.getInputStream(String)
will returnnull input stream
.If given destination is
ProcessBuilder.Redirect.to(java.io.File)
orProcessBuilder.Redirect.appendTo(java.io.File)
, than the process will write it's standard output to the specified file.IProcessManager.getInputStream(String)
will also returnnull input stream
.- Parameters:
destination
- given destination of the standard output of the process- Returns:
- this instance
- Throws:
IllegalArgumentException
- if the redirect does not correspond to a valid source of data, that is, has typeREAD
- See Also:
IProcessManager.getInputStream(String)
-
redirectError
ProcessBinder redirectError(ProcessBuilder.Redirect destination)
Sets the process's standard errors destination. When the process will start, it will write it's errors to the given destination.
If given destination isProcessBuilder.Redirect.PIPE
, than all the errors, process has written to it's standard errors could be read from input stream obtained byIProcessManager.getErrorsStream(String)
called with key of the process.If given destination is
ProcessBuilder.Redirect.INHERIT
, than process will use host process's standard errors stream as it's standard errors, andIProcessManager.getErrorsStream(String)
will returnnull input stream
.If given destination is
ProcessBuilder.Redirect.to(java.io.File)
orProcessBuilder.Redirect.appendTo(java.io.File)
, than the process will write it's errors to the specified file.IProcessManager.getErrorsStream(String)
will also returnnull input stream
.If process's errors and output are merged (using
mergeErrorsWithOutput()
), than this method is ignored.- Parameters:
destination
- given destination of the standard errors of the process- Returns:
- this instance
- Throws:
IllegalArgumentException
- if the redirect does not correspond to a valid source of data, that is, has typeREAD
- See Also:
IProcessManager.getErrorsStream(String)
-
mergeErrorsWithOutput
ProcessBinder mergeErrorsWithOutput(boolean merge)
Merges errors and output streams of the process if
merge
istrue
. If those streams are merged, all the errors of the process could be read from it's standard output stream,redirectError(Redirect)
is ignored, andIProcessManager.getErrorsStream(String)
returnsnull input stream
.If
merge
isfalse
, than standard output and standard errors are two separate streams.By default, output and errors are separate (
merge
isfalse
).- Parameters:
merge
- specifies whether to merge standard output and errors stream of the process- Returns:
- this instance
- See Also:
redirectError(Redirect)
,IProcessManager.getOutputStream(String)
,IProcessManager.getErrorsStream(String)
-
getServiceBinder
<T> ServiceBinder<T> getServiceBinder(Class<T> service)
Returns new or existing
service binder
for given service and corresponding process. Each calling for the same service will return the same instance. Bind services and their implementations by returned binder. Do not perform any modifying on the returned binder after the binding on thisprocess binder
is complete.- Parameters:
service
- given service- Returns:
- new or existing
service binder
for given service and corresponding process - See Also:
ServiceBinder
-
completeBinding
IProcessManager completeBinding()
Just returns the
process manager
on which thisprocess binder
is created.- Returns:
- the
process manager
on which thisprocess binder
is created
-
getKillDelay
long getKillDelay()
Returns a delay after that corresponding process will be killed after all the instances created within that process were disposed.
- Returns:
- a delay after that corresponding process will be killed after all the instances created within that process were disposed
-
getStartTimeout
long getStartTimeout()
Returns a start timeout.
- Returns:
- start timeout
- See Also:
setStartTimeOut(long)
-
getEnvironments
Map<String,String> getEnvironments()
Returns a map with all environments variables were set at the time of binding. Must be called only when a binding is complete. If called when the binding is not complete,
IllegalStateException
is thrown.- Returns:
- a map with all environments variables were set at the time of binding (not
null
). The returned map is unmodifiable, any modifying operations are not performed. - Throws:
IllegalStateException
- if called when the binding is not complete
-
getInputRedirect
ProcessBuilder.Redirect getInputRedirect()
Returns the process's standard input stream redirect, which is set by
redirectInput(Redirect)
. By default, it isProcessBuilder.Redirect.PIPE
.- Returns:
- the process's standard input stream redirect set by
redirectInput(Redirect)
(notnull
)
-
getOutputRedirect
ProcessBuilder.Redirect getOutputRedirect()
Returns the process's standard output stream redirect, which is set by
redirectOutput(Redirect)
. By default, it isProcessBuilder.Redirect.PIPE
.- Returns:
- the process's standard output stream redirect, which is set by
redirectOutput(Redirect)
(notnull
)
-
getErrorsRedirect
ProcessBuilder.Redirect getErrorsRedirect()
Returns the process's standard errors stream redirect, which is set by
redirectError(Redirect)
. By default, it isProcessBuilder.Redirect.PIPE
.- Returns:
- the process's standard errors stream redirect, which is set by
redirectError(Redirect)
(notnull
)
-
mergeErrorsWithOutput
boolean mergeErrorsWithOutput()
Returns whether to merge process's standard errors stream with it's standard output stream. This value could be set by
mergeErrorsWithOutput(boolean)
. BY default, it isfalse
.- Returns:
- whether to merge process's standard errors stream with it's standard output stream
-
getAllBoundServiceBinders
Collection<com._1c.g5.v8.dt.internal.pm.ServiceBinderImpl<?>> getAllBoundServiceBinders()
Returns a collection with all theservice binders
those bindings are complete.- Returns:
- a collection with all the
service binders
those bindings are complete
-
-