Interface ApplicationContext

All Known Subinterfaces:
ProcessingContext
All Known Implementing Classes:
ConfigurationApplicationContext, EmptyApplicationContext, LegacyMessageSupportingContext, ResourceOverridingProcessingContext
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 ApplicationContext
An ApplicationContext is a container for components that are registered in the ComponentRegistry of the ApplicationConfigurer. It allows retrieval of components by their type and optionally by their name.

This interface is typically used to retrieve components that are registered in the ApplicationConfigurer's ComponentRegistry. It is designed to be used in places where you have access to the ProcessingContext.

Since:
5.0.0
Author:
Mateusz Nowak, Mitchell Herrijgers, Steven van Beelen
  • Method Summary

    Modifier and Type
    Method
    Description
    default <C> C
    component(Class<C> type)
    Returns the component declared under the given type or throws a ComponentNotFoundException if it does not exist.
    <C> C
    component(Class<C> type, String name)
    Returns the component declared under the given type and name or throws a ComponentNotFoundException if it does not exist.
  • Method Details

    • component

      @Nonnull default <C> C component(@Nonnull Class<C> type)
      Returns the component declared under the given type or throws a ComponentNotFoundException if it does not exist.
      Type Parameters:
      C - The type of component.
      Parameters:
      type - The type of component, typically the interface the component implements.
      Returns:
      The component registered for the given type.
      Throws:
      ComponentNotFoundException - Whenever there is no component present for the given type.
    • component

      @Nonnull <C> C component(@Nonnull Class<C> type, @Nullable String name)
      Returns the component declared under the given type and name or throws a ComponentNotFoundException if it does not exist.
      Type Parameters:
      C - The type of component.
      Parameters:
      type - The type of component, typically the interface the component implements.
      name - The name of the component to retrieve. Use null when there is no name or use component(Class) instead.
      Returns:
      The component registered for the given type and name.
      Throws:
      ComponentNotFoundException - Whenever there is no component present for the given type and name.