Spring Data Commons

org.springframework.data.repository.config
Class RepositoryConfigurationExtensionSupport

java.lang.Object
  extended by 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

Field Summary
protected static String REPOSITORY_INTERFACE_POST_PROCESSOR
           
 
Constructor Summary
RepositoryConfigurationExtensionSupport()
           
 
Method Summary
 String getDefaultNamedQueryLocation()
          Returns the default location of the Spring Data named queries.
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(String interfaceName, 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)
          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 autogenerated.
 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, 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 String registerWithSourceAndGeneratedBeanName(BeanDefinitionRegistry registry, AbstractBeanDefinition bean, Object source)
          Sets the given source on the given AbstractBeanDefinition and registers it inside the given BeanDefinitionRegistry.
 
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
getRepositoryFactoryClassName
 

Field Detail

REPOSITORY_INTERFACE_POST_PROCESSOR

protected static final String REPOSITORY_INTERFACE_POST_PROCESSOR
See Also:
Constant Field Values
Constructor Detail

RepositoryConfigurationExtensionSupport

public RepositoryConfigurationExtensionSupport()
Method Detail

getRepositoryConfigurations

public <T extends RepositoryConfigurationSource> Collection<RepositoryConfiguration<T>> getRepositoryConfigurations(T configSource,
                                                                                                                    ResourceLoader loader)
Description copied from interface: RepositoryConfigurationExtension
Returns all RepositoryConfigurations obtained through the given RepositoryConfigurationSource.

Specified by:
getRepositoryConfigurations in interface RepositoryConfigurationExtension
Parameters:
configSource - must not be null.
loader - must not be null.
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,
                        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.

registerWithSourceAndGeneratedBeanName

public static String registerWithSourceAndGeneratedBeanName(BeanDefinitionRegistry registry,
                                                            AbstractBeanDefinition bean,
                                                            Object source)
Sets the given source on the given AbstractBeanDefinition and registers it inside the given BeanDefinitionRegistry.

Parameters:
registry -
bean -
source -
Returns:

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 autogenerated.

Parameters:
type -
registry -
Returns:

getRepositoryConfiguration

protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T> getRepositoryConfiguration(String interfaceName,
                                                                                                          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 behaviour.

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

Spring Data Commons

Copyright © 2012. All Rights Reserved.