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...")

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Extension function to create a resolver from a registry.

Link copied to clipboard
fun clear()

Clears all registered methods (for testing).

Link copied to clipboard
operator fun contains(methodName: String): Boolean

Checks if a method is registered using the in operator.

Link copied to clipboard
operator fun get(methodName: String): DidMethod?

Gets a DID method by name.

Link copied to clipboard

Gets all registered method names.

Link copied to clipboard

Gets all registered methods as a map.

Link copied to clipboard
fun has(methodName: String): Boolean

Checks if a method is registered.

Link copied to clipboard
fun register(method: DidMethod)

Registers a DID method.

Link copied to clipboard
fun registerAll(vararg methods: DidMethod)

Registers multiple DID methods.

Link copied to clipboard

Resolves a DID using a registered method.

Link copied to clipboard
operator fun set(methodName: String, method: DidMethod)

Registers a method using bracket notation.

Link copied to clipboard
fun size(): Int

Returns the number of registered methods.

Link copied to clipboard
fun unregister(methodName: String): Boolean

Unregisters a DID method.