PropertySourceProcessor class

The code that reads the files of @PropertySource annotations into an environment.

The application context runs it for every @PropertySource, so applications just write the annotation. Use it directly to add property files to an environment by hand, with the same rules: ${...} in locations, patterns such as file:conf/*.properties, missing files allowed or not.

The first source it adds goes last in the environment (lowest precedence); every later one goes just above the previous one, so the last location declared wins.

// A tool that reads an optional local override on top of a base file.
final processor = PropertySourceProcessor(
  environment,
  DefaultResourceLoader(),
);
processor.processPropertySource(
  [r'file:${config.dir}/app.properties', 'file:local.properties'],
  ignoreResourceNotFound: true,
);

Spring (Java):

var processor = new PropertySourceProcessor(
    environment, new DefaultResourceLoader());
processor.processPropertySource(new PropertySourceDescriptor(
    List.of("file:${config.dir}/app.properties", "file:local.properties"),
    true, null, DefaultPropertySourceFactory.class, null));

Constructors

PropertySourceProcessor(ConfigurableEnvironment environment, ResourceLoader resourceLoader)
Creates a processor that adds sources to environment and finds the files with resourceLoader.

Properties

environment → ConfigurableEnvironment
The environment the sources are added to; placeholders in locations are resolved against it.
final
hashCode → int
The hash code for this object.
no setterinherited
resourceLoader → ResourceLoader
Finds the resource for each location once its placeholders are resolved.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preload(Iterable<String> locations) → Future<void>
Reads ahead the resources of locations that can only be read asynchronously (Flutter assets behind a ProtocolResolver, URLs), so that a later processPropertySource can use them synchronously.
processPropertySource(List<String> locations, {String? name, bool ignoreResourceNotFound = false, PropertySourceFactory factory = const DefaultPropertySourceFactory(), String? encoding}) → void
Reads every file in locations into the environment, with the arguments of @PropertySource. ${...} in a location is resolved against the environment first.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited