Annotation Interface PreDestroy
The PreDestroy
annotation is used to signal that the annotated method
should be executed before the container removes the instance of the class
in which the method is declared. This is typically used for cleanup operations
or releasing resources held by the instance.
The annotated method must have no parameters, must be non-static and return void.
It is invoked before the bean is destroyed, allowing the bean to perform necessary
cleanup tasks.
If multiple methods are annotated with @PreDestroy
within a single
class, the order of execution is not guaranteed.
Example of usage:
@PreDestroy
public void cleanup() {
// Perform cleanup operations or release resources here
}
- Since:
- 1.0
- Author:
- Blyzhnytsia Team