Class ModuleRegistry

java.lang.Object
app.l2nx.gs.adapter.core.modules.ModuleRegistry

public final class ModuleRegistry extends Object
Holds the discovered Tier-1 modules and orchestrates their lifecycle. One-shot discovery at adapter bootstrap; cached for the JVM lifetime.

Per-module lifecycle health is tracked separately from the module's own self-reported status: when a connect-time hook (onConnect / start) throws, the registry marks the module FAILED and short-circuits its future currentStatus() reports to {name, "FAILED", empty Stats}. Modules that transition themselves into DEGRADED (e.g. db-sync's smoke-check failure path) report it via their own currentStatus() override.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    connect(app.l2nx.gs.adapter.api.spi.ConnectContext ctx)
    Two-phase connect: invoke onConnect(ctx) on every module, then iterate again invoking start() on every module that survived its onConnect.
    List<app.l2nx.gs.adapter.api.kafka.ops.ModuleStatus>
    Snapshot of ModuleStatus per discovered module.
    void
    Run ServiceLoader.load(Class) for AdapterModule on adapter-core's own classloader (avoiding host-CL surprises on JVMs with non-trivial classloader hierarchies) and cache the result, sorted by AdapterModule.name().
    List<app.l2nx.gs.adapter.api.spi.AdapterModule>
    Test seam / debugging accessor — returns the discovered modules in name-sorted order.
    void
    Reverse-discovery-order shutdown: invoke stop() on every module, then iterate again invoking onDisconnect().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ModuleRegistry

      public ModuleRegistry()
  • Method Details

    • discover

      public void discover()
      Run ServiceLoader.load(Class) for AdapterModule on adapter-core's own classloader (avoiding host-CL surprises on JVMs with non-trivial classloader hierarchies) and cache the result, sorted by AdapterModule.name().
    • connect

      public void connect(app.l2nx.gs.adapter.api.spi.ConnectContext ctx)
      Two-phase connect: invoke onConnect(ctx) on every module, then iterate again invoking start() on every module that survived its onConnect. onConnect failure transitions the module to FAILED and skips its start().
    • shutdown

      public void shutdown()
      Reverse-discovery-order shutdown: invoke stop() on every module, then iterate again invoking onDisconnect(). Failures are logged but do not abort the shutdown sequence.
    • currentStatuses

      public List<app.l2nx.gs.adapter.api.kafka.ops.ModuleStatus> currentStatuses()
      Snapshot of ModuleStatus per discovered module. For modules the registry has marked FAILED, returns {name, "FAILED", empty} without touching the module. Otherwise calls module.currentStatus() and falls back to {name, "FAILED", empty} if it throws or returns null.
    • modules

      public List<app.l2nx.gs.adapter.api.spi.AdapterModule> modules()
      Test seam / debugging accessor — returns the discovered modules in name-sorted order. Read-only view; mutation is unsupported.