DidMethodRegistry
In-memory registry for managing DID method implementations.
Methods can be registered manually or automatically discovered via SPI (Service Provider Interface). When auto-registration is enabled, all DidMethodProvider implementations on the classpath are scanned and their methods are registered.
Thread Safety: All operations are thread-safe using ConcurrentHashMap for concurrent access without explicit synchronization. All operations are atomic and safe for concurrent use.
Performance:
O(1) lookup time for method retrieval
O(n) for getAllMethodNames() and getAllMethods() where n is the number of methods
Example Usage:
// Manual registration
val registry = DidMethodRegistry()
registry.register(KeyDidMethod(kms))
// Auto-register from SPI providers
val auto = DidMethodRegistry.autoRegister(kms)
val registry = auto.registry
// Use operators
val method = registry["key"]
if ("key" in registry) {
// Method is registered
}
val result = registry.resolve("did:key:z6Mk...")Functions
Extension function to create a resolver from a registry.
Gets all registered method names.
Gets all registered methods as a map.
Registers multiple DID methods.
Resolves a DID using a registered method.
Unregisters a DID method.