mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-20 02:52:12 +00:00
DATAES-432 - 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:
parent
4313d13ddd
commit
9bc9c47f42
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2017 the original author or authors.
|
* Copyright 2013-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -60,24 +60,21 @@ public class ElasticsearchRepositoryBean<T> extends CdiRepositoryBean<T> {
|
|||||||
this.elasticsearchOperationsBean = operations;
|
this.elasticsearchOperationsBean = operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class, java.util.Optional)
|
* (non-Javadoc)
|
||||||
|
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType,
|
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {
|
||||||
Optional<Object> customImplementation) {
|
|
||||||
|
|
||||||
ElasticsearchOperations elasticsearchOperations = getDependencyInstance(elasticsearchOperationsBean,
|
ElasticsearchOperations operations = getDependencyInstance(elasticsearchOperationsBean,
|
||||||
ElasticsearchOperations.class);
|
ElasticsearchOperations.class);
|
||||||
|
|
||||||
ElasticsearchRepositoryFactory factory = new ElasticsearchRepositoryFactory(elasticsearchOperations);
|
return create(() -> new ElasticsearchRepositoryFactory(operations), repositoryType);
|
||||||
|
|
||||||
return customImplementation //
|
|
||||||
.map(o -> factory.getRepository(repositoryType, o)) //
|
|
||||||
.orElseGet(() -> factory.getRepository(repositoryType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#getScope()
|
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#getScope()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user