The
PreDestroy
annotation is used on a method as a callback notification
to signal that the instance is in the process of being removed by the container.
Note that we can equally use any PreDestroy
annotation - so we can use
the one from javax.annotation
, jakarta.annotation
or this one.
The method annotated with PreDestroy
is typically used to release resources
that it has been holding.
The method on which the PreDestroy
annotation is applied must fulfill the
following criteria:
- The method must not have any parameters.
- The method may be public, protected or package private.
- The method must not be static.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionint
Specify the priority of the destroy method to control its execution order relative to other destroy methods.
-
Element Details
-
priority
int prioritySpecify the priority of the destroy method to control its execution order relative to other destroy methods.Low values execute earlier than high values. All destroy methods without any explicit priority are given a value of 1000.
- Default:
1000
-