Class RepositoryFactoryBeanSupport<T extends Repository<S,ID>,S,ID>

java.lang.Object
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport<T,S,ID>
Type Parameters:
T - the type of the repository
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, RepositoryFactoryInformation<S,ID>
Direct Known Subclasses:
TransactionalRepositoryFactoryBeanSupport

public abstract class RepositoryFactoryBeanSupport<T extends Repository<S,ID>,S,ID> extends Object implements org.springframework.beans.factory.InitializingBean, RepositoryFactoryInformation<S,ID>, org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ApplicationEventPublisherAware
Adapter for Springs FactoryBean interface to allow easy setup of repository factories via Spring configuration.
Author:
Oliver Gierke, Thomas Darimont, Mark Paluch, Johannes Englmeier
  • Constructor Details

    • RepositoryFactoryBeanSupport

      protected RepositoryFactoryBeanSupport(Class<? extends T> repositoryInterface)
      Creates a new RepositoryFactoryBeanSupport for the given repository interface.
      Parameters:
      repositoryInterface - must not be null.
  • Method Details

    • setRepositoryBaseClass

      public void setRepositoryBaseClass(Class<?> repositoryBaseClass)
      Configures the repository base class to be used.
      Parameters:
      repositoryBaseClass - the repositoryBaseClass to set, can be null.
      Since:
      1.11
    • setQueryLookupStrategyKey

      public void setQueryLookupStrategyKey(QueryLookupStrategy.Key queryLookupStrategyKey)
      Set the QueryLookupStrategy.Key to be used.
      Parameters:
      queryLookupStrategyKey -
    • setCustomImplementation

      public void setCustomImplementation(Object customImplementation)
      Setter to inject a custom repository implementation.
      Parameters:
      customImplementation -
    • setRepositoryFragments

      public void setRepositoryFragments(RepositoryComposition.RepositoryFragments repositoryFragments)
      Setter to inject repository fragments.
      Parameters:
      repositoryFragments -
    • setNamedQueries

      public void setNamedQueries(NamedQueries namedQueries)
      Setter to inject a NamedQueries instance.
      Parameters:
      namedQueries - the namedQueries to set
    • setMappingContext

      protected void setMappingContext(MappingContext<?,?> mappingContext)
      Configures the MappingContext to be used to lookup PersistentEntity instances for getPersistentEntity().
      Parameters:
      mappingContext -
    • setEvaluationContextProvider

      public void setEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider)
      Sets the QueryMethodEvaluationContextProvider to be used to evaluate SpEL expressions in manually defined queries.
      Parameters:
      evaluationContextProvider - must not be null.
    • addRepositoryFactoryCustomizer

      public void addRepositoryFactoryCustomizer(RepositoryFactoryCustomizer customizer)
      Register a RepositoryFactoryCustomizer to customize the repository factor before creating the repository.
      Parameters:
      customizer - must not be null.
      Since:
      2.4
    • setLazyInit

      public void setLazyInit(boolean lazy)
      Configures whether to initialize the repository proxy lazily. This defaults to false.
      Parameters:
      lazy - whether to initialize the repository proxy lazily. This defaults to false.
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • createDefaultQueryMethodEvaluationContextProvider

      protected Optional<QueryMethodEvaluationContextProvider> createDefaultQueryMethodEvaluationContextProvider(org.springframework.beans.factory.ListableBeanFactory beanFactory)
      Create a default QueryMethodEvaluationContextProvider (or subclass) from ListableBeanFactory.
      Parameters:
      beanFactory - the bean factory to use.
      Returns:
      the default instance. May be Optional.empty().
      Since:
      2.4
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • getEntityInformation

      public EntityInformation<S,ID> getEntityInformation()
      Description copied from interface: RepositoryFactoryInformation
      Returns EntityInformation the repository factory is using.
      Specified by:
      getEntityInformation in interface RepositoryFactoryInformation<T extends Repository<S,ID>,S>
      Returns:
    • getRepositoryInformation

      public RepositoryInformation getRepositoryInformation()
      Description copied from interface: RepositoryFactoryInformation
      Returns the RepositoryInformation to determine meta-information about the repository being used.
      Specified by:
      getRepositoryInformation in interface RepositoryFactoryInformation<T extends Repository<S,ID>,S>
      Returns:
    • getPersistentEntity

      public PersistentEntity<?,?> getPersistentEntity()
      Description copied from interface: RepositoryFactoryInformation
      Returns the PersistentEntity managed by the underlying repository. Can be null in case the underlying persistence mechanism does not expose a MappingContext.
      Specified by:
      getPersistentEntity in interface RepositoryFactoryInformation<T extends Repository<S,ID>,S>
      Returns:
    • getQueryMethods

      public List<QueryMethod> getQueryMethods()
      Description copied from interface: RepositoryFactoryInformation
      Returns all QueryMethods declared for that repository.
      Specified by:
      getQueryMethods in interface RepositoryFactoryInformation<T extends Repository<S,ID>,S>
      Returns:
    • getObject

      @NonNull public T getObject()
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<T extends Repository<S,ID>>
    • getObjectType

      @NonNull public Class<? extends T> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<T extends Repository<S,ID>>
    • isSingleton

      public boolean isSingleton()
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<T extends Repository<S,ID>>
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • createRepositoryFactory

      protected abstract RepositoryFactorySupport createRepositoryFactory()
      Create the actual RepositoryFactorySupport instance.
      Returns: