Skip to content

Commit 9bc9c47

Browse files
committed
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.
1 parent 4313d13 commit 9bc9c47

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/main/java/org/springframework/data/elasticsearch/repository/cdi/ElasticsearchRepositoryBean.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2017 the original author or authors.
2+
* Copyright 2013-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,24 +60,21 @@ public ElasticsearchRepositoryBean(Bean<ElasticsearchOperations> operations, Set
6060
this.elasticsearchOperationsBean = operations;
6161
}
6262

63-
/* (non-Javadoc)
64-
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class, java.util.Optional)
63+
/*
64+
* (non-Javadoc)
65+
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class)
6566
*/
6667
@Override
67-
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType,
68-
Optional<Object> customImplementation) {
68+
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {
6969

70-
ElasticsearchOperations elasticsearchOperations = getDependencyInstance(elasticsearchOperationsBean,
70+
ElasticsearchOperations operations = getDependencyInstance(elasticsearchOperationsBean,
7171
ElasticsearchOperations.class);
7272

73-
ElasticsearchRepositoryFactory factory = new ElasticsearchRepositoryFactory(elasticsearchOperations);
74-
75-
return customImplementation //
76-
.map(o -> factory.getRepository(repositoryType, o)) //
77-
.orElseGet(() -> factory.getRepository(repositoryType));
73+
return create(() -> new ElasticsearchRepositoryFactory(operations), repositoryType);
7874
}
7975

80-
/* (non-Javadoc)
76+
/*
77+
* (non-Javadoc)
8178
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#getScope()
8279
*/
8380
@Override

0 commit comments

Comments
 (0)