Package org.approvej.configuration
Class Registry
java.lang.Object
org.approvej.configuration.Registry
Registry for components that can be configured via aliases.
Components are discovered via the Java ServiceLoader mechanism. Providers register
themselves by implementing the Provider interface and adding a corresponding entry in
META-INF/services/org.approvej.configuration.Provider.
The registry supports both alias-based lookups (e.g., "json", "yaml") and fallback to fully-qualified class names for backward compatibility.
-
Method Summary
-
Method Details
-
resolve
Resolves a component by its alias or fully-qualified class name.First attempts to find a registered provider with the given alias. If no provider is found, falls back to creating an instance via reflection using the alias as a class name.
- Type Parameters:
T- the component type- Parameters:
aliasOrClassName- the alias (e.g., "json") or fully-qualified class nametype- the expected component type- Returns:
- the resolved component instance
- Throws:
ConfigurationError- if the component cannot be resolved
-
findByAlias
Finds a provider by its alias for the given type.- Type Parameters:
T- the component type- Parameters:
alias- the alias to look uptype- the expected component type- Returns:
- an Optional containing the component if found
-