Package org.moeaframework.problem
Class ExternalProblem.Builder
java.lang.Object
org.moeaframework.problem.ExternalProblem.Builder
- Enclosing class:
- ExternalProblem
Builder for defining the process or connection to the external problem.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ExternalProblem.Instance
build()
Returns the constructed instance.protected ExternalProblem.Builder
copy()
Creates a copy of this builder.redirectErrorTo
(OutputStream errorStream) Redirects the process' standard error to the given stream.withCommand
(String... command) Configures this builder to start a process using the given command and optional arguments.Enables writing debugging info to standard output.withDebugging
(OutputStream debug) Enables writing debugging info to the given output stream.withIOStreams
(InputStream inputStream, OutputStream outputStream) Configures this builder to communicate using the given input and output streams.withRetries
(int retryAttempts, Duration retryDelay) Sets the retry options when trying to connect to the external process with sockets.withShutdownTimeout
(Duration shutdownTimeout) Overrides the timeout given to allow the process to cleanly terminate before sending a kill signal.withSocket
(int port) Configures this builder to communicate with a local process using the given port.withSocket
(String hostname, int port) Configures this builder to communicate with the specified hostname and port.withSocket
(InetAddress address, int port) Configures this builder to communicate with the specified address and port.withWorkingDirectory
(File directory) Sets the working directory where the process is started.withWorkingDirectory
(Path path) Sets the working directory where the process is started.
-
Constructor Details
-
Builder
public Builder()Constructs a new builder.
-
-
Method Details
-
withCommand
Configures this builder to start a process using the given command and optional arguments.- Parameters:
command
- the command and arguments- Returns:
- a reference to this builder for chaining together calls
-
withWorkingDirectory
Sets the working directory where the process is started.- Parameters:
directory
- the working directory- Returns:
- a reference to this builder for chaining together calls
-
withWorkingDirectory
Sets the working directory where the process is started.- Parameters:
path
- the working directory- Returns:
- a reference to this builder for chaining together calls
-
withSocket
Configures this builder to communicate with a local process using the given port.- Parameters:
port
- the port- Returns:
- a reference to this builder for chaining together calls
-
withSocket
Configures this builder to communicate with the specified address and port.- Parameters:
address
- the addressport
- the port- Returns:
- a reference to this builder for chaining together calls
-
withSocket
Configures this builder to communicate with the specified hostname and port.- Parameters:
hostname
- the host nameport
- the port- Returns:
- a reference to this builder for chaining together calls
-
withIOStreams
Configures this builder to communicate using the given input and output streams. This is primarily intended for internal use.- Parameters:
inputStream
- the input streamoutputStream
- the output stream- Returns:
- a reference to this builder for chaining together calls
-
withDebugging
Enables writing debugging info to standard output.- Returns:
- a reference to this builder for chaining together calls
-
withDebugging
Enables writing debugging info to the given output stream. The given stream is not closed when the problem is closed.- Parameters:
debug
- the output stream- Returns:
- a reference to this builder for chaining together calls
-
redirectErrorTo
Redirects the process' standard error to the given stream. The given stream is not closed when the problem is closed.- Parameters:
errorStream
- the stream where error messages are written- Returns:
- a reference to this builder for chaining together calls
-
withRetries
Sets the retry options when trying to connect to the external process with sockets.- Parameters:
retryAttempts
- the number of retry attempts (a value<= 0
will fail after the first attempt)retryDelay
- the fixed delay between retries- Returns:
- a reference to this builder for chaining together calls
-
withShutdownTimeout
Overrides the timeout given to allow the process to cleanly terminate before sending a kill signal.- Parameters:
shutdownTimeout
- the shutdown timeout- Returns:
- a reference to this builder for chaining together calls
-
copy
Creates a copy of this builder. Note that streams are shared between the two instances.- Returns:
- the copy
-
build
Returns the constructed instance.- Returns:
- the external problem instance
-