blob: 73d0cba9951e906d62401102f9de724986907b02 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010 Empolis GmbH and brox IT Solutions GmbH. All rights reserved. This program and the accompanying
* materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Thomas Menzel (brox IT Solution GmbH) initial implementation
*******************************************************************************/
package org.eclipse.smila.solr;
import org.eclipse.smila.management.ManagementRegistration;
import org.eclipse.smila.search.api.SearchService;
import org.eclipse.smila.solr.admin.SolrAdminAgent;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
/**
* The solr BundleActivator class.
*/
public class Activator implements BundleActivator {
/**
* The bundle name.
*/
public static final String BUNDLE_ID = "org.eclipse.smila.solr";
/**
* this instance is set and unset by the activator, so it might return null depending on the state of the bundle but
* otherwise this servers as a static handle to get to the important stuff of this bundle.
*/
private static Activator s_instance;
/**
* The SolrManager instance.
*/
private SolrServerManager _serverManager;
/**
* The SearchService service tracker.
*/
private ServiceTracker _searchServiceTracker;
/**
* {@inheritDoc}
*
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
s_instance = this;
_serverManager = new SolrServerManager();
ManagementRegistration.INSTANCE.registerAgent(new SolrServerManagerAgent(_serverManager));
ManagementRegistration.INSTANCE.registerAgent(new SolrAdminAgent(_serverManager.getSolrAdmin()));
_searchServiceTracker = new ServiceTracker(context, SearchService.class.getName(), null);
_searchServiceTracker.open();
}
/**
* {@inheritDoc}
*
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
s_instance = null;
_searchServiceTracker.close();
}
/**
* Get activator instance.
*
* @return the activator instance.
*/
public static Activator getInstance() {
return s_instance;
}
/**
* Get SolrServerManager.
*
* @return the SolrServerManager.
*/
public SolrServerManager getSolrManager() {
return _serverManager;
}
/**
* Get SearchService.
*
* @return the SearchService.
*/
public SearchService getSearchService() {
return (SearchService) _searchServiceTracker.getService();
}
}