Annotation Interface DependsOn
Declares that a bean depends on the beans of the given types without injecting them.
Every bean of each listed type is created before the annotated bean is instantiated and, for singletons, destroyed after the annotated bean has been destroyed. The annotation therefore controls both the creation and the destruction order, which is otherwise only derived from the injection points of a bean. A bean that must stop consuming messages before the publisher it feeds is closed can express that as:
@Singleton
@DependsOn(MessagePublisher.class)
class MessageConsumer {
@PreDestroy
void stop() {
// the publisher is still open here
}
}
The annotation is an error when no bean of a listed type exists.
- Since:
- 5.2.0
- Author:
- Denis Stepanov
-
Required Element Summary
Required Elements
-
Element Details
-
value
-