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
ConstructorsModifierConstructorDescriptionprotected
RepositoryFactoryBeanSupport
(Class<? extends T> repositoryInterface) Creates a newRepositoryFactoryBeanSupport
for the given repository interface. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Register aRepositoryFactoryCustomizer
to customize therepository factor
before creating the repository.void
protected Optional<QueryMethodEvaluationContextProvider>
createDefaultQueryMethodEvaluationContextProvider
(org.springframework.beans.factory.ListableBeanFactory beanFactory) Create a defaultQueryMethodEvaluationContextProvider
(or subclass) fromListableBeanFactory
.protected abstract RepositoryFactorySupport
Create the actualRepositoryFactorySupport
instance.ReturnsEntityInformation
the repository factory is using.PersistentEntity<?,
?> Returns thePersistentEntity
managed by the underlying repository.Returns allQueryMethod
s declared for that repository.Returns theRepositoryInformation
to determine meta-information about the repository being used.boolean
void
setApplicationEventPublisher
(org.springframework.context.ApplicationEventPublisher publisher) void
setBeanClassLoader
(ClassLoader classLoader) void
setBeanFactory
(org.springframework.beans.factory.BeanFactory beanFactory) void
setCustomImplementation
(Object customImplementation) Setter to inject a custom repository implementation.void
setEvaluationContextProvider
(QueryMethodEvaluationContextProvider evaluationContextProvider) Sets theQueryMethodEvaluationContextProvider
to be used to evaluate SpEL expressions in manually defined queries.void
setLazyInit
(boolean lazy) Configures whether to initialize the repository proxy lazily.protected void
setMappingContext
(MappingContext<?, ?> mappingContext) Configures theMappingContext
to be used to lookupPersistentEntity
instances forgetPersistentEntity()
.void
setNamedQueries
(NamedQueries namedQueries) Setter to inject aNamedQueries
instance.void
setQueryLookupStrategyKey
(QueryLookupStrategy.Key queryLookupStrategyKey) Set theQueryLookupStrategy.Key
to be used.void
setRepositoryBaseClass
(Class<?> repositoryBaseClass) Configures the repository base class to be used.void
setRepositoryFragments
(RepositoryComposition.RepositoryFragments repositoryFragments) Setter to inject repository fragments.
-
Constructor Details
-
RepositoryFactoryBeanSupport
Creates a newRepositoryFactoryBeanSupport
for 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.Key
to 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 aNamedQueries
instance.- Parameters:
namedQueries
- the namedQueries to set
-
setMappingContext
Configures theMappingContext
to be used to lookupPersistentEntity
instances forgetPersistentEntity()
.- Parameters:
mappingContext
-
-
setEvaluationContextProvider
public void setEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider) Sets theQueryMethodEvaluationContextProvider
to be used to evaluate SpEL expressions in manually defined queries.- Parameters:
evaluationContextProvider
- must not be null.
-
addRepositoryFactoryCustomizer
Register aRepositoryFactoryCustomizer
to customize therepository 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
- Specified by:
setBeanClassLoader
in interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactory
in 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:
setApplicationEventPublisher
in interfaceorg.springframework.context.ApplicationEventPublisherAware
-
getEntityInformation
Description copied from interface:RepositoryFactoryInformation
ReturnsEntityInformation
the repository factory is using.- Specified by:
getEntityInformation
in interfaceRepositoryFactoryInformation<T extends Repository<S,
ID>, S> - Returns:
-
getRepositoryInformation
Description copied from interface:RepositoryFactoryInformation
Returns theRepositoryInformation
to determine meta-information about the repository being used.- Specified by:
getRepositoryInformation
in interfaceRepositoryFactoryInformation<T extends Repository<S,
ID>, S> - Returns:
-
getPersistentEntity
Description copied from interface:RepositoryFactoryInformation
Returns thePersistentEntity
managed by the underlying repository. Can be null in case the underlying persistence mechanism does not expose aMappingContext
.- Specified by:
getPersistentEntity
in interfaceRepositoryFactoryInformation<T extends Repository<S,
ID>, S> - Returns:
-
getQueryMethods
Description copied from interface:RepositoryFactoryInformation
Returns allQueryMethod
s declared for that repository.- Specified by:
getQueryMethods
in interfaceRepositoryFactoryInformation<T extends Repository<S,
ID>, S> - Returns:
-
getObject
- Specified by:
getObject
in interfaceorg.springframework.beans.factory.FactoryBean<T extends Repository<S,
ID>>
-
getObjectType
- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<T extends Repository<S,
ID>>
-
isSingleton
public boolean isSingleton()- Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<T extends Repository<S,
ID>>
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
createRepositoryFactory
Create the actualRepositoryFactorySupport
instance.- Returns:
-