DATALDAP-64 - 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:
Mark Paluch
2018-03-12 16:31:13 +01:00
parent f73a1bdd1e
commit 3c47cd0e1c
4 changed files with 14 additions and 8 deletions

View File

@@ -63,13 +63,19 @@ public class LdapRepositoryBean<T> extends CdiRepositoryBean<T> {
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class)
*/
@Override
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType,
Optional<Object> customImplementation) {
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {
LdapOperations ldapOperations = getDependencyInstance(operations, LdapOperations.class);
LdapRepositoryFactory factory = new LdapRepositoryFactory(ldapOperations);
return customImplementation.map(o -> factory.getRepository(repositoryType, o))
.orElseGet(() -> factory.getRepository(repositoryType));
return create(() -> new LdapRepositoryFactory(ldapOperations), repositoryType);
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#getScope()
*/
@Override
public Class<? extends Annotation> getScope() {
return operations.getScope();
}
}