Class StoreBackedBootstrapStateService

java.lang.Object
com.svenruppert.jsentinel.bootstrap.StoreBackedBootstrapStateService

@ExperimentalJSentinelApi public final class StoreBackedBootstrapStateService extends Object
Bootstrap-state service backed by a BootstrapStateStore.

Where the legacy BootstrapStateService derives "is the system uninitialized?" from AdministratorAccountStore.hasAnyAdministrator(), this variant treats the bootstrap fact as a first-class persistent record (with completion instant and tenant scope). The transition from "required" → "completed" is recorded by markCompleted() and is idempotent.

Bound to one TenantId + BootstrapMode at construction. Multi-tenant deployments instantiate one service per tenant.

  • Constructor Details

  • Method Details

    • bootstrapRequired

      public boolean bootstrapRequired()
      Returns:
      true when bootstrap is still required, i.e. the mode is not BootstrapMode.DISABLED and no completion has been recorded for the configured tenant
    • hasAdministrator

      public boolean hasAdministrator()
      Returns:
      true when a completion record exists for the configured tenant. Independent of BootstrapMode
    • state

      public BootstrapState state()
      Returns the persisted bootstrap state for the configured tenant. Absent records are reported as required.
      Returns:
      current state
    • markCompleted

      public BootstrapState markCompleted()
      Records the completion of the initial-admin bootstrap for the configured tenant at the current clock instant. Idempotent: already-completed states are kept as-is so the completion instant of the first transition is preserved.
      Returns:
      the persisted state after the call
    • reset

      public boolean reset()
      Removes any recorded completion for the configured tenant. Intended for tests and admin-tooling that need to "re-bootstrap" a tenant (e.g. recovery flows).
      Returns:
      true when a record was removed
    • mode

      public BootstrapMode mode()
      Returns:
      the BootstrapMode this service was configured with
    • tenant

      public TenantId tenant()
      Returns:
      the TenantId this service is bound to