package aimmotionnotifier;

import com.buglabs.util.ServiceFilterGenerator;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.util.tracker.ServiceTracker;
import aimmotionnotifier.servicetracker.*;

/**
 * BundleActivator for AIMMotionNotifier
 *
 */
public class Activator implements BundleActivator {
	private aimmotionnotifier.servicetracker.AIMMotionNotifierServiceTracker stc;
	private ServiceTracker st;
	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		//Create the service tracker and run it.
		stc = new AIMMotionNotifierServiceTracker(context);
		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();
	}
}