org.springframework.data.repository.core.support

## 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:
  Aware, BeanClassLoaderAware, BeanFactoryAware, FactoryBean<T>, InitializingBean, ApplicationEventPublisherAware, RepositoryFactoryInformation<S,ID>

Direct Known Subclasses:
  TransactionalRepositoryFactoryBeanSupport

    public abstract class RepositoryFactoryBeanSupport<T extends Repository<S,ID>,S,ID>
    extends Object
    implements InitializingBean, RepositoryFactoryInformation<S,ID>, FactoryBean<T>, BeanClassLoaderAware, BeanFactoryAware, ApplicationEventPublisherAware

Adapter for Springs `FactoryBean` interface to allow easy setup of repository factories via Spring configuration.

Author:
  Oliver Gierke, Thomas Darimont, Mark Paluch

### Field Summary

### Fields inherited from interface org.springframework.beans.factory.FactoryBean

`OBJECT_TYPE_ATTRIBUTE`

### Constructor Summary

Constructors
`protected` `RepositoryFactoryBeanSupport(Class<? extends T> repositoryInterface)` Creates a new `RepositoryFactoryBeanSupport` for the given repository interface.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `addRepositoryFactoryCustomizer(RepositoryFactoryCustomizer customizer)` Register a `RepositoryFactoryCustomizer` to customize the `repository factor` before creating the repository.
`void` `afterPropertiesSet()`
`protected Optional<QueryMethodEvaluationContextProvider>` `createDefaultQueryMethodEvaluationContextProvider(ListableBeanFactory beanFactory)` Create a default `QueryMethodEvaluationContextProvider` (or subclass) from `ListableBeanFactory`.
`protected abstract RepositoryFactorySupport` `createRepositoryFactory()` Create the actual `RepositoryFactorySupport` instance.
`EntityInformation<S,ID>` `getEntityInformation()` Returns `EntityInformation` the repository factory is using.
`T` `getObject()`
`Class<? extends T>` `getObjectType()`
`PersistentEntity<?,?>` `getPersistentEntity()` Returns the `PersistentEntity` managed by the underlying repository.
`List<QueryMethod>` `getQueryMethods()` Returns all `QueryMethod`s declared for that repository.
`RepositoryInformation` `getRepositoryInformation()` Returns the `RepositoryInformation` to determine meta-information about the repository being used.
`boolean` `isSingleton()`
`void` `setApplicationEventPublisher(ApplicationEventPublisher publisher)`
`void` `setBeanClassLoader(ClassLoader classLoader)`
`void` `setBeanFactory(BeanFactory beanFactory)`
`void` `setCustomImplementation(Object customImplementation)` Setter to inject a custom repository implementation.
`void` `setEvaluationContextProvider(QueryMethodEvaluationContextProvider evaluationContextProvider)` Sets the `QueryMethodEvaluationContextProvider` 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 the `MappingContext` to be used to lookup `PersistentEntity` instances for `getPersistentEntity()`.
`void` `setNamedQueries(NamedQueries namedQueries)` Setter to inject a `NamedQueries` instance.
`void` `setQueryLookupStrategyKey(QueryLookupStrategy.Key queryLookupStrategyKey)` Set the `QueryLookupStrategy.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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### RepositoryFactoryBeanSupport

    protected RepositoryFactoryBeanSupport(Class<? extends T> repositoryInterface)

Creates a new `RepositoryFactoryBeanSupport` for the given repository interface.

Parameters:
  `repositoryInterface` - must not be null.

### Method Detail

#### 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 `BeanClassLoaderAware`

#### setBeanFactory

    public void setBeanFactory(BeanFactory beanFactory)
                        throws BeansException

Specified by:
  `setBeanFactory` in interface `BeanFactoryAware`
Throws:
  `BeansException`

#### createDefaultQueryMethodEvaluationContextProvider

    protected Optional<QueryMethodEvaluationContextProvider> createDefaultQueryMethodEvaluationContextProvider(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(ApplicationEventPublisher publisher)

Specified by:
  `setApplicationEventPublisher` in interface `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<S,ID>`
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<S,ID>`
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<S,ID>`
Returns:

#### getQueryMethods

    public List<QueryMethod> getQueryMethods()

Description copied from interface: `RepositoryFactoryInformation`
Returns all `QueryMethod`s declared for that repository.

Specified by:
  `getQueryMethods` in interface `RepositoryFactoryInformation<S,ID>`
Returns:

#### getObject

    @Nonnull
    public T getObject()

Specified by:
  `getObject` in interface `FactoryBean<T extends Repository<S,ID>>`

#### getObjectType

    @Nonnull
    public Class<? extends T> getObjectType()

Specified by:
  `getObjectType` in interface `FactoryBean<T extends Repository<S,ID>>`

#### isSingleton

    public boolean isSingleton()

Specified by:
  `isSingleton` in interface `FactoryBean<T extends Repository<S,ID>>`

#### afterPropertiesSet

    public void afterPropertiesSet()

Specified by:
  `afterPropertiesSet` in interface `InitializingBean`

#### createRepositoryFactory

    protected abstract RepositoryFactorySupport createRepositoryFactory()

Create the actual `RepositoryFactorySupport` instance.

Returns: