Class StateBackendFactory
StateBackend.
Mirrors the ExpectationStoreFactory pattern:
a volatile-registry with a default in-memory implementation. An optional
clustered backend (phase 2b, in a separate module) can register a
StateBackendFactory.Factory that returns a clustering-aware StateBackend
without mockserver-core depending on the data grid.
Auto-discovery: when stateBackend=infinispan is configured and
no custom factory has been registered, the factory attempts to load
InfinispanStateBackendRegistrar via reflection from the classpath.
If the class is found, its register() method is called, which
registers the Infinispan factory. This keeps mockserver-core free of any
compile-time dependency on the Infinispan module.
Cloud blob store discovery: when blobStoreType is set to a cloud
backend name (s3, gcs, azure) and no matching BlobStoreFactory
has been registered, the factory attempts to load the corresponding
registrar class via reflection. Each cloud module provides a registrar
that calls registerBlobStoreFactory(String, BlobStoreFactory).
Thread-safety: the factory reference is volatile; register/reset
are expected at startup. The blob store factory registry is a
ConcurrentHashMap.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCreates aStateBackendfor anHttpStateinstance. -
Method Summary
Modifier and TypeMethodDescriptionstatic StateBackendcreate(Configuration configuration) Create the state backend via the registered factory.static booleanisBlobStoreFactoryRegistered(String typeName) static booleanstatic voidregister(StateBackendFactory.Factory customFactory) Register a custom factory (e.g. a clustered backend).static voidregisterBlobStoreFactory(String typeName, BlobStoreFactory blobStoreFactory) Register a pluggableBlobStoreFactoryfor a given type name.static voidReset to the default in-memory factory (primarily for tests).
-
Method Details
-
register
Register a custom factory (e.g. a clustered backend). Passingnullresets to the default in-memory factory. -
registerBlobStoreFactory
Register a pluggableBlobStoreFactoryfor a given type name. Cloud blob store modules call this from their registrar classes to make themselves available whenblobStoreTypeis configured.- Parameters:
typeName- the blob store type name (e.g. "s3", "gcs", "azure")blobStoreFactory- the factory that creates the blob store
-
resetToDefault
public static void resetToDefault()Reset to the default in-memory factory (primarily for tests). -
isCustomFactoryRegistered
public static boolean isCustomFactoryRegistered()- Returns:
trueif a non-default factory is registered.
-
isBlobStoreFactoryRegistered
- Returns:
trueif a blob store factory is registered for the given type name.
-
create
Create the state backend via the registered factory. IfstateBackend=infinispanis configured and no custom factory has been registered yet, attempts auto-discovery of the Infinispan module from the classpath via reflection.
-