diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/Repository.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/Repository.java index a20ec8415..d027868ef 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/Repository.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/Repository.java @@ -101,7 +101,7 @@ public interface Repository { /** - * Deletes all entities managed by the DAO. + * Deletes all entities managed by the repository. */ void deleteAll(); } diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/config/AbstractRepositoryConfigDefinitionParser.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/config/AbstractRepositoryConfigDefinitionParser.java index 75f1aaa84..1af45d9f3 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/config/AbstractRepositoryConfigDefinitionParser.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/config/AbstractRepositoryConfigDefinitionParser.java @@ -64,7 +64,7 @@ public abstract class AbstractRepositoryConfigDefinitionParser PET_POST_PROCESSOR = PersistenceExceptionTranslationPostProcessor.class; - private static final String DAO_INTERFACE_POST_PROCESSOR = + private static final String REPOSITORY_INTERFACE_POST_PROCESSOR = "org.springframework.data.repository.support.RepositoryInterfaceAwareBeanPostProcessor"; @@ -111,14 +111,15 @@ public abstract class AbstractRepositoryConfigDefinitionParser repositoryInterfaces = getRepositoryInterfacesForAutoConfig(config, resourceLoader, parser.getReaderContext()); - for (String daoInterface : repositoryInterfaces) { - registerGenericRepositoryFactoryBean(parser, - config.getAutoconfigRepositoryInformation(daoInterface)); + for (String repositoryInterface : repositoryInterfaces) { + registerGenericRepositoryFactoryBean( + parser, + config.getAutoconfigRepositoryInformation(repositoryInterface)); } } @@ -168,8 +169,9 @@ public abstract class AbstractRepositoryConfigDefinitionParser, S extends CommonRepositoryConfigInformation> implements GlobalRepositoryConfigInformation { - public static final String DEFAULT_DAO_IMPL_POSTFIX = "Impl"; + public static final String DEFAULT_REPOSITORY_IMPL_POSTFIX = "Impl"; public static final String QUERY_LOOKUP_STRATEGY = "query-lookup-strategy"; public static final String BASE_PACKAGE = "base-package"; - public static final String REPOSITORY_IMPL_POSTFIX = "dao-impl-postfix"; + public static final String REPOSITORY_IMPL_POSTFIX = + "repository-impl-postfix"; public static final String REPOSITORY_FACTORY_CLASS_NAME = "factory-class"; public static final String TRANSACTION_MANAGER_REF = "transaction-manager-ref"; @@ -153,7 +154,7 @@ public abstract class RepositoryConfig> this.factory = createRepositoryFactory(); this.factory.setQueryLookupStrategyKey(queryLookupStrategyKey); this.factory.validate(repositoryInterface, customImplementation); - this.factory.addDaoProxyPostProcessor(txPostProcessor); + this.factory.addRepositoryProxyPostProcessor(txPostProcessor); } diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryFactorySupport.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryFactorySupport.java index 92566ccb4..bc00e6b63 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryFactorySupport.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryFactorySupport.java @@ -79,7 +79,7 @@ public abstract class RepositoryFactorySupport { * * @param processor */ - protected void addDaoProxyPostProcessor( + protected void addRepositoryProxyPostProcessor( RepositoryProxyPostProcessor processor) { Assert.notNull(processor); @@ -107,14 +107,14 @@ public abstract class RepositoryFactorySupport { * * @param * @param repositoryInterface - * @param customDaoImplementation + * @param customImplementation * @return */ @SuppressWarnings("unchecked") public > T getRepository( - Class repositoryInterface, Object customDaoImplementation) { + Class repositoryInterface, Object customImplementation) { - validate(repositoryInterface, customDaoImplementation); + validate(repositoryInterface, customImplementation); Class domainClass = getDomainClass(repositoryInterface); RepositorySupport target = getTargetRepository(domainClass); @@ -129,7 +129,7 @@ public abstract class RepositoryFactorySupport { } result.addAdvice(new QueryExecuterMethodInterceptor( - repositoryInterface, customDaoImplementation, target)); + repositoryInterface, customImplementation, target)); return (T) result.getProxy(); } @@ -166,26 +166,26 @@ public abstract class RepositoryFactorySupport { /** - * Returns if the configured DAO interface has custom methods, that might - * have to be delegated to a custom DAO implementation. This is used to - * verify DAO configuration. + * Returns if the configured repository interface has custom methods, that + * might have to be delegated to a custom implementation. This is used to + * verify repository configuration. * * @return */ private boolean hasCustomMethod( - Class> daoInterface) { + Class> repositoryInterface) { boolean hasCustomMethod = false; // No detection required if no typing interface was configured - if (isGenericRepositoryInterface(daoInterface)) { + if (isGenericRepositoryInterface(repositoryInterface)) { return false; } - for (Method method : daoInterface.getMethods()) { + for (Method method : repositoryInterface.getMethods()) { - if (isCustomMethod(method, daoInterface) - && !isBaseClassMethod(method, daoInterface)) { + if (isCustomMethod(method, repositoryInterface) + && !isBaseClassMethod(method, repositoryInterface)) { return true; } } @@ -195,34 +195,39 @@ public abstract class RepositoryFactorySupport { /** - * Returns whether the given method is considered to be a DAO base class - * method. + * Returns whether the given method is considered to be a repository base + * class method. * * @param method + * @param repositoryInterface * @return */ - private boolean isBaseClassMethod(Method method, Class daoInterface) { + private boolean isBaseClassMethod(Method method, + Class repositoryInterface) { Assert.notNull(method); - if (method.getDeclaringClass().isAssignableFrom(getRepositoryClass())) { + if (method.getDeclaringClass().isAssignableFrom( + getRepositoryClass(repositoryInterface))) { return true; } - return !method.equals(getBaseClassMethod(method, daoInterface)); + return !method.equals(getBaseClassMethod(method, repositoryInterface)); } /** * Returns the base class method that is backing the given method. This can - * be necessary if a DAO interface redeclares a method in {@link GenericDao} - * (e.g. for transaction behaviour customization). Returns the method itself - * if the base class does not implement the given method. + * be necessary if a repository interface redeclares a method in + * {@link Repository} (e.g. for transaction behaviour customization). + * Returns the method itself if the base class does not implement the given + * method. * * @param method * @return */ - private Method getBaseClassMethod(Method method, Class daoInterface) { + private Method getBaseClassMethod(Method method, + Class repositoryInterface) { Assert.notNull(method); @@ -234,7 +239,7 @@ public abstract class RepositoryFactorySupport { result = getBaseClassMethodFor(method, getRepositoryClass(), - daoInterface); + repositoryInterface); methodCache.put(method, result); return result; @@ -242,38 +247,39 @@ public abstract class RepositoryFactorySupport { /** - * Returns whether the given method is a custom DAO method. + * Returns whether the given method is a custom repository method. * * @param method - * @param daoInterface + * @param repositoryInterface * @return */ - private boolean isCustomMethod(Method method, Class daoInterface) { + private boolean isCustomMethod(Method method, Class repositoryInterface) { Class declaringClass = method.getDeclaringClass(); - boolean isQueryMethod = declaringClass.equals(daoInterface); - boolean isHadesDaoInterface = + boolean isQueryMethod = declaringClass.equals(repositoryInterface); + boolean isRepositoryInterface = isGenericRepositoryInterface(declaringClass); - boolean isBaseClassMethod = isBaseClassMethod(method, daoInterface); + boolean isBaseClassMethod = + isBaseClassMethod(method, repositoryInterface); - return !(isHadesDaoInterface || isBaseClassMethod || isQueryMethod); + return !(isRepositoryInterface || isBaseClassMethod || isQueryMethod); } /** * Returns all methods considered to be finder methods. * - * @param daoInterface + * @param repositoryInterface * @return */ - private Iterable getFinderMethods(Class daoInterface) { + private Iterable getFinderMethods(Class repositoryInterface) { Set result = new HashSet(); - for (Method method : daoInterface.getDeclaredMethods()) { - if (!isCustomMethod(method, daoInterface) - && !isBaseClassMethod(method, daoInterface)) { + for (Method method : repositoryInterface.getDeclaredMethods()) { + if (!isCustomMethod(method, repositoryInterface) + && !isBaseClassMethod(method, repositoryInterface)) { result.add(method); } } @@ -285,13 +291,13 @@ public abstract class RepositoryFactorySupport { /** * Validates the given repository interface. * - * @param daoInterface + * @param repositoryInterface */ - private void validate(Class daoInterface) { + private void validate(Class repositoryInterface) { - Assert.notNull(daoInterface); + Assert.notNull(repositoryInterface); Assert.notNull( - getDomainClass(daoInterface), + getDomainClass(repositoryInterface), "Could not retrieve domain class from interface. Make sure it extends GenericRepository."); } diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryInterfaceAwareBeanPostProcessor.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryInterfaceAwareBeanPostProcessor.java index a5842e0ea..c7a6a2226 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryInterfaceAwareBeanPostProcessor.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryInterfaceAwareBeanPostProcessor.java @@ -29,9 +29,10 @@ import org.springframework.util.ClassUtils; * A * {@link org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor} * implementing {@code #predictBeanType(Class, String)} to return the configured - * DAO interface from {@link GenericDaoFactoryBean}s. This is done as shortcut - * to prevent the need of instantiating {@link GenericDaoFactoryBean}s just to - * find out what DAO interface they actually create. + * repository interface from {@link RepositoryFactoryBeanSupport}s. This is done + * as shortcut to prevent the need of instantiating + * {@link RepositoryFactoryBeanSupport}s just to find out what repository + * interface they actually create. * * @author Oliver Gierke */ @@ -39,7 +40,7 @@ class RepositoryInterfaceAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements BeanFactoryAware { private static final Class REPOSITORY_TYPE = - RepositoryFactoryBeanSupport.class; + RepositoryFactoryBeanSupport.class; private ConfigurableListableBeanFactory context; @@ -54,7 +55,6 @@ class RepositoryInterfaceAwareBeanPostProcessor extends public void setBeanFactory(BeanFactory beanFactory) { if (beanFactory instanceof ConfigurableListableBeanFactory) { - this.context = (ConfigurableListableBeanFactory) beanFactory; } } @@ -76,7 +76,8 @@ class RepositoryInterfaceAwareBeanPostProcessor extends BeanDefinition definition = context.getBeanDefinition(beanName); PropertyValue value = - definition.getPropertyValues().getPropertyValue("repositoryInterface"); + definition.getPropertyValues().getPropertyValue( + "repositoryInterface"); return getClassForPropertyValue(value); } @@ -107,7 +108,8 @@ class RepositoryInterfaceAwareBeanPostProcessor extends try { return ClassUtils.resolveClassName(className, - RepositoryInterfaceAwareBeanPostProcessor.class.getClassLoader()); + RepositoryInterfaceAwareBeanPostProcessor.class + .getClassLoader()); } catch (IllegalArgumentException ex) { return null; } diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryProxyPostProcessor.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryProxyPostProcessor.java index 4f931000e..4813aace7 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryProxyPostProcessor.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositoryProxyPostProcessor.java @@ -19,8 +19,8 @@ import org.springframework.aop.framework.ProxyFactory; /** - * Callback interface used during DAO proxy creation. Allows manipulating the - * {@link ProxyFactory} creating the DAO. + * Callback interface used during repository proxy creation. Allows manipulating + * the {@link ProxyFactory} creating the repository. * * @author Oliver Gierke */ diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/TransactionalRepositoryProxyPostProcessor.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/TransactionalRepositoryProxyPostProcessor.java index 36a30fe16..c807d6a13 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/TransactionalRepositoryProxyPostProcessor.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/TransactionalRepositoryProxyPostProcessor.java @@ -24,9 +24,9 @@ import org.springframework.util.Assert; /** - * {@link DaoProxyPostProcessor} to add transactional behaviour to DAO proxies. - * Adds a {@link PersistenceExceptionTranslationInterceptor} as well as an - * annotation based {@link TransactionInterceptor} to the proxy. + * {@link RepositoryProxyPostProcessor} to add transactional behaviour to + * repository proxies. Adds a {@link PersistenceExceptionTranslationInterceptor} + * as well as an annotation based {@link TransactionInterceptor} to the proxy. * * @author Oliver Gierke */ @@ -64,8 +64,8 @@ class TransactionalRepositoryProxyPostProcessor implements * (non-Javadoc) * * @see - * org.synyx.hades.dao.orm.DaoProxyPostProcessor#postProcess(org.springframework - * .aop.framework.ProxyFactory) + * org.springframework.data.repository.support.RepositoryProxyPostProcessor + * #postProcess(org.springframework.aop.framework.ProxyFactory) */ public void postProcess(ProxyFactory factory) {