Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: spring-projects/spring-data-commons
...
head fork: jonbcard/spring-data-commons
Checking mergeability… Don’t worry, you can still create the pull request.
  • 11 commits
  • 18 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 12, 2012
@spring-buildmaster spring-buildmaster DATACMNS-192 - Prepare next development iteration. 8007e25
@olivergierke olivergierke DATACMNS-168 - Allow customizing repository bean names.
The bean name is now resolved through inspecting Spring stereotype annotations and @Named on the repository interface. If none found we're still using the uncapitalized simple interface name as we did until now.
b4a553e
Commits on Nov 13, 2012
@olivergierke olivergierke DATACMNS-247 - Improved implementation of RepositoryBeanDefinitionReg…
…istrarSupport.

RepositoryBeanDefinitionRegistrarSupport not implements BeanClassLoaderAware and ResourceLoaderAware as Spring 3.2 will regard these callback interfaces and inject the resources. We still default these injected resources upon invocation to be able to run on Spring 3.1 as well.
c523abe
Commits on Nov 27, 2012
@olivergierke olivergierke DATACMNS-253 - Improved exception message in ParameterOutOfBoundsExce…
…ption.
fe8e484
@olivergierke olivergierke DATACMNS-254 - Polished JavaDoc of Auditable. 5664554
Commits on Nov 29, 2012
@olivergierke olivergierke DATACMNS-257 - PropertyPath can now handle all-uppercase fields.
So far, PropertyPath inevitably uncapitalized the property names it was created for. We now check, whether the source name is all uppercase and prevent uncapitalization in this case.
3fd47ee
Commits on Jan 05, 2013
@olivergierke olivergierke DATACMNS-263 - Fixed incompatibility with OpenWebbeans < 1.1.8.
Prefer using non-anonymous inner classes to represent @Default and @Any qualifiers. Upgraded to OpenWebbeans 1.1.7 along the way.
5266a9a
Commits on Jan 29, 2013
@olivergierke olivergierke DATACMNS-276 - Added hashCode() to ParameterizedTypeInformation.
Implemented hashCode() to be as close as possible to the equals(…) implementation.
3e2ae83
Commits on Feb 07, 2013
@olivergierke olivergierke DATACMNS-280 - Prepare release of version 1.4.1. 8289e17
@spring-buildmaster spring-buildmaster DATACMNS-280 - Release version 1.4.1.RELEASE. 2622232
@spring-buildmaster spring-buildmaster DATACMNS-280 - Prepare next development iteration. 4f67c4b
Showing with 320 additions and 28 deletions.
  1. +1 −1  pom.xml
  2. +2 −2 spring-data-commons-core/pom.xml
  3. +1 −1  spring-data-commons-core/src/main/java/org/springframework/data/domain/Auditable.java
  4. +2 −1  spring-data-commons-core/src/main/java/org/springframework/data/mapping/PropertyPath.java
  5. +17 −6 ...-data-commons-core/src/main/java/org/springframework/data/repository/cdi/CdiRepositoryExtensionSupport.java
  6. +8 −3 ...a-commons-core/src/main/java/org/springframework/data/repository/config/RepositoryBeanDefinitionParser.java
  7. +68 −3 ...core/src/main/java/org/springframework/data/repository/config/RepositoryBeanDefinitionRegistrarSupport.java
  8. +80 −0 ...data-commons-core/src/main/java/org/springframework/data/repository/config/RepositoryBeanNameGenerator.java
  9. +3 −0  spring-data-commons-core/src/main/java/org/springframework/data/repository/config/RepositoryConfiguration.java
  10. +4 −4 ...ata-commons-core/src/main/java/org/springframework/data/repository/query/ParameterOutOfBoundsException.java
  11. +3 −2 spring-data-commons-core/src/main/java/org/springframework/data/repository/query/Parameters.java
  12. +9 −0 spring-data-commons-core/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java
  13. +28 −1 spring-data-commons-core/src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java
  14. +0 −1  ...-core/src/test/java/org/springframework/data/repository/config/DefaultRepositoryConfigurationUnitTests.java
  15. +77 −0 ...mons-core/src/test/java/org/springframework/data/repository/config/RepositoryBeanNameGeneratorUnitTest.java
  16. +1 −1  spring-data-commons-parent/pom.xml
  17. +14 −0 src/main/resources/changelog.txt
  18. +2 −2 src/main/resources/notice.txt
