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
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRepositoryFactoryBeanSupport(Class<? extends T> repositoryInterface) Creates a newRepositoryFactoryBeanSupportfor the given repository interface. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister aRepositoryFactoryCustomizerto customize therepository factorbefore creating the repository.voidprotected Optional<QueryMethodEvaluationContextProvider>createDefaultQueryMethodEvaluationContextProvider(org.springframework.beans.factory.ListableBeanFactory beanFactory) Create a defaultQueryMethodEvaluationContextProvider(or subclass) fromListableBeanFactory.protected abstract RepositoryFactorySupportCreate the actualRepositoryFactorySupportinstance.ReturnsEntityInformationthe repository factory is using.PersistentEntity<?,?> Returns thePersistentEntitymanaged by the underlying repository.Returns allQueryMethods declared for that repository.Returns theRepositoryInformationto determine meta-information about the repository being used.booleanvoidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher) voidsetBeanClassLoader(ClassLoader classLoader) voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) voidsetCustomImplementation(Object customImplementation) Setter to inject a custom repository implementation.voidsetEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider) Sets theQueryMethodEvaluationContextProviderto be used to evaluate SpEL expressions in manually defined queries.voidsetLazyInit(boolean lazy) Configures whether to initialize the repository proxy lazily.protected voidsetMappingContext(MappingContext<?, ?> mappingContext) Configures theMappingContextto be used to lookupPersistentEntityinstances forgetPersistentEntity().voidsetNamedQueries(NamedQueries namedQueries) Setter to inject aNamedQueriesinstance.voidsetQueryLookupStrategyKey(QueryLookupStrategy.Key queryLookupStrategyKey) Set theQueryLookupStrategy.Keyto be used.voidsetRepositoryBaseClass(Class<?> repositoryBaseClass) Configures the repository base class to be used.voidsetRepositoryFragments(RepositoryComposition.RepositoryFragments repositoryFragments) Setter to inject repository fragments.
-
Constructor Details
-
RepositoryFactoryBeanSupport
Creates a newRepositoryFactoryBeanSupportfor the given repository interface.- Parameters:
repositoryInterface- must not be null.
-
-
Method Details
-
setRepositoryBaseClass
Configures the repository base class to be used.- Parameters:
repositoryBaseClass- the repositoryBaseClass to set, can be null.- Since:
- 1.11
-
setQueryLookupStrategyKey
Set theQueryLookupStrategy.Keyto be used.- Parameters:
queryLookupStrategyKey-
-
setCustomImplementation
Setter to inject a custom repository implementation.- Parameters:
customImplementation-
-
setRepositoryFragments
Setter to inject repository fragments.- Parameters:
repositoryFragments-
-
setNamedQueries
Setter to inject aNamedQueriesinstance.- Parameters:
namedQueries- the namedQueries to set
-
setMappingContext
Configures theMappingContextto be used to lookupPersistentEntityinstances forgetPersistentEntity().- Parameters:
mappingContext-
-
setEvaluationContextProvider
public void setEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider) Sets theQueryMethodEvaluationContextProviderto be used to evaluate SpEL expressions in manually defined queries.- Parameters:
evaluationContextProvider- must not be null.
-
addRepositoryFactoryCustomizer
Register aRepositoryFactoryCustomizerto customize therepository factorbefore 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
- Specified by:
setBeanClassLoaderin interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
createDefaultQueryMethodEvaluationContextProvider
protected Optional<QueryMethodEvaluationContextProvider> createDefaultQueryMethodEvaluationContextProvider(org.springframework.beans.factory.ListableBeanFactory beanFactory) Create a defaultQueryMethodEvaluationContextProvider(or subclass) fromListableBeanFactory.- 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:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
getEntityInformation
Description copied from interface:RepositoryFactoryInformationReturnsEntityInformationthe repository factory is using.- Specified by:
getEntityInformationin interfaceRepositoryFactoryInformation<T extends Repository<S,ID>, S> - Returns:
-
getRepositoryInformation
Description copied from interface:RepositoryFactoryInformationReturns theRepositoryInformationto determine meta-information about the repository being used.- Specified by:
getRepositoryInformationin interfaceRepositoryFactoryInformation<T extends Repository<S,ID>, S> - Returns:
-
getPersistentEntity
Description copied from interface:RepositoryFactoryInformationReturns thePersistentEntitymanaged by the underlying repository. Can be null in case the underlying persistence mechanism does not expose aMappingContext.- Specified by:
getPersistentEntityin interfaceRepositoryFactoryInformation<T extends Repository<S,ID>, S> - Returns:
-
getQueryMethods
Description copied from interface:RepositoryFactoryInformationReturns allQueryMethods declared for that repository.- Specified by:
getQueryMethodsin interfaceRepositoryFactoryInformation<T extends Repository<S,ID>, S> - Returns:
-
getObject
- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean<T extends Repository<S,ID>>
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<T extends Repository<S,ID>>
-
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<T extends Repository<S,ID>>
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
createRepositoryFactory
Create the actualRepositoryFactorySupportinstance.- Returns:
-