Interface CtxEventListener

All Known Implementing Classes:
AbstractConfigurableService, AbstractService, AnalyticsClient, AnalyticsServer, ApiClient, AppService, AssemblyService, BrokerClient, BrowserService, ConfigServer, ConfigService, CriticalDataService, DeviceService, ExtensionService, FirmwareService, FuseService, HandleService, HardwareService, KeyValService, LocalizationService, LogServer, LogService, ManifestService, NetworkService, NodeMgrService, NodeResolverService, OTAService, RegionService, SerialService, SpawnService, StateService, StorageService, TimeService, TroubleService, UdevService, UpdateService

public interface CtxEventListener
Interface that allows a bean to accept callbacks from the KOS BeanContext after certain autowiring steps have completed.

There are two such events:

  1. When a particular autowiring phase has completed.
  2. When all autowiring of the bean has completed.

Autowire support for contexts allows for partial autowiring by using the optional "phase" property of the @Autowired annotation.

This is particularly useful for initial system startup, when services should be started in a specific sequence, and cannot necessarily be fully autowired until later steps in the process.

When using @Autowired(phase="myPhase"), a call to ctx.update("myPhase") will cause those fields tagged with this phase to be autowired. When all beans in the context have been processed for this phase, any beans that implement this interface will be notified that all autowiring for the phase is complete, allowing the beans to do some work.

Since:
1.0
Version:
2022-08-30
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    This method is called by the BeanContext when all autowiring for the bean has completed.
    default void
    This method is called by BeanContext when the context is destroyed.
    default void
    This method is called by the BeanContext when all autowiring for the given phase has completed.
  • Method Details

    • onCtxPhaseCompleted

      default void onCtxPhaseCompleted(String phaseName)
      This method is called by the BeanContext when all autowiring for the given phase has completed. This is only called for phases referenced in the bean, and will only be called once per phase. Override if needed.
    • onCtxAutowiringCompleted

      default void onCtxAutowiringCompleted()
      This method is called by the BeanContext when all autowiring for the bean has completed. This is only called once per bean. Override if needed.
    • onCtxDestroyed

      default void onCtxDestroyed()
      This method is called by BeanContext when the context is destroyed. Override as needed.