Class MiddlewareRuntimeBuilder

java.lang.Object
org.j7m.middleware.runtime.MiddlewareRuntimeBuilder

public final class MiddlewareRuntimeBuilder extends Object
Builder for Phase 1 runtime instances.

The builder is not thread-safe. The runtime returned by build() owns the supplied registry and transport providers and closes them during runtime shutdown.

  • Constructor Details

    • MiddlewareRuntimeBuilder

      public MiddlewareRuntimeBuilder()
      Creates a builder with default codec, registry, and clock.
  • Method Details

    • runtimeId

      public MiddlewareRuntimeBuilder runtimeId(String runtimeId)
      Sets the runtime id.
      Parameters:
      runtimeId - runtime identifier
      Returns:
      this builder
    • registryContext

      public MiddlewareRuntimeBuilder registryContext(String registryContext)
      Sets the registry context.
      Parameters:
      registryContext - registry context
      Returns:
      this builder
    • registry

      public MiddlewareRuntimeBuilder registry(org.j7m.middleware.registry.api.RegistryClient registry)
      Sets the registry client.
      Parameters:
      registry - registry client
      Returns:
      this builder
    • codec

      public MiddlewareRuntimeBuilder codec(org.j7m.middleware.codec.api.ValueCodec codec)
      Sets the value codec.
      Parameters:
      codec - value codec
      Returns:
      this builder
    • clock

      public MiddlewareRuntimeBuilder clock(Clock clock)
      Sets the runtime clock.
      Parameters:
      clock - clock
      Returns:
      this builder
    • addTransport

      public MiddlewareRuntimeBuilder addTransport(org.j7m.middleware.transport.api.TransportProvider provider)
      Adds a transport provider.
      Parameters:
      provider - provider owned by the runtime
      Returns:
      this builder
    • security

      public MiddlewareRuntimeBuilder security(org.j7m.middleware.security.api.SecurityConfiguration security)
      Sets runtime security configuration.
      Parameters:
      security - security configuration
      Returns:
      this builder
    • nuggetAdmin

      public MiddlewareRuntimeBuilder nuggetAdmin(NuggetAdminRuntimeConfiguration configuration)
      Configures the runtime-owned nugget administration service.

      Supplying this configuration keeps nugget administration enabled and makes the returned runtime own the started service. The runtime closes the service during shutdown before closing transports and the registry. The configuration must include a valid PIN source unless it explicitly disables admin or explicitly enables unsafe developer mode.

      Parameters:
      configuration - nugget administration configuration
      Returns:
      this builder
      Throws:
      IllegalArgumentException - when configuration is null
    • disableNuggetAdmin

      public MiddlewareRuntimeBuilder disableNuggetAdmin()
      Explicitly disables runtime-owned nugget administration.

      This method is intended for tests, demos, and embedders that do not expose the Phase 7 operations plane. Production runtime construction is otherwise fail-closed: nugget administration is enabled by default and a missing PIN source rejects startup.

      Returns:
      this builder
    • build

      public org.j7m.middleware.core.DefaultMiddlewareRuntime build()
      Builds and starts the runtime.

      When no transport providers were explicitly supplied through addTransport(TransportProvider), the builder loads TransportProvider implementations through ServiceLoader. Provider loading is bounded, sorted by provider class name, and fails fast when no provider is available. Explicitly supplied providers always take precedence and do not trigger service loading.

      Returns:
      runtime