Package com.tccc.kos.commons.util.ready
Interface ReadyListener
- All Known Subinterfaces:
ReadyAndReadyListener
- All Known Implementing Classes:
AbstractConfigurable,AbstractConfigurableService,AbstractService,AnalyticsClient,AnalyticsServer,ApiClient,AppService,AssemblyService,BrokerClient,BrowserService,ConfigSerialNumberProvider,ConfigServer,ConfigService,CriticalDataSerialNumberProvider,CriticalDataService,DeviceService,ExtensionService,FirmwareService,FuseService,HandleService,HardwareService,KeyValService,LocalizationService,LogServer,LogService,ManifestService,NetworkService,NodeMgrService,NodeResolverService,OTAService,ReadyBean,RegionService,SerialService,SpawnService,StateService,StorageService,TimeService,TroubleService,UdevNode,UdevService,UpdateService
public interface ReadyListener
When a bean implements this interface, then it receives callbacks when fields
annotated with WhenReady become "ready". This interface works in conjunction
with the
@WhenReady annotation. This implementing bean must be
connected to the KOS BeanContext in order to receive the callbacks.
Example
public class MyClass1 implements ReadyListener {
@Autowired
@WhenReady("Group-A");
private MyClass2 myClass2;
@Autowired
@WhenReady({"Group-B", "Group-C"});
private MyClass3 myClass3;
@Override // ReadyListner
public void onDependenciesGroupReady(String group) {
switch (group) {
case "Group-A":
// We know that all "Group-A" objects are ready,
// therefore myClass2 can perform work using those objects.
break;
case "Group-B":
// We know that all "Group-B" objects are ready,
// therefore myClass3 can perform work using those objects.
break;
case "Group-C":
// We know that all "Group-C" objects are ready,
// therefore myClass3 can perform work using those objects.
break;
default:
// We're not interested in this group.
break;
}
}
@Override // ReadyListener
public void onDependenciesReady() {
// We know that all groups are ready,
// therefore myClass2 and myClass3 can perform all of their init work.
}
}
- Since:
- 1.0
- Version:
- 2022-08-30
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidonDependenciesGroupReady(String group) Called when@WhenReady-annotated fields for a particular group become ready.voidCalled when all@WhenReady-annotated beans in the object become ready.
-
Method Details
-
onDependenciesGroupReady
Called when@WhenReady-annotated fields for a particular group become ready. The value of@WhenReadyis a group name (default is empty string), which allows for multiple callbacks to occur, one for every time all the objects in a named group are ready. The order of callbacks is not deterministic, and occur as the dependent objects become ready and complete the groups. This can be overridden in order to perform a phased startup based on the availability of various combinations of beans.- Parameters:
group- the name of the group that has become ready
-
onDependenciesReady
void onDependenciesReady()Called when all@WhenReady-annotated beans in the object become ready. This is never called more than once, and may never be called if any dependent objects never become ready. This can be used in conjunction withonDependenciesGroupReady()to know when all groups have become ready. If the bean also implementsReadythis this typically callssetReady()to continue the ready events.
-