Interface PropertySourceImporter<T>
- Type Parameters:
T- The typed import declaration produced from aConnectionStringor structured values
- All Superinterfaces:
AutoCloseable, Toggleable
- All Known Implementing Classes:
ClasspathPropertySourceImporter, ClasspathWildcardPropertySourceImporter, ConfigTreePropertySourceImporter, EnvPropertySourceImporter, FilePropertySourceImporter, RetryablePropertySourceImporter
PropertySource for a given provider.
Importer instances are created for a single configuration loading cycle. Micronaut reuses the same importer
instance for all imports resolved during that cycle so implementations may share expensive resources such as
HTTP clients across multiple imports. Once configuration loading completes, Micronaut invokes close().
The same lifecycle applies during startup and each refresh operation.
- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceImport context information and helper methods. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Close resources associated with this importer after a configuration loading cycle completes.Resolve a property source from the provided context.newImportDeclaration(ConvertibleValues<Object> values) Convert structured config import values into a type-safe import declaration consumed by this importer.newImportDeclaration(ConnectionString connectionString) Convert the raw connection string into a type-safe import declaration consumed by this importer.Methods inherited from interface Toggleable
isEnabled
-
Method Details
-
getProvider
String getProvider()- Returns:
- The provider this importer supports.
-
newImportDeclaration
Convert the raw connection string into a type-safe import declaration consumed by this importer.Micronaut invokes this method once for each scalar
micronaut.config.importentry before callingimportPropertySource(ImportContext). Implementations should validate any importer-specific semantics here and return an immutable declaration value suitable for repeated reads within the same load cycle.- Parameters:
connectionString- The parsed connection string declaration- Returns:
- The typed import declaration
-
newImportDeclaration
Convert structured config import values into a type-safe import declaration consumed by this importer.Micronaut invokes this method for map-based
micronaut.config.importdeclarations after resolving the requiredproviderfield. Implementations should validate required keys and throw a configuration exception if the declaration is invalid.- Parameters:
values- The structured config import values- Returns:
- The typed import declaration
-
importPropertySource
Resolve a property source from the provided context.- Parameters:
context- The import context- Returns:
- The imported property source
-
close
default void close()Close resources associated with this importer after a configuration loading cycle completes.Micronaut invokes this method once after startup loading finishes and once after each refresh load finishes. Implementations may override it to release per-load resources. The default implementation is a no-op.
- Specified by:
closein interfaceAutoCloseable
-