AbstractEnvironment class abstract

Base class for creating environment implementations in JetLeaf.

AbstractEnvironment is a foundational implementation of ConfigurableEnvironment that manages environment properties and profiles via:

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:

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.

Inheritance
Implementers

Constructors

AbstractEnvironment()
Base class for creating environment implementations in JetLeaf.
AbstractEnvironment.source(MutablePropertySources propertySources)
Constructor with Pre-Created Sources

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

acceptsProfiles(Profiles profiles) bool
Profile Predicate Evaluation
override
addActiveProfile(String profile) → void
Adds an additional active profile to the current set.
override
containsProperty(String key) bool
Returns whether the given property key is defined.
override
createPropertyResolver(MutablePropertySources propertySources) ConfigurablePropertyResolver
Factory for Property Resolver
customizePropertySources(MutablePropertySources sources) → void
Called during construction to allow subclasses to register default property sources.
doGetActiveProfiles() Set<String>
Resolves Active Profiles
doGetActiveProfilesProperty() String?
Reads Active Profiles Property
doGetDefaultProfiles() Set<String>
Resolves Default Profiles
doGetDefaultProfilesProperty() String?
Reads Default Profiles Property
getActiveProfiles() List<String>
Active Profiles
override
getConversionService() → ConfigurableConversionService
Returns the ConfigurableConversionService used to perform type conversions.
override
getDefaultProfiles() List<String>
Default Profiles
override
getPackageName() String
Represents an abstraction for identifying the package that an object, resource, or service belongs to.
inherited
getProperty(String key, [String? defaultValue]) String?
Retrieves the value for the given property key, or null if not found.
override
getPropertyAs<T>(String key, Class<T> targetType, [T? defaultValue]) → T?
Retrieves and converts the value of key to the desired type T.
override
getPropertyResolver() ConfigurablePropertyResolver
Access to the Property Resolver
getPropertySources() MutablePropertySources
Returns the MutablePropertySources backing this environment.
override
getRequiredProperty(String key) String
Returns the property value for key, or throws IllegalStateException if the property is not defined.
override
getRequiredPropertyAs<T>(String key, Class<T> targetType) → T
Retrieves and converts the property key to type T, or throws IllegalStateException if missing or invalid.
override
getReservedDefaultProfiles() Set<String>
Reserved Default Profiles
getSystemEnvironment() Map<String, String>
Returns the environment variables of the underlying OS.
override
getSystemProperties() Map<String, String>
Returns the system properties available to the Dart VM (if any), such as those passed via --define or custom bootstrap logic.
override
isProfileActive(String profile) bool
Checks Profile Activation
matchesProfiles(List<String> profileExpressions) bool
Profile Expression Matcher
inherited
merge(ConfigurableEnvironment parent) → void
Merges another ConfigurableEnvironment into this one.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolvePlaceholders(String text) String
Resolves #{...} placeholders in the input text using available properties.
override
resolveRequiredPlaceholders(String text) String
Resolves #{...} placeholders in the input text using available properties.
override
setActiveProfiles(List<String> profiles) → void
Replaces the current set of active profiles with the given list.
override
setConversionService(ConfigurableConversionService conversionService) → void
Replaces the underlying ConfigurableConversionService used for type conversions.
override
setDefaultProfiles(List<String> profiles) → void
Specify the set of profiles to be made active by default if no other profiles are explicitly made active through {@link #setActiveProfiles}.
override
setEscapeCharacter(Character? escapeCharacter) → void
Sets the escape character used to ignore placeholder prefix and separator.
override
setIgnoreUnresolvableNestedPlaceholders(bool ignoreUnresolvableNestedPlaceholders) → void
Enables or disables ignoring unresolvable nested placeholders.
override
setPlaceholderPrefix(String placeholderPrefix) → void
Sets the prefix that identifies a placeholder in property values.
override
setPlaceholderSuffix(String placeholderSuffix) → void
Sets the suffix that identifies the end of a placeholder in property values.
override
setRequiredProperties(List<String> requiredProperties) → void
Sets the list of property names that are required to be present and non-null.
override
setValueSeparator(String? valueSeparator) → void
Sets the separator for default values within placeholders.
override
suggestions(String key) List<String>
Configuration Suggestions
override
suppressGetenvAccess() bool
Suppresses System Environment Access
toString() String
A string representation of this object.
override
validateProfile(String profile) → void
Profile Name Validation
validateRequiredProperties() → void
Validates that all required properties are present and non-null.
override

Operators

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

Static Properties

ACTIVE_PROFILES_PROPERTY_NAME String
Active Profiles Property
final
DEFAULT_PROFILES_PROPERTY_NAME String
Default Profiles Property
final
IGNORE_GETENV_PROPERTY_NAME String
System Environment Suppression Flag
final
RESERVED_DEFAULT_PROFILE_NAME String
Reserved Default Profile Name
final