Class ExpectationStoreFactory

java.lang.Object
org.mockserver.mock.ExpectationStoreFactory

public final class ExpectationStoreFactory extends Object
Pluggable factory for the expectation store (RequestMatchers).

G10 phase 1 — clustered-state seam. HttpState obtains its RequestMatchers through this factory rather than constructing it directly, so an optional clustered backend (phase 2, an embedded Infinispan data grid sharing expectations across MockServer instances) can register a ExpectationStoreFactory.Factory that returns a clustering-aware RequestMatchers subclass without mockserver-core depending on the data grid.

Zero behaviour change in phase 1: the default factory is the standard RequestMatchers constructor, so when no override is registered the behaviour is identical to constructing it inline.

Thread-safety: the factory reference is volatile; register/reset are expected at startup (mirrors the SPI-registry pattern used by AsyncApiControlPlaneRegistry, DriftStore, WasmStore).

Phase 2 (deferred): a clustered backend additionally requires the expectation storage (the CircularPriorityQueue inside RequestMatchers) to be overridable so a distributed map can back it; that storage abstraction is out of scope for this construction-seam phase.

  • Method Details

    • register

      public static void register(ExpectationStoreFactory.Factory customFactory)
      Register a custom factory (e.g. a clustered backend). Passing null resets to the default in-memory factory.
    • resetToDefault

      public static void resetToDefault()
      Reset to the default in-memory factory (primarily for tests).
    • isCustomFactoryRegistered

      public static boolean isCustomFactoryRegistered()
      Returns:
      true if a non-default factory is registered.
    • create

      public static RequestMatchers create(Configuration configuration, MockServerLogger mockServerLogger, Scheduler scheduler, WebSocketClientRegistry webSocketClientRegistry)
      Create the expectation store via the registered factory (default: the standard in-memory RequestMatchers).