SGF-725 - Export composable repositories via CDI.
We now export composable repositories through our CDI extension. Repositories can now be customized either by a single custom implementation (as it was before) and by providing fragment interfaces along their fragment implementation. This change aligns CDI support with the existing RepositoryFactory support we provide within a Spring application context.
This commit is contained in:
@@ -143,18 +143,11 @@ class GemfireRepositoryBean<T> extends CdiRepositoryBean<T> {
|
||||
* @param creationalContext operations used by the {@link javax.enterprise.context.spi.Contextual} implementation
|
||||
* during creation of the bean instance.
|
||||
* @param repositoryType the actual class type of the SD (GemFire) Repository.
|
||||
* @param customImplementation the supporting custom Repository implementing class.
|
||||
* @return a factory used to create instance of {@link org.springframework.data.gemfire.repository.GemfireRepository}.
|
||||
* @see javax.enterprise.context.spi.Contextual#create(javax.enterprise.context.spi.CreationalContext)
|
||||
* @see #newGemfireRepositoryFactory()
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType,
|
||||
Optional<Object> customImplementation) {
|
||||
|
||||
return (customImplementation.isPresent()
|
||||
? newGemfireRepositoryFactory().getRepository(repositoryType, customImplementation.get())
|
||||
: newGemfireRepositoryFactory().getRepository(repositoryType));
|
||||
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {
|
||||
return create(this::newGemfireRepositoryFactory, repositoryType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,11 @@ package org.springframework.data.gemfire.repository.cdi;
|
||||
* supporting additional data access (CRUD) operations on people.
|
||||
*
|
||||
* @author John Blum
|
||||
* @author Mark Paluch
|
||||
* @see org.springframework.data.gemfire.repository.cdi.CustomPersonRepository
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public class SamplePersonRepositoryImpl implements CustomPersonRepository {
|
||||
public class CustomPersonRepositoryImpl implements CustomPersonRepository {
|
||||
|
||||
public int returnOne() {
|
||||
return 1;
|
||||
@@ -335,7 +335,7 @@ public class GemfireRepositoryBeanTest {
|
||||
};
|
||||
|
||||
GemfireRepository<Person, Long> gemfireRepository =
|
||||
repositoryBean.create(null, PersonRepository.class, Optional.empty());
|
||||
repositoryBean.create(null, PersonRepository.class);
|
||||
|
||||
assertThat(gemfireRepository, is(notNullValue()));
|
||||
assertThat(repositoryProxyPostProcessed.get(), is(true));
|
||||
|
||||
@@ -26,9 +26,10 @@ import org.springframework.data.gemfire.repository.sample.Person;
|
||||
* operations on instances of {@link Person}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @author Mark Paluch
|
||||
* @see org.springframework.data.gemfire.repository.GemfireRepository
|
||||
* @see org.springframework.data.gemfire.repository.cdi.CustomPersonRepository
|
||||
* @see org.springframework.data.gemfire.repository.cdi.SamplePersonRepositoryImpl
|
||||
* @see CustomPersonRepositoryImpl
|
||||
* @see org.springframework.data.gemfire.repository.sample.Person
|
||||
* @since 1.8.0
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user