Branch 5.0.x.

This commit is contained in:
Peter-Josef Meisch 2021-11-22 19:27:11 +01:00
parent 4e39fb30bc
commit f0c359eb41
No known key found for this signature in database
GPG Key ID: DE108246970C7708
22 changed files with 119 additions and 77 deletions

36
Jenkinsfile vendored
View File

@ -31,13 +31,13 @@ pipeline {
options { timeout(time: 30, unit: 'MINUTES') }
environment {
DOCKER_HUB = credentials("${p['docker.credentials']}")
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
DOCKER_HUB = credentials('hub.docker.com-springbuildmaster')
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
script {
docker.withRegistry(p['docker.registry'], p['docker.credentials']) {
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.docker']) {
sh "docker login --username ${DOCKER_HUB_USR} --password ${DOCKER_HUB_PSW}"
sh 'PROFILE=none ci/verify.sh'
@ -119,7 +119,7 @@ pipeline {
options { timeout(time: 20, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials("${p['artifactory.credentials']}")
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
@ -139,6 +139,34 @@ pipeline {
}
}
}
stage('Publish documentation') {
when {
branch 'main'
}
agent {
label 'data'
}
options { timeout(time: 20, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
script {
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
docker.image(p['docker.java.main.image']).inside(p['docker.java.inside.basic']) {
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,distribute -Dmaven.repo.local=/tmp/jenkins-home/.m2/spring-data-elasticsearch-non-root ' +
'-Dartifactory.server=https://repo.spring.io ' +
"-Dartifactory.username=${ARTIFACTORY_USR} " +
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
"-Dartifactory.distribution-repository=temp-private-local " +
'-Dmaven.test.skip=true clean deploy -U -B'
}
}
}
}
}
}
post {

33
pom.xml
View File

@ -5,12 +5,12 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>5.0.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<name>Spring Data Elasticsearch</name>
@ -21,7 +21,7 @@
<elasticsearch>7.17.1</elasticsearch>
<log4j>2.17.1</log4j>
<netty>4.1.65.Final</netty>
<springdata.commons>2.7.0-SNAPSHOT</springdata.commons>
<springdata.commons>3.0.0-SNAPSHOT</springdata.commons>
<testcontainers>1.16.2</testcontainers>
<blockhound-junit>1.0.6.RELEASE</blockhound-junit>
<java-module-name>spring.data.elasticsearch</java-module-name>
@ -174,23 +174,40 @@
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>${cdi}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${javax-annotation-api}</version>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-api}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-se</artifactId>
<classifier>jakarta</classifier>
<version>${webbeans}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
<classifier>jakarta</classifier>
<version>${webbeans}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<classifier>jakarta</classifier>
<version>${webbeans}</version>
<scope>test</scope>
</dependency>

View File

@ -54,7 +54,6 @@ public interface ClientConfiguration {
/**
* Creates a new {@link ClientConfiguration} instance configured to localhost.
* <p/>
*
* <pre class="code">
* // "localhost:9200"
@ -70,7 +69,6 @@ public interface ClientConfiguration {
/**
* Creates a new {@link ClientConfiguration} instance configured to a single host given {@code hostAndPort}.
* <p/>
* For example given the endpoint http://localhost:9200
*
* <pre class="code">
@ -85,7 +83,6 @@ public interface ClientConfiguration {
/**
* Creates a new {@link ClientConfiguration} instance configured to a single host given {@link InetSocketAddress}.
* <p/>
* For example given the endpoint http://localhost:9200
*
* <pre class="code">

View File

@ -28,8 +28,7 @@ import org.springframework.web.reactive.function.client.WebClient;
/**
* Provider for {@link WebClient}s using a pre-configured {@code scheme}. This class returns {@link WebClient} for a
* specific {@link InetSocketAddress endpoint} and encapsulates common configuration aspects of {@link WebClient} so
* that code using {@link WebClient} is not required to apply further configuration to the actual client.
* <p/>
* that code using {@link WebClient} is not required to apply further configuration to the actual client. <br/>
* Client instances are typically cached allowing reuse of pooled connections if configured on the
* {@link ClientHttpConnector}.
*

View File

@ -148,7 +148,6 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper
/**
* Set the {@link EntityCallbacks} instance to use when invoking {@link EntityCallbacks callbacks} like the
* {@link org.springframework.data.elasticsearch.core.event.BeforeConvertCallback}.
* <p />
* Overrides potentially existing {@link EntityCallbacks}.
*
* @param entityCallbacks must not be {@literal null}.

View File

@ -58,7 +58,7 @@ public class Range<T> {
* @param <T>
* @param value must not be {@literal null}.
* @return
* @see Range#closed(T, T)
* @see Range#closed(Object, Object)
*/
public static <T> Range<T> just(T value) {
return Range.closed(value, value);
@ -231,8 +231,8 @@ public class Range<T> {
}
/**
* Value object representing a boundary. A boundary can either be {@link #unbounded() unbounded}, {@link #inclusive(T)
* including its value} or {@link #exclusive(T) its value}.
* Value object representing a boundary. A boundary can either be {@link #unbounded() unbounded}, {@link #inclusive(Object)}
* including its value} or {@link #exclusive(Object)} its value}.
*/
public static final class Bound<T> {

View File

@ -213,7 +213,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
/**
* Set the {@link ReactiveEntityCallbacks} instance to use when invoking {@link ReactiveEntityCallbacks callbacks}
* like the {@link ReactiveBeforeConvertCallback}.
* <p />
* <br/>
* Overrides potentially existing {@link ReactiveEntityCallbacks}.
*
* @param entityCallbacks must not be {@literal null}.

View File

@ -126,7 +126,6 @@ public interface ReactiveSearchOperations {
*
* @param query must not be {@literal null}.
* @param entityType must not be {@literal null}.
* @param <T>
* @return a {@link Mono} emitting matching entities in a {@link SearchHits}.
* @since 4.1
*/
@ -140,7 +139,6 @@ public interface ReactiveSearchOperations {
* @param query must not be {@literal null}.
* @param entityType must not be {@literal null}.
* @param resultType the projection result type.
* @param <T>
* @return a {@link Mono} emitting matching entities in a {@link SearchHits}.
* @since 4.1
*/
@ -152,7 +150,6 @@ public interface ReactiveSearchOperations {
* @param query must not be {@literal null}.
* @param entityType must not be {@literal null}.
* @param index the target index, must not be {@literal null}
* @param <T>
* @return a {@link Mono} emitting matching entities in a {@link SearchHits}.
* @since 4.1
*/

View File

@ -205,7 +205,6 @@ public interface SearchOperations {
/**
* Executes the given {@link Query} against elasticsearch and return result as {@link SearchHitsIterator}.
* <p>
*
* @param <T> element return type
* @param query the query to execute
@ -218,7 +217,6 @@ public interface SearchOperations {
/**
* Executes the given {@link Query} against elasticsearch and return result as {@link SearchHitsIterator}.
* <p>
*
* @param <T> element return type
* @param query the query to execute

View File

@ -20,8 +20,8 @@ import org.springframework.data.elasticsearch.core.convert.GeoConverters;
import org.springframework.data.elasticsearch.core.document.Document;
/**
* Interface definition for structures defined in <a href="https://geojson.org/">GeoJSON</a> format. copied from Spring
* Data Mongodb
* Interface definition for structures defined in <a href="https://geojson.org">GeoJSON</a>
* format. copied from Spring Data Mongodb
*
* @author Christoph Strobl
* @since 1.7

View File

@ -349,7 +349,7 @@ public class MappingBuilder {
}
if (isNestedOrObjectProperty) {
Iterator<? extends TypeInformation<?>> iterator = property.getPersistentEntityTypes().iterator();
Iterator<? extends TypeInformation<?>> iterator = property.getPersistentEntityTypeInformation().iterator();
ElasticsearchPersistentEntity<?> persistentEntity = iterator.hasNext()
? elasticsearchConverter.getMappingContext().getPersistentEntity(iterator.next())
: null;

View File

@ -157,7 +157,7 @@ public interface Query {
float getMinScore();
/**
* Get if scores will be computed and tracked, regardless of whether sorting on a field. Defaults to <tt>false</tt>.
* Get if scores will be computed and tracked, regardless of whether sorting on a field. Defaults to <em>false</em>.
*
* @return
* @since 3.1

View File

@ -19,9 +19,9 @@ import java.lang.annotation.Annotation;
import java.util.Optional;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.spi.Bean;
import jakarta.enterprise.inject.spi.BeanManager;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory;
@ -49,12 +49,12 @@ public class ElasticsearchRepositoryBean<T> extends CdiRepositoryBean<T> {
* @param repositoryType must not be {@literal null}.
* @param beanManager must not be {@literal null}.
* @param detector detector for the custom {@link org.springframework.data.repository.Repository} implementations
* {@link CustomRepositoryImplementationDetector}, can be {@literal null}.
* {@link CustomRepositoryImplementationDetector}, can be {@link Optional#empty()}.
*/
public ElasticsearchRepositoryBean(Bean<ElasticsearchOperations> operations, Set<Annotation> qualifiers,
Class<T> repositoryType, BeanManager beanManager, CustomRepositoryImplementationDetector detector) {
Class<T> repositoryType, BeanManager beanManager, Optional<CustomRepositoryImplementationDetector> detector) {
super(qualifiers, repositoryType, beanManager, Optional.of(detector));
super(qualifiers, repositoryType, beanManager, detector);
Assert.notNull(operations, "Cannot create repository with 'null' for ElasticsearchOperations.");
this.elasticsearchOperationsBean = operations;
@ -62,7 +62,7 @@ public class ElasticsearchRepositoryBean<T> extends CdiRepositoryBean<T> {
/*
* (non-Javadoc)
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class)
* @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(jakarta.enterprise.context.spi.CreationalContext, java.lang.Class)
*/
@Override
protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {

View File

@ -18,17 +18,21 @@ package org.springframework.data.elasticsearch.repository.cdi;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.ProcessBean;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.UnsatisfiedResolutionException;
import jakarta.enterprise.inject.spi.AfterBeanDiscovery;
import jakarta.enterprise.inject.spi.Bean;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.ProcessBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.repository.cdi.CdiRepositoryBean;
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
@ -43,14 +47,24 @@ import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
*/
public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupport {
private static final Log LOGGER = LogFactory.getLog(ElasticsearchRepositoryExtension.class);
private final Map<Set<Annotation>, Bean<ElasticsearchOperations>> elasticsearchOperationsMap = new HashMap<>();
@SuppressWarnings("unchecked")
<T> void processBean(@Observes ProcessBean<T> processBean) {
Bean<T> bean = processBean.getBean();
for (Type type : bean.getTypes()) {
if (type instanceof Class<?> && ElasticsearchOperations.class.isAssignableFrom((Class<?>) type)) {
elasticsearchOperationsMap.put(bean.getQualifiers(), ((Bean<ElasticsearchOperations>) bean));
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format("Discovered %s with qualifiers %s.", ElasticsearchOperations.class.getName(),
bean.getQualifiers()));
}
elasticsearchOperationsMap.put(new HashSet<>(bean.getQualifiers()), ((Bean<ElasticsearchOperations>) bean));
}
}
}
@ -62,22 +76,27 @@ public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupp
Set<Annotation> qualifiers = entry.getValue();
CdiRepositoryBean<?> repositoryBean = createRepositoryBean(repositoryType, qualifiers, beanManager);
afterBeanDiscovery.addBean(repositoryBean);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Registering bean for %s with qualifiers %s.", repositoryType.getName(), qualifiers));
}
registerBean(repositoryBean);
afterBeanDiscovery.addBean(repositoryBean);
}
}
private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers,
BeanManager beanManager) {
if (!this.elasticsearchOperationsMap.containsKey(qualifiers)) {
Bean<ElasticsearchOperations> elasticsearchOperations = this.elasticsearchOperationsMap.get(qualifiers);
if (elasticsearchOperations == null) {
throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.",
ElasticsearchOperations.class.getName(), qualifiers));
}
Bean<ElasticsearchOperations> elasticsearchOperationsBean = this.elasticsearchOperationsMap.get(qualifiers);
return new ElasticsearchRepositoryBean<>(elasticsearchOperationsBean, qualifiers, repositoryType, beanManager,
getCustomImplementationDetector());
return new ElasticsearchRepositoryBean<>(elasticsearchOperations, qualifiers, repositoryType, beanManager,
Optional.of(getCustomImplementationDetector()));
}
}

View File

@ -54,10 +54,10 @@ public class ConvertingParameterAccessor implements ElasticsearchParameterAccess
return delegate.getSort();
}
@Override
public Optional<Class<?>> getDynamicProjection() {
return delegate.getDynamicProjection();
}
// @Override
// public Optional<Class<?>> getDynamicProjection() {
// return delegate.getDynamicProjection();
// }
@Override
public Class<?> findDynamicProjection() {

View File

@ -15,7 +15,7 @@
*/
package org.springframework.data.elasticsearch.repositories.cdi;
import javax.inject.Inject;
import jakarta.inject.Inject;
import org.springframework.lang.Nullable;

View File

@ -24,8 +24,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@ -49,7 +49,7 @@ import org.springframework.lang.Nullable;
@IntegrationTest
public class CdiRepositoryTests {
@Nullable private static SeContainer container;
@SuppressWarnings("NotNullFieldNotInitialized") private static SeContainer container;
// @Nullable private static CdiTestContainer cdiContainer;
private CdiProductRepository repository;
@ -67,10 +67,7 @@ public class CdiRepositoryTests {
@AfterAll
public static void shutdown() throws Exception {
if (container != null) {
container.close();
}
container.close();
}
@BeforeEach

View File

@ -17,9 +17,9 @@ package org.springframework.data.elasticsearch.repositories.cdi;
import static org.springframework.util.StringUtils.*;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import jakarta.annotation.PreDestroy;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.data.elasticsearch.client.ClientConfiguration;

View File

@ -21,7 +21,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import jakarta.inject.Qualifier;
/**
* @author Mark Paluch

View File

@ -21,7 +21,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import jakarta.inject.Qualifier;
/**
* @author Mark Paluch

View File

@ -91,15 +91,6 @@ class StubParameterAccessor implements ElasticsearchParameterAccessor {
return this.values;
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#getDynamicProjection()
*/
@Override
public Optional<Class<?>> getDynamicProjection() {
return Optional.empty();
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#findDynamicProjection()