Package me.outofti.solrspatiallight

Source Code of me.outofti.solrspatiallight.EmbeddedSolrServerFactory

package me.outofti.solrspatiallight;

import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.core.CoreContainer;

class EmbeddedSolrServerFactory {
    private static EmbeddedSolrServerFactory instance;

    private EmbeddedSolrServer server;

    public static EmbeddedSolrServerFactory getInstance() {
        if(instance == null) {
            System.setProperty("solr.solr.home", "test/solr");
            System.setProperty("java.util.logging.config.file", "test/logging.properties");
            instance = new EmbeddedSolrServerFactory();
        }
        return instance;
    }

    private EmbeddedSolrServerFactory() { }

    public EmbeddedSolrServer getServer() throws IOException, ParserConfigurationException, SAXException {
        if(this.server == null) {
            final CoreContainer.Initializer initializer = new CoreContainer.Initializer();
            final CoreContainer coreContainer = initializer.initialize();
            this.server = new EmbeddedSolrServer(coreContainer, "");
        }
        return this.server;
    }
}
TOP

Related Classes of me.outofti.solrspatiallight.EmbeddedSolrServerFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.