Interface Service.Builder

  • Enclosing interface:
    Service

    public static interface Service.Builder
    A builder for a new service.
    • Method Detail

      • withModule

        Service.Builder withModule​(ApolloModule module)
        Registers the specified module as loadable by this service. This does not guarantee that the module is actually loaded; the modules themselves will inspect the configuration and actually determine if they should be loaded.
        Parameters:
        module - The module to register.
        Returns:
        This builder.
      • usingModuleDiscovery

        Service.Builder usingModuleDiscovery​(boolean moduleDiscovery)
        Enables or disables module discovery, which will use SPI to discover all available modules on the classpath. By default, module discovery is disabled.
        Parameters:
        moduleDiscovery - true if module discovery should be used, false otherwise.
        Returns:
        This builder.
      • withShutdownInterrupt

        Service.Builder withShutdownInterrupt​(boolean enabled)
        Enables/disables whether the thread calling Service.start(String...) will be interrupted when the application is requested to shut down. The default is to not interrupt the thread.
        Parameters:
        enabled - true if Thread.interrupt() should be called on the thread that called Service.start(String...) when the service is signalled to shut down; false if nothing should happen.
        Returns:
        This builder.
      • withCliHelp

        Service.Builder withCliHelp​(boolean enabled)
        Enables/disables whether Apollo should handle the --help/-h flags and display command-line help. The default is to handle the flags.
        Parameters:
        enabled - true if Apollo should intercept --help/-h, false otherwise.
        Returns:
        This builder.
      • withEnvVarPrefix

        Service.Builder withEnvVarPrefix​(String prefix)
        Sets the prefix that is used to convert environment variables into configuration keys. By default, the prefix is "APOLLO", which means that an environment variable like "APOLLO_DOMAIN_NAME" is translated into the config key "domain.name".
        Parameters:
        prefix - The environment variable prefix to use.
        Returns:
        This builder.
      • withWatchdogTimeout

        Service.Builder withWatchdogTimeout​(long timeout,
                                            TimeUnit unit)
        Sets the timeout for how long Apollo will wait for the service to clean itself up upon shutdown. Apollo will keep a reaper thread running as long as there are shutdown operations pending. After the timeout has elapsed, the reaper thread will die, but other threads might still linger.
        Parameters:
        timeout - The timeout value.
        unit - The time unit of the timeout value.
        Returns:
        This builder.
      • withRuntime

        Service.Builder withRuntime​(Runtime runtime)
        The Java runtime to use when constructing service instances. This is only respected by Apollo itself; the service instance(s) configured by Apollo might decide to use the global runtime. The default is to use the global JVM runtime.
        Parameters:
        runtime - The Java runtime to use when constructing service instances.
        Returns:
        This builder.
      • build

        Service build()
        Creates a new service based off of this builder.
        Returns:
        The newly created service.