org.springframework.data.repository.config

## Class RepositoryConfigurationExtensionSupport

- java.lang.Object
- - org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport

All Implemented Interfaces:
  RepositoryConfigurationExtension

    public abstract class RepositoryConfigurationExtensionSupport
    extends Object
    implements RepositoryConfigurationExtension

Base implementation of `RepositoryConfigurationExtension` to ease the implementation of the interface. Will default the default named query location based on a module prefix provided by implementors (see `getModulePrefix()`). Stubs out the post-processing methods as they might not be needed by default.

Author:
  Oliver Gierke, Mark Paluch, Christoph Strobl

### Constructor Summary

Constructors
Constructor and Description
`RepositoryConfigurationExtensionSupport()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`protected ClassLoader` `getConfigurationInspectionClassLoader(ResourceLoader loader)` Returns the `ClassLoader` to load repository interfaces for configuration inspection.
`String` `getDefaultNamedQueryLocation()` Returns the default location of the Spring Data named queries.
`protected Collection<Class<? extends Annotation>>` `getIdentifyingAnnotations()` Return the annotations to scan domain types for when evaluating repository interfaces for store assignment.
`protected Collection<Class<?>>` `getIdentifyingTypes()` Returns the types that indicate a store match when inspecting repositories for strict matches.
`String` `getModuleName()` Returns the descriptive name of the module.
`protected abstract String` `getModulePrefix()` Returns the prefix of the module to be used to create the default location for Spring Data named queries.
`protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T>` `getRepositoryConfiguration(BeanDefinition definition, T configSource)` Creates a actual `RepositoryConfiguration` instance for the given `RepositoryConfigurationSource` and interface name.
`<T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>>` `getRepositoryConfigurations(T configSource, ResourceLoader loader)`
`<T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>>` `getRepositoryConfigurations(T configSource, ResourceLoader loader, boolean strictMatchesOnly)` Returns all `RepositoryConfiguration`s obtained through the given `RepositoryConfigurationSource`.
`static boolean` `hasBean(Class<?> type, BeanDefinitionRegistry registry)` Returns whether the given `BeanDefinitionRegistry` already contains a bean of the given type assuming the bean name has been auto-generated.
`protected boolean` `isStrictRepositoryCandidate(RepositoryMetadata metadata)` Returns whether the given repository metadata is a candidate for bean definition creation in the strict repository detection mode.
`void` `postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config)` Callback to post process the `BeanDefinition` built from annotations and tweak the configuration if necessary.
`void` `postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source)` Callback to post process the `BeanDefinition` and tweak the configuration if necessary.
`void` `postProcess(BeanDefinitionBuilder builder, XmlRepositoryConfigurationSource config)` Callback to post process the `BeanDefinition` built from XML and tweak the configuration if necessary.
`void` `registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource)` Callback to register additional bean definitions for a repositories root node.
`static void` `registerIfNotAlreadyRegistered(Supplier<AbstractBeanDefinition> supplier, BeanDefinitionRegistry registry, String beanName, Object source)` Registers the `AbstractBeanDefinition` produced by the given `Supplier` with the given registry with the given bean name unless the registry already contains a bean with that name.
`static void` `registerLazyIfNotAlreadyRegistered(Supplier<AbstractBeanDefinition> supplier, BeanDefinitionRegistry registry, String beanName, Object source)` Registers the `AbstractBeanDefinition` produced by the given `Supplier` as lazy bean definition with the given registry with the given bean name unless the registry already contains a bean with that name.
`static String` `registerWithSourceAndGeneratedBeanName(AbstractBeanDefinition bean, BeanDefinitionRegistry registry, Object source)` Sets the given source on the given `AbstractBeanDefinition` and registers it inside the given `BeanDefinitionRegistry`.
`protected boolean` `useRepositoryConfiguration(RepositoryMetadata metadata)` Return whether to use the configuration for the repository with the given metadata.

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

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

### Methods inherited from interface org.springframework.data.repository.config.RepositoryConfigurationExtension

`getRepositoryFactoryBeanClassName`

### Constructor Detail

#### RepositoryConfigurationExtensionSupport

    public RepositoryConfigurationExtensionSupport()

### Method Detail

#### getModuleName

    public String getModuleName()

Description copied from interface: `RepositoryConfigurationExtension`
Returns the descriptive name of the module.

Specified by:
  `getModuleName` in interface `RepositoryConfigurationExtension`
Returns:

#### getRepositoryConfigurations

    public <T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>> getRepositoryConfigurations(T configSource,
                                                                                                                        ResourceLoader loader)

#### getRepositoryConfigurations

    public <T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>> getRepositoryConfigurations(T configSource,
                                                                                                                        ResourceLoader loader,
                                                                                                                        boolean strictMatchesOnly)

Description copied from interface: `RepositoryConfigurationExtension`
Returns all `RepositoryConfiguration`s obtained through the given `RepositoryConfigurationSource`.

Specified by:
  `getRepositoryConfigurations` in interface `RepositoryConfigurationExtension`
  `strictMatchesOnly` - whether to return strict repository matches only. Handing in true will cause the repository interfaces and domain types handled to be checked whether they are managed by the current store.
Returns:

#### getDefaultNamedQueryLocation

    public String getDefaultNamedQueryLocation()

Description copied from interface: `RepositoryConfigurationExtension`
Returns the default location of the Spring Data named queries.

Specified by:
  `getDefaultNamedQueryLocation` in interface `RepositoryConfigurationExtension`
Returns:
  must not be null or empty.

#### registerBeansForRoot

    public void registerBeansForRoot(BeanDefinitionRegistry registry,
                                     RepositoryConfigurationSource configurationSource)

Description copied from interface: `RepositoryConfigurationExtension`
Callback to register additional bean definitions for a repositories root node. This usually includes beans you have to set up once independently of the number of repositories to be created. Will be called before any repositories bean definitions have been registered.

Specified by:
  `registerBeansForRoot` in interface `RepositoryConfigurationExtension`

#### getModulePrefix

    protected abstract String getModulePrefix()

Returns the prefix of the module to be used to create the default location for Spring Data named queries.

Returns:
  must not be null.

#### postProcess

    public void postProcess(BeanDefinitionBuilder builder,
                            RepositoryConfigurationSource source)

Description copied from interface: `RepositoryConfigurationExtension`
Callback to post process the `BeanDefinition` and tweak the configuration if necessary.

Specified by:
  `postProcess` in interface `RepositoryConfigurationExtension`
Parameters:
  `builder` - will never be null.
  `source` - will never be null.

#### postProcess

    public void postProcess(BeanDefinitionBuilder builder,
                            AnnotationRepositoryConfigurationSource config)

Description copied from interface: `RepositoryConfigurationExtension`
Callback to post process the `BeanDefinition` built from annotations and tweak the configuration if necessary.

Specified by:
  `postProcess` in interface `RepositoryConfigurationExtension`
Parameters:
  `builder` - will never be null.
  `config` - will never be null.

#### postProcess

    public void postProcess(BeanDefinitionBuilder builder,
                            XmlRepositoryConfigurationSource config)

Description copied from interface: `RepositoryConfigurationExtension`
Callback to post process the `BeanDefinition` built from XML and tweak the configuration if necessary.

Specified by:
  `postProcess` in interface `RepositoryConfigurationExtension`
Parameters:
  `builder` - will never be null.
  `config` - will never be null.

#### getIdentifyingAnnotations

    protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations()

Return the annotations to scan domain types for when evaluating repository interfaces for store assignment. Modules should return the annotations that identify a domain type as managed by the store explicitly.

Returns:
Since:
  1.9

#### getIdentifyingTypes

    protected Collection<Class<?>> getIdentifyingTypes()

Returns the types that indicate a store match when inspecting repositories for strict matches.

Returns:
Since:
  1.9

#### getConfigurationInspectionClassLoader

    @Nullable
    protected ClassLoader getConfigurationInspectionClassLoader(ResourceLoader loader)

Returns the `ClassLoader` to load repository interfaces for configuration inspection. Subclasses may override this method to provide a customized class loader.

Parameters:
  `loader` - must not be null.
Returns:
  the `ClassLoader` for repository interfaces configuration inspection.
Since:
  2.1

#### registerWithSourceAndGeneratedBeanName

    public static String registerWithSourceAndGeneratedBeanName(AbstractBeanDefinition bean,
                                                                BeanDefinitionRegistry registry,
                                                                Object source)

Sets the given source on the given `AbstractBeanDefinition` and registers it inside the given `BeanDefinitionRegistry`. For `BeanDefinition`s to be registered once-and-only-once for all configuration elements (annotation or XML), prefer calling `registerIfNotAlreadyRegistered(Supplier, BeanDefinitionRegistry, String, Object)` with a dedicated bean name to avoid the bead definition being registered multiple times.

Parameters:
  `bean` - must not be null.
  `registry` - must not be null.
  `source` - must not be null.
Returns:
  the bean name generated for the given `BeanDefinition`

#### registerIfNotAlreadyRegistered

    public static void registerIfNotAlreadyRegistered(Supplier<AbstractBeanDefinition> supplier,
                                                      BeanDefinitionRegistry registry,
                                                      String beanName,
                                                      Object source)

Registers the `AbstractBeanDefinition` produced by the given `Supplier` with the given registry with the given bean name unless the registry already contains a bean with that name.

Parameters:
  `supplier` - must not be null.
  `registry` - must not be null.
  `beanName` - must not be null or empty.
  `source` - must not be null.
Since:
  2.1

#### registerLazyIfNotAlreadyRegistered

    public static void registerLazyIfNotAlreadyRegistered(Supplier<AbstractBeanDefinition> supplier,
                                                          BeanDefinitionRegistry registry,
                                                          String beanName,
                                                          Object source)

Registers the `AbstractBeanDefinition` produced by the given `Supplier` as lazy bean definition with the given registry with the given bean name unless the registry already contains a bean with that name.

Parameters:
  `supplier` - must not be null.
  `registry` - must not be null.
  `beanName` - must not be null or empty.
  `source` - must not be null.
Since:
  2.1

#### hasBean

    public static boolean hasBean(Class<?> type,
                                  BeanDefinitionRegistry registry)

Returns whether the given `BeanDefinitionRegistry` already contains a bean of the given type assuming the bean name has been auto-generated.

Parameters:
  `type` -
  `registry` -
Returns:

#### getRepositoryConfiguration

    protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T> getRepositoryConfiguration(BeanDefinition definition,
                                                                                                              T configSource)

Creates a actual `RepositoryConfiguration` instance for the given `RepositoryConfigurationSource` and interface name. Defaults to the `DefaultRepositoryConfiguration` but allows sub-classes to override this to customize the behavior.

Parameters:
  `definition` - will never be null or empty.
  `configSource` - will never be null.
Returns:

#### isStrictRepositoryCandidate

    protected boolean isStrictRepositoryCandidate(RepositoryMetadata metadata)

Returns whether the given repository metadata is a candidate for bean definition creation in the strict repository detection mode. The default implementation inspects the domain type managed for a set of well-known annotations (see `getIdentifyingAnnotations()`). If none of them is found, the candidate is discarded. Implementations should make sure, the only return true if they're really sure the interface handed to the method is really a store interface.

Parameters:
  `metadata` -
Returns:
Since:
  1.9

#### useRepositoryConfiguration

    protected boolean useRepositoryConfiguration(RepositoryMetadata metadata)

Return whether to use the configuration for the repository with the given metadata. Defaults to true and `InvalidDataAccessApiUsageException` for `reactive repositories`. Must be overridden by store modules that wish to provide reactive repositories.

Parameters:
  `metadata` - will never be null.
Returns:
Throws:
  `InvalidDataAccessApiUsageException` - on `repositories` by default.