Permalink
Browse files

DATACMNS-306 - RepositoryBeanDefinitionBuilder not correctly sets sou…

…rce.

Previously, the RepositoryBeanDefinitionBuilder did not forward the repository configuration's source instance into the built BeanDefinitions. This is now fixed to enable STS track the origin of the BeanDefinition back to the configuration source (an @Enable-annotation or an XML namespace element).
  • Loading branch information...
olivergierke committed Mar 28, 2013
1 parent e8b2db8 commit 64dada589644e64444d93c0ec3162af20fc91fb5
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 the original author or authors.
+ * Copyright 2012-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.
@@ -81,6 +81,7 @@ public BeanDefinitionBuilder build(BeanDefinitionRegistry registry, ResourceLoad
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(factoryBeanName);
+ builder.getRawBeanDefinition().setSource(configuration.getSource());
builder.addPropertyValue("repositoryInterface", configuration.getRepositoryInterface());
builder.addPropertyValue("queryLookupStrategyKey", configuration.getQueryLookupStrategyKey());
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 the original author or authors.
+ * Copyright 2012-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.
@@ -19,6 +19,7 @@
import static org.junit.Assert.*;
import org.junit.Test;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
@@ -46,4 +47,13 @@ public void testBootstrappingWithInheritedConfigClasses() {
assertThat(context.getBean(MyRepository.class), is(notNullValue()));
assertThat(context.getBean(MyOtherRepository.class), is(notNullValue()));
}
+
+ @Test
+ public void beanDefinitionSourceIsSetForJavaConfigScannedBeans() {
+
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);
+
+ BeanDefinition definition = context.getBeanDefinition("myRepository");
+ assertThat(definition.getSource(), is(notNullValue()));
+ }
}

0 comments on commit 64dada5

Please sign in to comment.