All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jslsolucoes.elasticsearch.ee.RestHighLevelClientCreator Maven / Gradle / Ivy

There is a newer version: 1.0.32
Show newest version
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