Package app.l2nx.gs.adapter.core.modules
Class ModuleRegistry
java.lang.Object
app.l2nx.gs.adapter.core.modules.ModuleRegistry
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect(app.l2nx.gs.adapter.api.spi.ConnectContext ctx) Two-phase connect: invokeonConnect(ctx)on every module, then iterate again invokingstart()on every module that survived itsonConnect.List<app.l2nx.gs.adapter.api.kafka.ops.ModuleStatus>Snapshot ofModuleStatusper discovered module.voiddiscover()RunServiceLoader.load(Class)forAdapterModuleon adapter-core's own classloader (avoiding host-CL surprises on JVMs with non-trivial classloader hierarchies) and cache the result, sorted byAdapterModule.name().List<app.l2nx.gs.adapter.api.spi.AdapterModule>modules()Test seam / debugging accessor — returns the discovered modules in name-sorted order.voidshutdown()Reverse-discovery-order shutdown: invokestop()on every module, then iterate again invokingonDisconnect().
-
Constructor Details
-
ModuleRegistry
public ModuleRegistry()
-
-
Method Details
-
discover
public void discover()RunServiceLoader.load(Class)forAdapterModuleon adapter-core's own classloader (avoiding host-CL surprises on JVMs with non-trivial classloader hierarchies) and cache the result, sorted byAdapterModule.name(). -
connect
public void connect(app.l2nx.gs.adapter.api.spi.ConnectContext ctx) Two-phase connect: invokeonConnect(ctx)on every module, then iterate again invokingstart()on every module that survived itsonConnect.onConnectfailure transitions the module toFAILEDand skips itsstart(). -
shutdown
public void shutdown()Reverse-discovery-order shutdown: invokestop()on every module, then iterate again invokingonDisconnect(). Failures are logged but do not abort the shutdown sequence. -
currentStatuses
Snapshot ofModuleStatusper discovered module. For modules the registry has markedFAILED, returns{name, "FAILED", empty}without touching the module. Otherwise callsmodule.currentStatus()and falls back to{name, "FAILED", empty}if it throws or returnsnull. -
modules
Test seam / debugging accessor — returns the discovered modules in name-sorted order. Read-only view; mutation is unsupported.
-