Interface PropertySourceImporter<T>

Type Parameters:
T - The typed import declaration produced from a ConnectionString or structured values
All Superinterfaces:
AutoCloseable, Toggleable
All Known Implementing Classes:
ClasspathPropertySourceImporter, ClasspathWildcardPropertySourceImporter, ConfigTreePropertySourceImporter, EnvPropertySourceImporter, FilePropertySourceImporter, RetryablePropertySourceImporter

public interface PropertySourceImporter<T> extends Toggleable, AutoCloseable
Imports a 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
  • Method Details

    • getProvider

      String getProvider()
      Returns:
      The provider this importer supports.
    • newImportDeclaration

      T newImportDeclaration(ConnectionString connectionString)
      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.import entry before calling importPropertySource(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

      T newImportDeclaration(ConvertibleValues<Object> values)
      Convert structured config import values into a type-safe import declaration consumed by this importer.

      Micronaut invokes this method for map-based micronaut.config.import declarations after resolving the required provider field. 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:
      close in interface AutoCloseable