BeanExpressionContextAccessor class final

A PropertyAccessor that reads the beans of a BeanExpressionContext as its properties, so that #{mailer} is the bean mailer.

StandardBeanExpressionResolver registers it for every @Value expression; you need it only to evaluate expressions against a BeanExpressionContext in a context of your own. Beans cannot be assigned through it.

// `mailer` reads the bean of that name.
final context = StandardEvaluationContext(BeanExpressionContext(factory))
  ..addPropertyAccessor(const BeanExpressionContextAccessor());
SpelExpressionParser().parseExpression('mailer').getValue(context);

Spring (Java):

context.addPropertyAccessor(new BeanExpressionContextAccessor());
parser.parseExpression("mailer").getValue(context);
Implemented types

Constructors

BeanExpressionContextAccessor()
Creates the accessor (stateless).
const

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

canRead(EvaluationContext context, Object target, String name) → bool
Whether this accessor handles reading property name of target; false lets the next accessor try. target is never null.
override
canWrite(EvaluationContext context, Object target, String name) → bool
Whether this accessor handles writing property name of target; return false for read-only properties.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(EvaluationContext context, Object target, String name) → Object?
The value of property name of target; only called after canRead returned true.
override
toString() → String
A string representation of this object.
inherited
write(EvaluationContext context, Object target, String name, Object? newValue) → void
Stores newValue in property name of target; only called after canWrite returned true.
override

Operators

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