SGF-140 - Update to Spring Data Commons 1.5.0.
Expose GemfireMappingContext to the parent class to enable PersistentEntity lookup.
This commit is contained in:
@@ -12,7 +12,7 @@ description = 'Spring Data GemFire'
|
||||
group = 'org.springframework.data'
|
||||
|
||||
repositories {
|
||||
maven { url "http://repo.springsource.org/libs-milestone" }
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
maven { url "http://repo.springsource.org/plugins-release"}
|
||||
maven { url "http://dist.gemstone.com.s3.amazonaws.com/maven/release"}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ slf4jVersion = 1.6.4
|
||||
|
||||
# Common libraries
|
||||
springVersion = 3.2.0.RC1
|
||||
springDataCommonsVersion = 1.4.0.RELEASE
|
||||
springDataCommonsVersion = 1.5.0.BUILD-SNAPSHOT
|
||||
gemfireVersion = 7.0
|
||||
|
||||
# Testing
|
||||
|
||||
@@ -74,7 +74,7 @@ public class GemfireRepositoryConfigurationExtension extends RepositoryConfigura
|
||||
String mappingContextRef = element.getAttribute(MAPPING_CONTEXT_REF);
|
||||
|
||||
if (StringUtils.hasText(mappingContextRef)) {
|
||||
builder.addPropertyReference("mappingContext", mappingContextRef);
|
||||
builder.addPropertyReference("gemfireMappingContext", mappingContextRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
|
||||
import org.springframework.data.gemfire.mapping.GemfirePersistentEntity;
|
||||
import org.springframework.data.gemfire.mapping.GemfirePersistentProperty;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
@@ -63,7 +64,7 @@ public class GemfireRepositoryFactoryBean<T extends Repository<S, ID>, S, ID ext
|
||||
*
|
||||
* @param context the context to set
|
||||
*/
|
||||
public void setMappingContext(
|
||||
public void setGemfireMappingContext(
|
||||
MappingContext<? extends GemfirePersistentEntity<?>, GemfirePersistentProperty> context) {
|
||||
this.context = context;
|
||||
}
|
||||
@@ -79,4 +80,19 @@ public class GemfireRepositoryFactoryBean<T extends Repository<S, ID>, S, ID ext
|
||||
protected RepositoryFactorySupport createRepositoryFactory() {
|
||||
return new GemfireRepositoryFactory(regions, context);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
|
||||
if (this.context == null) {
|
||||
this.context = new GemfireMappingContext();
|
||||
setMappingContext(context);
|
||||
}
|
||||
|
||||
super.afterPropertiesSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,19 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.mapping.Regions;
|
||||
import org.springframework.data.gemfire.repository.sample.Person;
|
||||
import org.springframework.data.gemfire.repository.sample.PersonRepository;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.repository.support.Repositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@@ -30,6 +38,9 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
@ContextConfiguration("../config/repo-context.xml")
|
||||
public class GemfireRepositoryFactoryIntegrationTests extends AbstractGemfireRepositoryFactoryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext context;
|
||||
|
||||
@Override
|
||||
protected PersonRepository getRepository(Regions regions) {
|
||||
|
||||
@@ -44,4 +55,15 @@ public class GemfireRepositoryFactoryIntegrationTests extends AbstractGemfireRep
|
||||
GemfireRepositoryFactory factory = new GemfireRepositoryFactory((Iterable) Collections.emptySet(), null);
|
||||
factory.getRepository(PersonRepository.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SGF-140
|
||||
*/
|
||||
@Test
|
||||
public void exposesPersistentProperty() {
|
||||
|
||||
Repositories repositories = new Repositories(context);
|
||||
PersistentEntity<?, ?> entity = repositories.getPersistentEntity(Person.class);
|
||||
assertThat(entity, is(notNullValue()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user