com.jslsolucoes.elasticsearch.ee.RestHighLevelClientCreator Maven / Gradle / Ivy
package com.jslsolucoes.elasticsearch.ee;
import java.io.IOException;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
@RequestScoped
public class RestHighLevelClientCreator {
@Inject
private ElasticSearch elasticSearch;
@Deprecated
public RestHighLevelClientCreator() {
}
@Produces
public RestHighLevelClient create() {
return new RestHighLevelClient(RestClient.builder(elasticSearch.getHosts()));
}
public void disposes(@Disposes RestHighLevelClient restHighLevelClient) {
try {
restHighLevelClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy