Class ProcessConfiguration.Builder
- Enclosing class:
ProcessConfiguration
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the process configuration based on the configuration of this builder.environment(@NonNull ServiceEnvironmentType environment) Sets the name of the environment services using the created process configuration should use.environment(@NonNull String environment) Sets the name of the environment services using the created process configuration should use.environmentVariables(@NonNull Map<String, String> environmentVariables) Sets the environment variables which should set in the environment the process runs in.jvmOptions(@NonNull Collection<String> jvmOptions) Sets the jvm options which should get applied to the service command line.maxHeapMemorySize(@Range(from=50L,to=2147483647L) int maxHeapMemorySize) Sets the maximum amount of heap memory (in mb) the service is allowed to use.Modifies the environment variables which should get appended to the environment of the process.modifyJvmOptions(@NonNull Consumer<Collection<String>> modifier) Modifies the jvm options of this builder.modifyProcessParameters(@NonNull Consumer<Collection<String>> modifier) Modifies the process parameters which should get appended to the command line.processParameters(@NonNull Collection<String> processParameters) Sets the process parameters which should get appended to the command line.
-
Field Details
-
environment
-
maxHeapMemorySize
protected int maxHeapMemorySize -
jvmOptions
-
processParameters
-
environmentVariables
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
maxHeapMemorySize
@NonNull public @NonNull ProcessConfiguration.Builder maxHeapMemorySize(@Range(from=50L,to=2147483647L) int maxHeapMemorySize) Sets the maximum amount of heap memory (in mb) the service is allowed to use. The given heap memory size must be at least 50 MB (less heap memory makes no sense when running a service).- Parameters:
maxHeapMemorySize- the maximum heap memory a service is allowed to use.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
IllegalArgumentException- if the given memory size is less than 50 mb.
-
environment
@NonNull public @NonNull ProcessConfiguration.Builder environment(@NonNull @NonNull String environment) Sets the name of the environment services using the created process configuration should use. Based on the environments the configuration and application files are selected and modified.- Parameters:
environment- the name of the environment the configuration should use.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given environment name is null.
-
environment
@NonNull public @NonNull ProcessConfiguration.Builder environment(@NonNull @NonNull ServiceEnvironmentType environment) Sets the name of the environment services using the created process configuration should use. Based on the environments the configuration and application files are selected and modified.- Parameters:
environment- the environment the configuration should use.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given environment is null.
-
jvmOptions
@NonNull public @NonNull ProcessConfiguration.Builder jvmOptions(@NonNull @NonNull Collection<String> jvmOptions) Sets the jvm options which should get applied to the service command line. JVM options are there to configure the behaviour of the jvm, for example the garbage collector.The XmX and XmS options will always get appended based on the configured maximum heap memory size.
This method will override all previously added jvm options. Furthermore, the given collection will be copied into this builder, meaning that changes to it will not reflect into the builder after the method call.
- Parameters:
jvmOptions- the jvm options of the configuration.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given options collection is null.
-
modifyJvmOptions
@NonNull public @NonNull ProcessConfiguration.Builder modifyJvmOptions(@NonNull @NonNull Consumer<Collection<String>> modifier) Modifies the jvm options of this builder. JVM options are there to configure the behaviour of the jvm, for example the garbage collector.The XmX and XmS options will always get appended based on the configured maximum heap memory size.
Duplicate options will be omitted by the underlying collection. HOWEVER, adding the same option twice with a changed value to it will most likely result in the jvm to crash, beware!
- Parameters:
modifier- the modifier to be applied to the already added jvm options of this builder.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given modifier is null.
-
processParameters
@NonNull public @NonNull ProcessConfiguration.Builder processParameters(@NonNull @NonNull Collection<String> processParameters) Sets the process parameters which should get appended to the command line. Process parameters are there to configure the application, for example setting an option like --online-mode=true.This method will override all previously added process parameters options. Furthermore, the given collection will be copied into this builder, meaning that changes to it will not reflect into the builder after the method call.
- Parameters:
processParameters- the process parameters of the configuration.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given parameters' collection is null.
-
modifyProcessParameters
@NonNull public @NonNull ProcessConfiguration.Builder modifyProcessParameters(@NonNull @NonNull Consumer<Collection<String>> modifier) Modifies the process parameters which should get appended to the command line. Process parameters are there to configure the application, for example setting an option like --online-mode=true.Duplicate parameters will get omitted by the underlying collection.
- Parameters:
modifier- the modifier to be applied to the already added process parameters of this builder.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given modifier is null.
-
environmentVariables
@NonNull public @NonNull ProcessConfiguration.Builder environmentVariables(@NonNull @NonNull Map<String, String> environmentVariables) Sets the environment variables which should set in the environment the process runs in.This method will override all previously added environment variables options. Furthermore, the given map will be copied into this builder, meaning that changes to it will not reflect into the builder after the method call.
- Parameters:
environmentVariables- the environment variables to apply to processes created based on this configuration.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given environment variables map is null.
-
modifyEnvironmentVariables
@NonNull public @NonNull ProcessConfiguration.Builder modifyEnvironmentVariables(@NonNull @NonNull Consumer<Map<String, String>> modifier) Modifies the environment variables which should get appended to the environment of the process.- Parameters:
modifier- the modifier to be applied to the already added environment variables of this builder.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the modifier is null.
-
build
Builds the process configuration based on the configuration of this builder.- Returns:
- the created process configuration.
- Throws:
NullPointerException- if no environment is specified for the configuration.
-