BeanMethodAnnotation class

Marks an annotation class whose methods the runtime can find on beans.

Libraries that act on annotated bean methods (a scheduler running @Scheduled methods, a message consumer) need to find and call them, and Dart has no reflection for that. Put @BeanMethodAnnotation() on such an annotation class: for every bean method carrying it, the generator writes an IntrospectedMethod into BeanDefinition.annotatedMethods with the method's name, annotations and a closure that calls it. Application code rarely needs it; library authors do.

@BeanMethodAnnotation()
class Poll {
  const Poll(this.every);
  final Duration every;
}

@Component()
class Inbox {
  @Poll(Duration(seconds: 30))
  void check() { ... }
}

// In a BeanPostProcessor or lifecycle bean of the library: find the
// @Poll methods and call them on the bean.
for (final method in context.beanFactory
    .getBeanDefinition('inbox')
    .annotatedMethods) {
  final poll = method.annotations.whereType<Poll>().first;
  method.invoke(context.getBeanByName('inbox'), const []);
}

Spring finds such methods by reflection (MethodIntrospector.selectMethods), so it has no equivalent.

Constructors

BeanMethodAnnotation()
Marks the annotation class.
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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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