DATAMONGO-1566 - Adapt API in MongoRepositoryFactoryBean.
Related tickets: DATACMNS-891.
This commit is contained in:
@@ -30,13 +30,22 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class MongoRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable> extends
|
||||
RepositoryFactoryBeanSupport<T, S, ID> {
|
||||
public class MongoRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
|
||||
extends RepositoryFactoryBeanSupport<T, S, ID> {
|
||||
|
||||
private MongoOperations operations;
|
||||
private boolean createIndexesForQueryMethods = false;
|
||||
private boolean mappingContextConfigured = false;
|
||||
|
||||
/**
|
||||
* Creates a new {@link MongoRepositoryFactoryBean} for the given repository interface.
|
||||
*
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
*/
|
||||
public MongoRepositoryFactoryBean(Class<? extends T> repositoryInterface) {
|
||||
super(repositoryInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the {@link MongoOperations} to be used.
|
||||
*
|
||||
|
||||
@@ -98,9 +98,9 @@ public class PerformanceTests {
|
||||
this.converter = new MappingMongoConverter(new DefaultDbRefResolver(mongoDbFactory), context);
|
||||
this.operations = new MongoTemplate(new SimpleMongoDbFactory(this.mongo, DATABASE_NAME), converter);
|
||||
|
||||
MongoRepositoryFactoryBean<PersonRepository, Person, ObjectId> factory = new MongoRepositoryFactoryBean<PersonRepository, Person, ObjectId>();
|
||||
MongoRepositoryFactoryBean<PersonRepository, Person, ObjectId> factory = new MongoRepositoryFactoryBean<PersonRepository, Person, ObjectId>(
|
||||
PersonRepository.class);
|
||||
factory.setMongoOperations(operations);
|
||||
factory.setRepositoryInterface(PersonRepository.class);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
this.repository = factory.getObject();
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.repository.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -59,15 +54,4 @@ public class MongoRepositoriesRegistrarIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testConfiguration() {}
|
||||
|
||||
/**
|
||||
* @see DATAMONGO-901
|
||||
*/
|
||||
@Test
|
||||
public void registersTypePredictingPostProcessor() {
|
||||
|
||||
Iterable<String> beanNames = Arrays.asList(context.getBeanDefinitionNames());
|
||||
|
||||
assertThat(beanNames, hasItem(containsString("RepositoryFactoryBeanSupport_Predictor")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MongoRepositoryFactoryBeanUnitTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void addsIndexEnsuringQueryCreationListenerIfConfigured() {
|
||||
|
||||
MongoRepositoryFactoryBean factory = new MongoRepositoryFactoryBean();
|
||||
MongoRepositoryFactoryBean factory = new MongoRepositoryFactoryBean(ContactRepository.class);
|
||||
factory.setCreateIndexesForQueryMethods(true);
|
||||
|
||||
List<Object> listeners = getListenersFromFactory(factory);
|
||||
@@ -60,7 +60,7 @@ public class MongoRepositoryFactoryBeanUnitTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void doesNotAddIndexEnsuringQueryCreationListenerByDefault() {
|
||||
|
||||
List<Object> listeners = getListenersFromFactory(new MongoRepositoryFactoryBean());
|
||||
List<Object> listeners = getListenersFromFactory(new MongoRepositoryFactoryBean(ContactRepository.class));
|
||||
assertThat(listeners.size(), is(1));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,6 @@ public class MongoRepositoryFactoryBeanUnitTests {
|
||||
|
||||
factoryBean.setLazyInit(true);
|
||||
factoryBean.setMongoOperations(operations);
|
||||
factoryBean.setRepositoryInterface(ContactRepository.class);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
RepositoryFactorySupport factory = factoryBean.createRepositoryFactory();
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean">
|
||||
<constructor-arg value="org.springframework.data.mongodb.repository.PersonRepository"/>
|
||||
<property name="mongoOperations" ref="mongoTemplate"/>
|
||||
<property name="repositoryInterface" value="org.springframework.data.mongodb.repository.PersonRepository"/>
|
||||
<property name="namedQueries">
|
||||
<bean class="org.springframework.data.repository.core.support.PropertiesBasedNamedQueries">
|
||||
<constructor-arg>
|
||||
@@ -34,5 +34,5 @@
|
||||
<bean class="org.springframework.data.mongodb.repository.SampleEvaluationContextExtension"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user