Annotation Interface WhenReady
Annotation that monitors a field for when it becomes ready.
This is only meaningful if the referenced object implements the Ready
interface, so that it has an indicator to attach to.
The class that uses this annotation must also implement the ReadyListener
interface, in order to get the two callbacks that occur when WhenReady
objects become ready.
Example
public class MyClass1 implements ReadyListener {
@Autowired
@WhenReady
private MyClass2 myClass2;
@Autowired
@WhenReady("Group-A")
private MyClass3 myClass3;
@Autowired
@WhenReady({"Group-A", "Group-B", "Group-C"})
private MyClass4 myClass4;
@Override // ReadyListener
public void onDependenciesGroupReady(String group) {
switch (group) {
case "Group-A":
// We know myClass3 & myClass4 are now ready, so perform desired work.
break;
default:
// Group we're not interested in.
break;
}
}
@Override // ReadyListener
public void onDependenciesReady() {
// We know know that both myClass2 and myClass3 are ready.
}
}
- Since:
- 1.0
- Version:
- 2022-08-30
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String[] valueThe ready group(s) that this object belongs to.- Returns:
- the names of the groups that this object belongs to; can be any number of groups
- Default:
- {""}
-