public abstract class RepositoryFactorySupport extends Object implements BeanClassLoaderAware, BeanFactoryAware
QueryExecutorMethodInterceptor. Query
detection strategy can be configured by setting QueryLookupStrategy.Key.| Constructor and Description |
|---|
RepositoryFactorySupport() |
| Modifier and Type | Method and Description |
|---|---|
void |
addInvocationListener(RepositoryMethodInvocationListener listener)
Adds a
RepositoryMethodInvocationListener to the factory to plug in functionality triggered right after
running query methods and fragment methods. |
void |
addQueryCreationListener(QueryCreationListener<?> listener)
Adds a
QueryCreationListener to the factory to plug in functionality triggered right after creation of
RepositoryQuery instances. |
void |
addRepositoryProxyPostProcessor(RepositoryProxyPostProcessor processor)
Adds
RepositoryProxyPostProcessors to the factory to allow manipulation of the ProxyFactory before
the proxy gets created. |
abstract <T,ID> EntityInformation<T,ID> |
getEntityInformation(Class<T> domainClass)
Returns the
EntityInformation for the given domain class. |
protected ProjectionFactory |
getProjectionFactory(ClassLoader classLoader,
BeanFactory beanFactory)
Returns the
ProjectionFactory to be used with the repository instances created. |
protected Optional<QueryLookupStrategy> |
getQueryLookupStrategy(QueryLookupStrategy.Key key,
QueryMethodEvaluationContextProvider evaluationContextProvider)
Returns the
QueryLookupStrategy for the given QueryLookupStrategy.Key and QueryMethodEvaluationContextProvider. |
protected List<QueryMethod> |
getQueryMethods() |
<T> T |
getRepository(Class<T> repositoryInterface)
Returns a repository instance for the given interface.
|
<T> T |
getRepository(Class<T> repositoryInterface,
Object customImplementation)
Returns a repository instance for the given interface backed by a single instance providing implementation logic
for custom logic.
|
<T> T |
getRepository(Class<T> repositoryInterface,
RepositoryComposition.RepositoryFragments fragments)
Returns a repository instance for the given interface backed by an instance providing implementation logic for
custom logic.
|
protected abstract Class<?> |
getRepositoryBaseClass(RepositoryMetadata metadata)
Returns the base class backing the actual repository instance.
|
protected RepositoryComposition.RepositoryFragments |
getRepositoryFragments(RepositoryMetadata metadata)
Creates
RepositoryComposition.RepositoryFragments based on RepositoryMetadata to add repository-specific extensions. |
protected RepositoryInformation |
getRepositoryInformation(RepositoryMetadata metadata,
RepositoryComposition.RepositoryFragments fragments)
Returns the
RepositoryInformation for the given RepositoryMetadata and custom
RepositoryComposition.RepositoryFragments. |
protected RepositoryMetadata |
getRepositoryMetadata(Class<?> repositoryInterface)
Returns the
RepositoryMetadata for the given repository interface. |
protected abstract Object |
getTargetRepository(RepositoryInformation metadata)
Create a repository instance as backing for the query proxy.
|
protected <R> R |
getTargetRepositoryViaReflection(Class<?> baseClass,
Object... constructorArguments)
Creates a repository of the repository base class defined in the given
RepositoryInformation using
reflection. |
protected <R> R |
getTargetRepositoryViaReflection(RepositoryInformation information,
Object... constructorArguments)
Creates a repository of the repository base class defined in the given
RepositoryInformation using
reflection. |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider)
Sets the
QueryMethodEvaluationContextProvider to be used to evaluate SpEL expressions in manually defined
queries. |
void |
setNamedQueries(NamedQueries namedQueries)
Configures a
NamedQueries instance to be handed to the QueryLookupStrategy for query creation. |
void |
setQueryLookupStrategyKey(QueryLookupStrategy.Key key)
Sets the strategy of how to lookup a query to execute finders.
|
void |
setRepositoryBaseClass(Class<?> repositoryBaseClass)
Configures the repository base class to use when creating the repository proxy.
|
protected void |
validate(RepositoryMetadata repositoryMetadata) |
public void setQueryLookupStrategyKey(QueryLookupStrategy.Key key)
key - public void setNamedQueries(NamedQueries namedQueries)
NamedQueries instance to be handed to the QueryLookupStrategy for query creation.namedQueries - the namedQueries to setpublic void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader in interface BeanClassLoaderAwarepublic void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory in interface BeanFactoryAwareBeansExceptionpublic void setEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider)
QueryMethodEvaluationContextProvider to be used to evaluate SpEL expressions in manually defined
queries.evaluationContextProvider - can be null, defaults to
QueryMethodEvaluationContextProvider#INSTANCE.public void setRepositoryBaseClass(Class<?> repositoryBaseClass)
getRepositoryBaseClass(RepositoryMetadata) by default.repositoryBaseClass - the repository base class to back the repository proxy, can be null.public void addQueryCreationListener(QueryCreationListener<?> listener)
QueryCreationListener to the factory to plug in functionality triggered right after creation of
RepositoryQuery instances.listener - public void addInvocationListener(RepositoryMethodInvocationListener listener)
RepositoryMethodInvocationListener to the factory to plug in functionality triggered right after
running query methods and fragment methods.listener - public void addRepositoryProxyPostProcessor(RepositoryProxyPostProcessor processor)
RepositoryProxyPostProcessors to the factory to allow manipulation of the ProxyFactory before
the proxy gets created. Note that the QueryExecutorMethodInterceptor will be added to the proxy
after the RepositoryProxyPostProcessors are considered.processor - protected RepositoryComposition.RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata)
RepositoryComposition.RepositoryFragments based on RepositoryMetadata to add repository-specific extensions.metadata - public <T> T getRepository(Class<T> repositoryInterface)
repositoryInterface - must not be null.public <T> T getRepository(Class<T> repositoryInterface, Object customImplementation)
#getRepository(Class, RepositoryFragments).repositoryInterface - must not be null.customImplementation - must not be null.public <T> T getRepository(Class<T> repositoryInterface, RepositoryComposition.RepositoryFragments fragments)
repositoryInterface - must not be null.fragments - must not be null.protected ProjectionFactory getProjectionFactory(ClassLoader classLoader, BeanFactory beanFactory)
ProjectionFactory to be used with the repository instances created.classLoader - will never be null.beanFactory - will never be null.protected RepositoryMetadata getRepositoryMetadata(Class<?> repositoryInterface)
RepositoryMetadata for the given repository interface.repositoryInterface - will never be null.protected RepositoryInformation getRepositoryInformation(RepositoryMetadata metadata, RepositoryComposition.RepositoryFragments fragments)
RepositoryInformation for the given RepositoryMetadata and custom
RepositoryComposition.RepositoryFragments.metadata - must not be null.fragments - must not be null.protected List<QueryMethod> getQueryMethods()
public abstract <T,ID> EntityInformation<T,ID> getEntityInformation(Class<T> domainClass)
EntityInformation for the given domain class.T - the entity typeID - the id typedomainClass - protected abstract Object getTargetRepository(RepositoryInformation metadata)
metadata - protected abstract Class<?> getRepositoryBaseClass(RepositoryMetadata metadata)
getTargetRepository(RepositoryInformation) returns an instance of this class.metadata - protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable QueryLookupStrategy.Key key, QueryMethodEvaluationContextProvider evaluationContextProvider)
QueryLookupStrategy for the given QueryLookupStrategy.Key and QueryMethodEvaluationContextProvider.key - can be null.evaluationContextProvider - will never be null.QueryLookupStrategy to use or null if no queries should be looked up.protected void validate(RepositoryMetadata repositoryMetadata)
protected final <R> R getTargetRepositoryViaReflection(RepositoryInformation information, Object... constructorArguments)
RepositoryInformation using
reflection.information - constructorArguments - protected final <R> R getTargetRepositoryViaReflection(Class<?> baseClass, Object... constructorArguments)
RepositoryInformation using
reflection.baseClass - constructorArguments - Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.