Interface ComponentLifecycleHandler<C>

Type Parameters:
C - The type of component.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ComponentLifecycleHandler<C>
Represents a handler for a component's lifecycle.

Unlike the LifecycleHandler, this handler provides access to the component when it is created.

With decorated components, this may not be the same component instance as would be retrieved from the configuration using the component's identifier. The latter would return the decorated component, while the ComponentLifecycleHandler receives the instance on the level it was registered. If this is a decorator, you get the decorated instance of that registration, not the completed component.

Since:
5.0.0
Author:
Allard Buijze
  • Method Summary

    Modifier and Type
    Method
    Description
    run(Configuration configuration, C component)
    Runs the lifecycle handler for given component that has been defined within the scope of given configuration.
  • Method Details

    • run

      CompletableFuture<?> run(@Nonnull Configuration configuration, @Nonnull C component)
      Runs the lifecycle handler for given component that has been defined within the scope of given configuration. The configuration may be used to retrieve components that the given component must interact with during its lifecycle.

      Lifecycle methods may be executed asynchronously. In that case, the returned CompletableFuture must be completed when the lifecycle operation has completed. Failures may be propagated by completing the CompletableFuture exceptionally.

      Parameters:
      configuration - The configuration in which the component was defined.
      component - The instance of the component.
      Returns:
      A future that completes when the lifecycle operation has terminated.