/**
 * Generated by DragonFly.
 *
 */
package bugweather;

import bugweather.servicetracker.*;
import com.buglabs.util.ServiceFilterGenerator;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import latlonconverter.utils.*;
/**
 * BundleActivator for BugWeather.
 *
 */
public class Activator implements BundleActivator {
	private BundleContext context;
	private BugWeatherServiceTracker stc;
	private ServiceTracker st;
	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		this.context = context;
		
		ServiceReference serviceReference = context.getServiceReference(ILocationConverter.class.getName());
		//Create the service tracker and run it.
		stc = new BugWeatherServiceTracker(context,serviceReference);
		Filter f = context.createFilter(ServiceFilterGenerator.generateServiceFilter(stc.getServices()));
		st = new ServiceTracker(context, f, stc);
		st.open();
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		stc.stop();
	}
}