AbstractEnvironment constructor
AbstractEnvironment()
Base class for creating environment implementations in JetLeaf.
AbstractEnvironment
is a foundational implementation of ConfigurableEnvironment
that manages environment properties and profiles via:
- A MutablePropertySources collection,
- A PropertySourcesPropertyResolver for resolving properties,
- A
ConfigurableConversionService
for type conversions, - and support for placeholder resolution and profile activation.
Subclasses should override customizePropertySources to register their own sources, such as system properties, application config maps, or custom sources.
Example
class MyEnvironment extends AbstractEnvironment {
@override
void customizePropertySources(MutablePropertySources sources) {
sources.addLast(MapPropertySource('my-config', {
'server.port': '8080',
'debug': 'true',
}));
}
}
void main() {
final env = MyEnvironment();
print(env.getProperty('server.port')); // 8080
}
Profiles
JetLeaf supports both active and default profiles:
- Active profiles are those explicitly set using setActiveProfiles or addActiveProfile.
- Default profiles are used when no active profile is set, and can be configured using setDefaultProfiles.
A default profile name of "default"
is always used unless overridden.
System properties and environment
You can access system properties and environment variables using getSystemProperties
and getSystemEnvironment. To suppress access to System.getenv()
, set the
jetleaf.getenv.ignore
flag via JetLeafProperties
.
Implementation
AbstractEnvironment() : this.source(MutablePropertySources());