Class ServiceConfigurationBase.Builder<T extends ServiceConfigurationBase, B extends ServiceConfigurationBase.Builder<T,B>>
- Type Parameters:
T- the type which gets build by the builder.B- the builder instance from the type which gets build, for proper chaining purposes.
- All Implemented Interfaces:
DefaultedDocPropertyHolder,DefaultedDocPropertyHolder.Mutable<B>,DefaultedDocPropertyHolder.Mutable.WithDirectModifier<B>,DocPropertyHolder,DocPropertyHolder.Mutable<B>
- Direct Known Subclasses:
GroupConfiguration.Builder,ServiceConfiguration.Builder,ServiceTask.Builder
- Enclosing class:
ServiceConfigurationBase
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder
DefaultedDocPropertyHolder.Mutable<S extends DocPropertyHolder.Mutable<S>>Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder.Mutable
DefaultedDocPropertyHolder.Mutable.WithDirectModifier<S extends DocPropertyHolder.Mutable<S>>Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.document.property.DocPropertyHolder
DocPropertyHolder.Mutable<S extends DocPropertyHolder.Mutable<S>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set<ServiceDeployment> protected Set<ServiceRemoteInclusion> protected Document.Mutableprotected Set<ServiceTemplate> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Tbuild()Builds an instance of the service configuration type this builder is targeting.deployments(@NonNull Collection<ServiceDeployment> deployments) Sets the deployments to execute when a service based on the configuration gets stopped or when explicitly requested by calling the associated method on the service provider.environmentVariables(@NonNull Map<String, String> environmentVariables) Sets the environment variables which should set in the environment the process runs in.inclusions(@NonNull Collection<ServiceRemoteInclusion> inclusions) Sets all inclusions which should get loaded onto a service created based on the service configuration before it starts.jvmOptions(@NonNull Collection<String> jvmOptions) Sets the jvm options which should get applied to the service command line.modifyDeployments(@NonNull Consumer<Collection<ServiceDeployment>> modifier) Modifies the deployments to execute when a service based on the configuration gets stopped or when explicitly requested by calling the associated method on the service provider.Modifies the environment variables which should get appended to the environment of the process.modifyInclusions(@NonNull Consumer<Collection<ServiceRemoteInclusion>> modifier) Modifies the inclusions which should get loaded onto a service created based on the service configuration before it starts.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.modifyTemplates(@NonNull Consumer<Collection<ServiceTemplate>> modifier) Modifies the templates which should get loaded onto a service before it starts.processParameters(@NonNull Collection<String> processParameters) Sets the process parameters which should get appended to the command line.properties(@NonNull Document properties) The properties to apply to the underlying created configuration.Get the underlying document that all read and write operations are delegated to.protected abstract Bself()Get the current instance of the builder, this removes the need for unchecked generics which are annoying.templates(@NonNull Collection<ServiceTemplate> templates) Sets all templates which should get loaded onto a service before it starts.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder
propertyAbsent, propertyPresent, readProperty, readPropertyOrDefault, readPropertyOrGet, readPropertyOrThrow, readPropertyOrThrowMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder.Mutable
removeProperty, writeProperty, writePropertyIfAbsent, writePropertyIfAbsent, writePropertyIfPresent, writePropertyIfPresentMethods inherited from interface eu.cloudnetservice.driver.document.property.DefaultedDocPropertyHolder.Mutable.WithDirectModifier
modifyAndSetProperties, modifyProperties
-
Field Details
-
jvmOptions
-
processParameters
-
templates
-
deployments
-
includes
-
environmentVariables
-
properties
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
properties
The properties to apply to the underlying created configuration.Note: some plugins might override certain properties, for example the bridge plugin overrides the online count property if set. There is no way to prevent this, as it ensures that CloudNet can run correctly. Just make sure that your property names differ from them CloudNet uses by default.
- Parameters:
properties- the properties to apply by default to all services.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given properties document is null.
-
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
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 this method directly. 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 options collection is null.
-
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
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 this method directly.
- 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 parameters' collection is null.
-
templates
Sets all templates which should get loaded onto a service before it starts. The given collection sorting is ignored and the templates will get re-sorted based on their priority. Templates will override existing files from any source if they are present in them, make sure to use an appropriate order for them.This method will override all previously added templates. The given collection will be copied into this builder, meaning that changes made to the collection after the method call will not reflect into the builder and vice-versa.
- Parameters:
templates- the templates to include onto all services before starting them.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given template collection is null.
-
modifyTemplates
Modifies the templates which should get loaded onto a service before it starts. The given collection sorting is ignored and the templates will get re-sorted based on their priority. Templates will override existing files from any source if they are present in them, make sure to use an appropriate order for them.- Parameters:
modifier- the modifier to be applied to the already added templates of this builder.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given template collection is null.
-
deployments
Sets the deployments to execute when a service based on the configuration gets stopped or when explicitly requested by calling the associated method on the service provider.This method will override all previously added deployments. The given collection will be copied into this builder, meaning that changes made to the collection after the method call will not reflect into the builder and vice-versa.
- Parameters:
deployments- the deployments to add to every service created based on the configuration.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given deployment collection is null.
-
modifyDeployments
@NonNull public B modifyDeployments(@NonNull @NonNull Consumer<Collection<ServiceDeployment>> modifier) Modifies the deployments to execute when a service based on the configuration gets stopped or when explicitly requested by calling the associated method on the service provider.- Parameters:
modifier- the modifier to be applied to the already added deployments of this builder.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given deployment collection is null.
-
inclusions
Sets all inclusions which should get loaded onto a service created based on the service configuration before it starts. Inclusions get cached based on their download url. If you need a clean copy of your inclusion you should change the download url of it. If the node is unable to download an inclusion based on the given url it will be ignored and a warning gets printed into the console.This method overrides all previously added inclusions. The given collection will be copied into this builder, meaning that changes made to the collection after the method call will not reflect into the builder and vice-versa.
- Parameters:
inclusions- the inclusions to include on all services created based on the configuration.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given inclusion collection is null.
-
modifyInclusions
@NonNull public B modifyInclusions(@NonNull @NonNull Consumer<Collection<ServiceRemoteInclusion>> modifier) Modifies the inclusions which should get loaded onto a service created based on the service configuration before it starts. Inclusions get cached based on their download url. If you need a clean copy of your inclusion you should change the download url of it. If the node is unable to download an inclusion based on the given url it will be ignored and a warning gets printed into the console.- Parameters:
modifier- the modifier to be applied to the already added inclusions of this builder.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given inclusion collection is null.
-
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 B 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.
-
propertyHolder
Get the underlying document that all read and write operations are delegated to.- Specified by:
propertyHolderin interfaceDocPropertyHolder- Specified by:
propertyHolderin interfaceDocPropertyHolder.Mutable<T extends ServiceConfigurationBase>- Returns:
- the underlying document.
-
self
-
build
-