PreDestroy class
Marks a method the container calls when a bean is destroyed: when the context closes for a singleton, when its scope ends for a scoped bean.
Use it to release what the bean holds: flush a buffer, close a file,
cancel a timer. The method takes no arguments. It may return a
Future, which closeAsync waits for (close logs it and goes on).
Prototype beans are not tracked, so their @PreDestroy methods are
never called (as in Spring).
@Component()
class Cache {
@PreDestroy()
void flush() { /* write entries */ }
}
Spring (Java), the Jakarta annotation:
@Component
class Cache {
@PreDestroy
void flush() { ... }
}
Constructors
- PreDestroy()
-
Marks the destroy method.
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