Class RepositoryRegistrationAotProcessor

java.lang.Object
org.springframework.data.repository.config.RepositoryRegistrationAotProcessor
All Implemented Interfaces:
BeanRegistrationAotProcessor, Aware, BeanFactoryAware, EnvironmentAware, EnvironmentCapable

public class RepositoryRegistrationAotProcessor extends Object implements BeanRegistrationAotProcessor, BeanFactoryAware, EnvironmentAware, EnvironmentCapable
BeanRegistrationAotProcessor responsible processing and providing AOT configuration for repositories.

Processes repository factory beans to provide generic type information to the AOT tooling to allow deriving target type from the bean definition. If generic types do not match due to customization of the factory bean by the user, at least the target repository type is provided via the FactoryBean.OBJECT_TYPE_ATTRIBUTE.

With registerRepositoryCompositionHints(AotRepositoryContext, GenerationContext) (specifically configureTypeContribution(Class, AotContext) and contributeAotRepository(AotRepositoryContext), stores can provide custom logic for contributing additional (e.g. reflection) configuration. By default, reflection configuration will be added for types reachable from the repository declaration and query methods as well as all used annotations from the org.springframework.data namespace.

The processor is typically configured via RepositoryConfigurationExtension.getRepositoryAotProcessor() and gets added by the RepositoryConfigurationDelegate.

Since:
3.0
Author:
Christoph Strobl, John Blum, Mark Paluch
  • Constructor Details

    • RepositoryRegistrationAotProcessor

      public RepositoryRegistrationAotProcessor()
  • Method Details

    • setBeanFactory

      public void setBeanFactory(BeanFactory beanFactory) throws BeansException
      Specified by:
      setBeanFactory in interface BeanFactoryAware
      Throws:
      BeansException
    • setEnvironment

      public void setEnvironment(Environment environment)
      Specified by:
      setEnvironment in interface EnvironmentAware
    • getEnvironment

      public Environment getEnvironment()
      Specified by:
      getEnvironment in interface EnvironmentCapable
    • setConfigMap

      public void setConfigMap(Map<String, RepositoryConfiguration<?>> configMap)
      Setter for the config map. See RepositoryConfigurationDelegate#registerAotComponents.
      Parameters:
      configMap -
    • getConfigMap

      public Map<String, RepositoryConfiguration<?>> getConfigMap()
    • getBeanFactory

      protected ConfigurableListableBeanFactory getBeanFactory()
    • processAheadOfTime

      public @Nullable BeanRegistrationAotContribution processAheadOfTime(RegisteredBean bean)
      Specified by:
      processAheadOfTime in interface BeanRegistrationAotProcessor
    • registerRepositoryCompositionHints

      protected void registerRepositoryCompositionHints(AotRepositoryContext repositoryContext, GenerationContext generationContext)
      Contribute repository-specific hints, e.g. for repository proxy, base implementation, fragments. Customization hook for subclasses that wish to customize repository hint contribution.
      Parameters:
      repositoryContext - the repository context.
      generationContext - the generation context.
      Since:
      4.0
    • configureTypeContributions

      protected void configureTypeContributions(AotRepositoryContext repositoryContext, GenerationContext generationContext)
      Register type-specific hints and AOT artifacts for domain types, reachable types, projection interfaces derived from query method return types, and annotations from org.springframework.data packages.
      Parameters:
      repositoryContext - the repository context.
      generationContext - the generation context.
      Since:
      4.0
    • configureTypeContribution

      protected void configureTypeContribution(Class<?> type, AotContext aotContext)
      Customization hook to configure the TypeContributor used to register the given type.
      Parameters:
      type - the class to configure the contribution for.
      aotContext - AOT context for type configuration.
      Since:
      4.0
    • contributeAotRepository

      protected @Nullable RepositoryContributor contributeAotRepository(AotRepositoryContext repositoryContext)
      This method allows for the creation to be overridden by subclasses.
      Parameters:
      repositoryContext - the context for the repository being processed.
      Returns:
      a RepositoryContributor to contribute store-specific AOT artifacts or null to skip store-specific AOT contributions.
      Since:
      4.0