View
2  pom.xml
@@ -6,7 +6,7 @@
<name>Spring Data Commons Distribution</name>
<description>Spring Data Commons</description>
<url>http://www.springsource.org/spring-data</url>
- <version>1.4.0.RELEASE</version>
+ <version>1.4.2.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
View
4 spring-data-commons-core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-parent</artifactId>
- <version>1.4.0.RELEASE</version>
+ <version>1.4.2.BUILD-SNAPSHOT</version>
<relativePath>../spring-data-commons-parent/pom.xml</relativePath>
</parent>
@@ -15,8 +15,8 @@
<properties>
<querydsl.version>2.8.0</querydsl.version>
<cdi.version>1.0</cdi.version>
- <webbeans.version>1.1.3</webbeans.version>
<jackson.version>1.9.7</jackson.version>
+ <webbeans.version>1.1.7</webbeans.version>
</properties>
<dependencies>
View
2  spring-data-commons-core/src/main/java/org/springframework/data/domain/Auditable.java
@@ -24,7 +24,7 @@
* instance (typically some user) is to be defined by a generics definition.
*
* @param <U> the auditing type. Typically some kind of user.
- * @param <ID> the type of the auditing type's idenifier
+ * @param <ID> the type of the audited type's identifier
* @author Oliver Gierke
*/
public interface Auditable<U, ID extends Serializable> extends Persistable<ID> {
View
3  spring-data-commons-core/src/main/java/org/springframework/data/mapping/PropertyPath.java
@@ -35,6 +35,7 @@
public class PropertyPath implements Iterable<PropertyPath> {
private static final String DELIMITERS = "_\\.";
+ private static final String ALL_UPPERCASE = "[A-Z0-9._$]+";
private static final Pattern SPLITTER = Pattern.compile("(?:[%s]?([%s]*?[^%s]+))".replaceAll("%s", DELIMITERS));
private final TypeInformation<?> owningType;
@@ -67,7 +68,7 @@
Assert.hasText(name);
Assert.notNull(owningType);
- String propertyName = StringUtils.uncapitalize(name);
+ String propertyName = name.matches(ALL_UPPERCASE) ? name : StringUtils.uncapitalize(name);
TypeInformation<?> type = owningType.getProperty(propertyName);
if (type == null) {
View
23 .../src/main/java/org/springframework/data/repository/cdi/CdiRepositoryExtensionSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,7 +94,6 @@ private boolean isRepository(Class<?> type) {
/**
* Determines the qualifiers of the given type.
*/
- @SuppressWarnings("serial")
private Set<Annotation> getQualifiers(final Class<?> type) {
Set<Annotation> qualifiers = new HashSet<Annotation>();
@@ -105,14 +104,14 @@ private boolean isRepository(Class<?> type) {
qualifiers.add(annotation);
}
}
+
// Add @Default qualifier if no qualifier is specified.
if (qualifiers.isEmpty()) {
- qualifiers.add(new AnnotationLiteral<Default>() {
- });
+ qualifiers.add(DefaultAnnotationLiteral.INSTANCE);
}
+
// Add @Any qualifier.
- qualifiers.add(new AnnotationLiteral<Any>() {
- });
+ qualifiers.add(AnyAnnotationLiteral.INSTANCE);
return qualifiers;
}
@@ -124,4 +123,16 @@ private boolean isRepository(Class<?> type) {
protected Iterable<Entry<Class<?>, Set<Annotation>>> getRepositoryTypes() {
return repositoryTypes.entrySet();
}
+
+ private static class DefaultAnnotationLiteral extends AnnotationLiteral<Default> implements Default {
+
+ private static final long serialVersionUID = 511359421048623933L;
+ private static final DefaultAnnotationLiteral INSTANCE = new DefaultAnnotationLiteral();
+ }
+
+ private static class AnyAnnotationLiteral extends AnnotationLiteral<Any> implements Any {
+
+ private static final long serialVersionUID = 7261821376671361463L;
+ private static final AnyAnnotationLiteral INSTANCE = new AnyAnnotationLiteral();
+ }
}
View
11 .../main/java/org/springframework/data/repository/config/RepositoryBeanDefinitionParser.java
@@ -104,12 +104,17 @@ private void registerGenericRepositoryFactoryBean(
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
beanDefinition.setSource(configuration.getSource());
+ RepositoryBeanNameGenerator generator = new RepositoryBeanNameGenerator();
+ generator.setBeanClassLoader(parser.getReaderContext().getBeanClassLoader());
+
+ String beanName = generator.generateBeanName(beanDefinition, parser.getRegistry());
+
if (LOG.isDebugEnabled()) {
- LOG.debug("Registering repository: " + configuration.getBeanId() + " - Interface: "
- + configuration.getRepositoryInterface() + " - Factory: " + extension.getRepositoryFactoryClassName());
+ LOG.debug("Registering repository: " + beanName + " - Interface: " + configuration.getRepositoryInterface()
+ + " - Factory: " + extension.getRepositoryFactoryClassName());
}
- BeanComponentDefinition definition = new BeanComponentDefinition(beanDefinition, configuration.getBeanId());
+ BeanComponentDefinition definition = new BeanComponentDefinition(beanDefinition, beanName);
parser.registerBeanComponent(definition);
} catch (RuntimeException e) {
handleError(e, configuration.getConfigurationSource().getElement(), parser.getReaderContext());
View
71 .../org/springframework/data/repository/config/RepositoryBeanDefinitionRegistrarSupport.java
@@ -17,21 +17,45 @@
import java.lang.annotation.Annotation;
+import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
/**
* Base class to implement {@link ImportBeanDefinitionRegistrar}s to enable repository
*
* @author Oliver Gierke
*/
-public abstract class RepositoryBeanDefinitionRegistrarSupport implements ImportBeanDefinitionRegistrar {
+public abstract class RepositoryBeanDefinitionRegistrarSupport implements ImportBeanDefinitionRegistrar,
+ BeanClassLoaderAware, ResourceLoaderAware {
+
+ private ResourceLoader resourceLoader;
+ private ClassLoader beanClassLoader;
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.BeanClassLoaderAware#setBeanClassLoader(java.lang.ClassLoader)
+ */
+ public void setBeanClassLoader(ClassLoader classLoader) {
+ this.beanClassLoader = classLoader;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.context.ResourceLoaderAware#setResourceLoader(org.springframework.core.io.ResourceLoader)
+ */
+ public void setResourceLoader(ResourceLoader resourceLoader) {
+ this.resourceLoader = resourceLoader;
+ }
/*
* (non-Javadoc)
@@ -47,13 +71,17 @@ public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanD
return;
}
- ResourceLoader resourceLoader = new DefaultResourceLoader();
+ defaultExternalResources(registry);
+
AnnotationRepositoryConfigurationSource configuration = new AnnotationRepositoryConfigurationSource(
annotationMetadata, getAnnotation());
RepositoryConfigurationExtension extension = getExtension();
extension.registerBeansForRoot(registry, configuration);
+ RepositoryBeanNameGenerator generator = new RepositoryBeanNameGenerator();
+ generator.setBeanClassLoader(beanClassLoader);
+
for (RepositoryConfiguration<AnnotationRepositoryConfigurationSource> repositoryConfiguration : extension
.getRepositoryConfigurations(configuration, resourceLoader)) {
@@ -62,11 +90,48 @@ public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanD
extension.postProcess(definitionBuilder, configuration);
- registry.registerBeanDefinition(repositoryConfiguration.getBeanId(), definitionBuilder.getBeanDefinition());
+ String beanName = generator.generateBeanName(definitionBuilder.getBeanDefinition(), registry);
+ registry.registerBeanDefinition(beanName, definitionBuilder.getBeanDefinition());
}
}
/**
+ * Workaround the lack of injectability of external resources into {@link ImportBeanDefinitionRegistrar}s in the
+ * Spring 3.1 timeline. We populate {@link #beanClassLoader} and default the {@link #resourceLoader} in case they
+ * haven't been set until a call to this method.
+ *
+ * @param registry must not be {@literal null}.
+ * @see SPR-9568
+ */
+ private void defaultExternalResources(BeanDefinitionRegistry registry) {
+
+ if (beanClassLoader == null) {
+ this.beanClassLoader = getBeanClassLoader(registry);
+ }
+
+ if (resourceLoader == null) {
+ this.resourceLoader = new DefaultResourceLoader(this.beanClassLoader);
+ }
+ }
+
+ /**
+ * Returns the bean class loader contained in the given registry if it is a {@link ConfigurableBeanFactory}. Falls
+ * back to the {@link ResourceLoader}'s {@link ClassLoader} or the global default one if that one is {@literal null}
+ * in turn.
+ *
+ * @param registry must not be {@literal null}.
+ * @return
+ */
+ private ClassLoader getBeanClassLoader(BeanDefinitionRegistry registry) {
+
+ if (registry instanceof ConfigurableBeanFactory) {
+ return ((ConfigurableBeanFactory) registry).getBeanClassLoader();
+ }
+
+ return resourceLoader == null ? ClassUtils.getDefaultClassLoader() : resourceLoader.getClassLoader();
+ }
+
+ /**
* Return the annotation to obtain configuration information from. Will be wrappen into an
* {@link AnnotationRepositoryConfigurationSource} so have a look at the constants in there for what annotation
* attributes it expects.
View
80 ...src/main/java/org/springframework/data/repository/config/RepositoryBeanNameGenerator.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.repository.config;
+
+import org.springframework.beans.factory.BeanClassLoaderAware;
+import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
+import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanNameGenerator;
+import org.springframework.context.annotation.AnnotationBeanNameGenerator;
+import org.springframework.util.ClassUtils;
+
+/**
+ * Special {@link BeanNameGenerator} to create bean names for Spring Data repositories. Will delegate to an
+ * {@link AnnotationBeanNameGenerator} but let the delegate work with a customized {@link BeanDefinition} to make sure
+ * the repository interface is inspected and not the actual bean definition class.
+ *
+ * @author Oliver Gierke
+ */
+public class RepositoryBeanNameGenerator implements BeanNameGenerator, BeanClassLoaderAware {
+
+ private static final BeanNameGenerator DELEGATE = new AnnotationBeanNameGenerator();
+
+ private ClassLoader beanClassLoader;
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.BeanClassLoaderAware#setBeanClassLoader(java.lang.ClassLoader)
+ */
+ public void setBeanClassLoader(ClassLoader classLoader) {
+ this.beanClassLoader = classLoader;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.beans.factory.support.BeanNameGenerator#generateBeanName(org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.BeanDefinitionRegistry)
+ */
+ public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
+
+ AnnotatedBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(getRepositoryInterfaceFrom(definition));
+ return DELEGATE.generateBeanName(beanDefinition, registry);
+ }
+
+ /**
+ * Returns the type configured for the {@code repositoryInterface} property of the given bean definition. Uses a
+ * potential {@link Class} being configured as is or tries to load a class with the given value's {@link #toString()}
+ * representation.
+ *
+ * @param beanDefinition
+ * @return
+ */
+ private Class<?> getRepositoryInterfaceFrom(BeanDefinition beanDefinition) {
+
+ Object value = beanDefinition.getPropertyValues().getPropertyValue("repositoryInterface").getValue();
+
+ if (value instanceof Class<?>) {
+ return (Class<?>) value;
+ } else {
+ try {
+ return ClassUtils.forName(value.toString(), beanClassLoader);
+ } catch (Exception o_O) {
+ throw new RuntimeException(o_O);
+ }
+ }
+ }
+}
View
3  ...ore/src/main/java/org/springframework/data/repository/config/RepositoryConfiguration.java
@@ -17,6 +17,7 @@
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.data.repository.query.QueryLookupStrategy;
/**
@@ -30,7 +31,9 @@
* Returns the id of the {@link BeanDefinition} the repository shall be registered under.
*
* @return
+ * @deprecated bean ids should be determined using a {@link BeanNameGenerator} during classpath scanning.
*/
+ @Deprecated
String getBeanId();
/**
View
8 ...rc/main/java/org/springframework/data/repository/query/ParameterOutOfBoundsException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2010 the original author or authors.
+ * Copyright 2008-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,10 +28,10 @@
/**
* Creates a new {@link ParameterOutOfBoundsException} with the given exception as cause.
*
+ * @param message
* @param cause
*/
- public ParameterOutOfBoundsException(Throwable cause) {
-
- super(cause);
+ public ParameterOutOfBoundsException(String message, Throwable cause) {
+ super(message, cause);
}
}
View
5 ...data-commons-core/src/main/java/org/springframework/data/repository/query/Parameters.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2011 the original author or authors.
+ * Copyright 2008-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -165,7 +165,8 @@ public Parameter getParameter(int index) {
try {
return parameters.get(index);
} catch (IndexOutOfBoundsException e) {
- throw new ParameterOutOfBoundsException(e);
+ throw new ParameterOutOfBoundsException(
+ "Invalid parameter index! You seem to have declare too little query method parameters!", e);
}
}
View
9 ...ommons-core/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java
@@ -163,6 +163,15 @@ public boolean equals(Object obj) {
return super.equals(obj);
}
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.util.ParentTypeAwareTypeInformation#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode() + (isResolvedCompletely() ? this.type.hashCode() : 0);
+ }
+
private boolean isResolvedCompletely() {
Type[] types = type.getActualTypeArguments();
View
29 ...ta-commons-core/src/test/java/org/springframework/data/mapping/PropertyPathUnitTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -281,10 +281,37 @@ public void hashCodeTests() {
assertThat(left.hashCode(), is(not(shortPath.hashCode())));
}
+ /**
+ * @see DATACMNS-257
+ */
+ @Test
+ public void findsAllUppercaseProperty() {
+
+ PropertyPath path = PropertyPath.from("UUID", Foo.class);
+
+ assertThat(path, is(notNullValue()));
+ assertThat(path.getSegment(), is("UUID"));
+ }
+
+ /**
+ * @see DATACMNS-257
+ */
+ @Test
+ public void findsNestedAllUppercaseProperty() {
+
+ PropertyPath path = PropertyPath.from("_fooUUID", Sample2.class);
+
+ assertThat(path, is(notNullValue()));
+ assertThat(path.getSegment(), is("_foo"));
+ assertThat(path.hasNext(), is(true));
+ assertThat(path.next().getSegment(), is("UUID"));
+ }
+
private class Foo {
String userName;
String _email;
+ String UUID;
}
private class Bar {
View
1  ...a/org/springframework/data/repository/config/DefaultRepositoryConfigurationUnitTests.java
@@ -41,7 +41,6 @@ public void supportsBasicConfiguration() {
RepositoryConfiguration<RepositoryConfigurationSource> configuration = new DefaultRepositoryConfiguration<RepositoryConfigurationSource>(
source, "com.acme.MyRepository");
- assertThat(configuration.getBeanId(), is("myRepository"));
assertThat(configuration.getConfigurationSource(), is(source));
assertThat(configuration.getImplementationBeanName(), is("myRepositoryImpl"));
assertThat(configuration.getImplementationClassName(), is("MyRepositoryImpl"));
View
77 .../java/org/springframework/data/repository/config/RepositoryBeanNameGeneratorUnitTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.repository.config;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import javax.inject.Named;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.BeanNameGenerator;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
+
+/**
+ * Unit tests for {@link RepositoryBeanNameGenerator}.
+ *
+ * @author Oliver Gierke
+ */
+public class RepositoryBeanNameGeneratorUnitTest {
+
+ BeanNameGenerator generator;
+ BeanDefinitionRegistry registry;
+
+ @Before
+ public void setUp() {
+
+ RepositoryBeanNameGenerator generator = new RepositoryBeanNameGenerator();
+ generator.setBeanClassLoader(Thread.currentThread().getContextClassLoader());
+
+ this.generator = generator;
+ this.registry = new DefaultListableBeanFactory();
+ }
+
+ @Test
+ public void usesPlainClassNameIfNoAnnotationPresent() {
+ assertThat(generator.generateBeanName(getBeanDefinitionFor(MyRepository.class), registry), is("myRepository"));
+ }
+
+ @Test
+ public void usesAnnotationValueIfAnnotationPresent() {
+ assertThat(generator.generateBeanName(getBeanDefinitionFor(AnnotatedInterface.class), registry), is("specialName"));
+ }
+
+ private BeanDefinition getBeanDefinitionFor(Class<?> repositoryInterface) {
+
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(RepositoryFactoryBeanSupport.class);
+ builder.addPropertyValue("repositoryInterface", repositoryInterface.getName());
+ return builder.getBeanDefinition();
+ }
+
+ interface PlainInterface {
+
+ }
+
+ @Named("specialName")
+ interface AnnotatedInterface {
+
+ }
+}
View
2  spring-data-commons-parent/pom.xml
@@ -6,7 +6,7 @@
<name>Spring Data Commons Parent</name>
<description>Spring Data Commons Parent</description>
<url>http://www.springsource.org/spring-data</url>
- <version>1.4.0.RELEASE</version>
+ <version>1.4.2.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
View
14 src/main/resources/changelog.txt
@@ -1,6 +1,20 @@
Spring Data Commons Changelog
=============================
+Changes in version 1.4.1.RELEASE (2013-02-07)
+---------------------------------------------
+** Bug
+ * [DATACMNS-257] - PropertyPath cannot deal with all uppercase fields
+ * [DATACMNS-276] - ParameterizedTypeInformation is missing hashCode() method
+
+** Improvement
+ * [DATACMNS-168] - Allow customizing the bean name for repository beans
+ * [DATACMNS-253] - IndexOutOfBoundsException in Repository proxy when missing parameters
+ * [DATACMNS-254] - Auditable's identifier type constrained to the the same type as Persistable's
+
+** Task
+ * [DATACMNS-280] - Release 1.4.1
+
Changes in version 1.4.0.RELEASE (2012-10-09)
---------------------------------------------
** Bug
View
4 src/main/resources/notice.txt
@@ -1,5 +1,5 @@
-Spring Data Commons 1.0
-Copyright (c) [2010] SpringSource, a division of VMware, Inc.
+Spring Data Commons 1.4.1
+Copyright (c) [2013] SpringSource, a division of VMware, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
You may not use this product except in compliance with the License.

No commit comments for this range

Something went wrong with that request. Please try again.