public abstract class RepositoryConfigurationExtensionSupport extends Object implements RepositoryConfigurationExtension
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.| Constructor and Description |
|---|
RepositoryConfigurationExtensionSupport() |
| Modifier and Type | Method and Description |
|---|---|
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> |
getRepositoryConfiguration(BeanDefinition definition,
T configSource)
Creates a actual
RepositoryConfiguration instance for the given RepositoryConfigurationSource and
interface name. |
<T extends RepositoryConfigurationSource> |
getRepositoryConfigurations(T configSource,
ResourceLoader loader) |
<T extends RepositoryConfigurationSource> |
getRepositoryConfigurations(T configSource,
ResourceLoader loader,
boolean strictMatchesOnly)
Returns all
RepositoryConfigurations 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetRepositoryFactoryBeanClassNamepublic RepositoryConfigurationExtensionSupport()
public String getModuleName()
RepositoryConfigurationExtensiongetModuleName in interface RepositoryConfigurationExtensionpublic <T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>> getRepositoryConfigurations(T configSource, ResourceLoader loader)
public <T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>> getRepositoryConfigurations(T configSource, ResourceLoader loader, boolean strictMatchesOnly)
RepositoryConfigurationExtensionRepositoryConfigurations obtained through the given RepositoryConfigurationSource.getRepositoryConfigurations in interface RepositoryConfigurationExtensionstrictMatchesOnly - 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.public String getDefaultNamedQueryLocation()
RepositoryConfigurationExtensiongetDefaultNamedQueryLocation in interface RepositoryConfigurationExtensionpublic void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource configurationSource)
RepositoryConfigurationExtensionregisterBeansForRoot in interface RepositoryConfigurationExtensionprotected abstract String getModulePrefix()
public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source)
RepositoryConfigurationExtensionBeanDefinition and tweak the configuration if necessary.postProcess in interface RepositoryConfigurationExtensionbuilder - will never be null.source - will never be null.public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config)
RepositoryConfigurationExtensionBeanDefinition built from annotations and tweak the configuration if
necessary.postProcess in interface RepositoryConfigurationExtensionbuilder - will never be null.config - will never be null.public void postProcess(BeanDefinitionBuilder builder, XmlRepositoryConfigurationSource config)
RepositoryConfigurationExtensionBeanDefinition built from XML and tweak the configuration if necessary.postProcess in interface RepositoryConfigurationExtensionbuilder - will never be null.config - will never be null.protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations()
protected Collection<Class<?>> getIdentifyingTypes()
@Nullable protected ClassLoader getConfigurationInspectionClassLoader(ResourceLoader loader)
ClassLoader to load repository interfaces for configuration inspection. Subclasses may override
this method to provide a customized class loader.loader - must not be null.ClassLoader for repository interfaces configuration inspection.public static String registerWithSourceAndGeneratedBeanName(AbstractBeanDefinition bean, BeanDefinitionRegistry registry, Object source)
AbstractBeanDefinition and registers it inside the given
BeanDefinitionRegistry. For BeanDefinitions 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.bean - must not be null.registry - must not be null.source - must not be null.BeanDefinitionpublic static void registerIfNotAlreadyRegistered(Supplier<AbstractBeanDefinition> supplier, BeanDefinitionRegistry registry, String beanName, Object source)
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.supplier - must not be null.registry - must not be null.beanName - must not be null or empty.source - must not be null.public static void registerLazyIfNotAlreadyRegistered(Supplier<AbstractBeanDefinition> supplier, BeanDefinitionRegistry registry, String beanName, Object source)
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.supplier - must not be null.registry - must not be null.beanName - must not be null or empty.source - must not be null.public static boolean hasBean(Class<?> type, BeanDefinitionRegistry registry)
BeanDefinitionRegistry already contains a bean of the given type assuming the
bean name has been auto-generated.type - registry - protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T> getRepositoryConfiguration(BeanDefinition definition, T configSource)
RepositoryConfiguration instance for the given RepositoryConfigurationSource and
interface name. Defaults to the DefaultRepositoryConfiguration but allows sub-classes to override this to
customize the behavior.definition - will never be null or empty.configSource - will never be null.protected boolean isStrictRepositoryCandidate(RepositoryMetadata metadata)
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.metadata - protected boolean useRepositoryConfiguration(RepositoryMetadata metadata)
InvalidDataAccessApiUsageException for reactive
repositories. Must be overridden by store modules that wish to provide reactive repositories.metadata - will never be null.InvalidDataAccessApiUsageException - on repositories by
default.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.