Class ServiceConfiguration.Builder

  • Enclosing class:
    ServiceConfiguration

    public static class ServiceConfiguration.Builder
    extends java.lang.Object
    Builder for the creation of new services. All required parameters are: You can create a new service with this example:

    ServiceConfiguration .builder() .task("Lobby") .environment(ServiceEnvironmentType.MINECRAFT_SERVER) .maxHeapMemory(512) .build() .createNewService();

    this will return the newly created ServiceInfoSnapshot or null if the service couldn't be created.

    • Method Detail

      • task

        @NotNull
        public @NotNull ServiceConfiguration.Builder task​(@NotNull
                                                          @NotNull ServiceTask task)
        Applies every option of the given ServiceTask object except for the Properties. This will override every previously set option of this builder.
      • task

        @NotNull
        public @NotNull ServiceConfiguration.Builder task​(@NotNull
                                                          @NotNull java.lang.String task)
        The task for the new service. No permanent task with that name has to exist. This will NOT use any options of the given task, to do that use task(ServiceTask).
      • taskId

        @NotNull
        public @NotNull ServiceConfiguration.Builder taskId​(int taskId)
        The task id for the new service (For example Lobby-1 would have the task id 1).
      • uniqueId

        @NotNull
        public @NotNull ServiceConfiguration.Builder uniqueId​(@NotNull
                                                              @NotNull java.util.UUID uniqueId)
        The uniqueId for the new service.
      • javaCommand

        @NotNull
        public @NotNull ServiceConfiguration.Builder javaCommand​(@Nullable
                                                                 @Nullable java.lang.String javaCommand)
        the java command to start the service with if this is null the default value from the config.json will be used
      • allowedNodes

        @NotNull
        public @NotNull ServiceConfiguration.Builder allowedNodes​(@NotNull
                                                                  @NotNull java.util.Collection<java.lang.String> allowedNodes)
        A list of all allowed nodes. CloudNet will choose the node with the most free resources. If a node is provided using node(String), this option will be ignored.
      • allowedNodes

        @NotNull
        public @NotNull ServiceConfiguration.Builder allowedNodes​(@NotNull
                                                                  @NotNull java.lang.String @NotNull ... allowedNodes)
        A list of all allowed nodes. CloudNet will choose the node with the most free resources. If a node is provided using node(String), this option will be ignored.
      • addAllowedNodes

        @NotNull
        public @NotNull ServiceConfiguration.Builder addAllowedNodes​(@NotNull
                                                                     @NotNull java.util.Collection<java.lang.String> allowedNodes)
        A list of all allowed nodes. CloudNet will choose the node with the most free resources. If a node is provided using node(String), this option will be ignored.
      • addAllowedNodes

        @NotNull
        public @NotNull ServiceConfiguration.Builder addAllowedNodes​(@NotNull
                                                                     @NotNull java.lang.String @NotNull ... allowedNodes)
        A list of all allowed nodes. CloudNet will choose the node with the most free resources. If a node is provided using node(String), this option will be ignored.
      • runtime

        @NotNull
        public @NotNull ServiceConfiguration.Builder runtime​(@NotNull
                                                             @NotNull java.lang.String runtime)
        The runtime of the service. If none is provided, the default "jvm" is used. By default, CloudNet only provides the "jvm" runtime, you can add your own with custom modules.
      • autoDeleteOnStop

        @NotNull
        public @NotNull ServiceConfiguration.Builder autoDeleteOnStop​(boolean autoDeleteOnStop)
        Whether this service should be deleted on stop (doesn't affect files of a static service) or the life cycle should be changed to ServiceLifeCycle.PREPARED.
      • staticService

        @NotNull
        public @NotNull ServiceConfiguration.Builder staticService​(boolean staticService)
        Whether the files should be deleted or saved on deletion of the service.
      • groups

        @NotNull
        public @NotNull ServiceConfiguration.Builder groups​(@NotNull
                                                            @NotNull java.lang.String @NotNull ... groups)
        The groups for the new service. CloudNet will apply every template, deployment and inclusion of the given groups to the new service.
      • groups

        @NotNull
        public @NotNull ServiceConfiguration.Builder groups​(@NotNull
                                                            @NotNull java.util.Collection<java.lang.String> groups)
        The groups for the new service. CloudNet will apply every template, deployment and inclusion of the given groups to the new service.
      • addGroups

        @NotNull
        public @NotNull ServiceConfiguration.Builder addGroups​(@NotNull
                                                               @NotNull java.lang.String @NotNull ... groups)
        The groups for the new service. CloudNet will apply every template, deployment and inclusion of the given groups to the new service.
      • addGroups

        @NotNull
        public @NotNull ServiceConfiguration.Builder addGroups​(@NotNull
                                                               @NotNull java.util.Collection<java.lang.String> groups)
        The groups for the new service. CloudNet will apply every template, deployment and inclusion of the given groups to the new service.
      • deleteFilesAfterStop

        @NotNull
        public @NotNull ServiceConfiguration.Builder deleteFilesAfterStop​(@NotNull
                                                                          @NotNull java.lang.String @NotNull ... deletedFilesAfterStop)
        The files that should be deleted after the service has been stopped.
      • deleteFilesAfterStop

        @NotNull
        public @NotNull ServiceConfiguration.Builder deleteFilesAfterStop​(@NotNull
                                                                          @NotNull java.util.Collection<java.lang.String> deletedFilesAfterStop)
        The files that should be deleted after the service has been stopped.
      • addDeletedFilesAfterStop

        @NotNull
        public @NotNull ServiceConfiguration.Builder addDeletedFilesAfterStop​(@NotNull
                                                                              @NotNull java.lang.String @NotNull ... deletedFilesAfterStop)
        The files that should be deleted after the service has been stopped.
      • addDeletedFilesAfterStop

        @NotNull
        public @NotNull ServiceConfiguration.Builder addDeletedFilesAfterStop​(@NotNull
                                                                              @NotNull java.util.Collection<java.lang.String> deletedFilesAfterStop)
        The files that should be deleted after the service has been stopped.
      • maxHeapMemory

        @NotNull
        public @NotNull ServiceConfiguration.Builder maxHeapMemory​(int maxHeapMemory)
        The max heap memory for the new service.
      • jvmOptions

        @NotNull
        public @NotNull ServiceConfiguration.Builder jvmOptions​(@NotNull
                                                                @NotNull java.util.Collection<java.lang.String> jvmOptions)
        The jvm options for the new service. They will be added directly before the "-Xmx" parameter in the startup command.
      • jvmOptions

        @NotNull
        public @NotNull ServiceConfiguration.Builder jvmOptions​(@NotNull
                                                                @NotNull java.lang.String @NotNull ... jvmOptions)
        The jvm options for the new service. They will be added directly before the "-Xmx" parameter in the startup command.
      • addJvmOptions

        @NotNull
        public @NotNull ServiceConfiguration.Builder addJvmOptions​(@NotNull
                                                                   @NotNull java.lang.String @NotNull ... jvmOptions)
        The jvm options for the new service. They will be added directly before the "-Xmx" parameter in the startup command.
      • addJvmOptions

        @NotNull
        public @NotNull ServiceConfiguration.Builder addJvmOptions​(@NotNull
                                                                   @NotNull java.util.Collection<java.lang.String> jvmOptions)
        The jvm options for the new service. They will be added directly before the "-Xmx" parameter in the startup command.
      • processParameters

        @NotNull
        public @NotNull ServiceConfiguration.Builder processParameters​(@NotNull
                                                                       @NotNull java.util.Collection<java.lang.String> jvmOptions)
        The process parameters for the new service. This will be the last parameters that will be added to the command.
      • addProcessParameters

        @NotNull
        public @NotNull ServiceConfiguration.Builder addProcessParameters​(@NotNull
                                                                          @NotNull java.lang.String @NotNull ... jvmOptions)
        The process parameters for the new service. This will be the last parameters that will be added to the command.
      • addProcessParameters

        @NotNull
        public @NotNull ServiceConfiguration.Builder addProcessParameters​(@NotNull
                                                                          @NotNull java.util.Collection<java.lang.String> jvmOptions)
        The process parameters for the new service. This will be the last parameters that will be added to the command.
      • startPort

        @NotNull
        public @NotNull ServiceConfiguration.Builder startPort​(int startPort)
        The start port for the new service. CloudNet will test whether the port is used or not, it will count up 1 while the port is used.
      • properties

        @NotNull
        public @NotNull ServiceConfiguration.Builder properties​(@NotNull
                                                                @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument properties)
        The default properties of the new service. CloudNet itself completely ignores them, but they can be useful if you want to transport data from the component that has created the service to the new service.