/**
* Generated by DragonFly
*
* Starts the GoogleTiles application when all
* service dependencies are satisfied.
*
* Modified doStart and doStop methods.
* @author Angel Roman - angel.roman@mdesystems.com
*/
package googletiles.servicetracker;
import googletiles.app.GoogleTilesApp;
import org.osgi.framework.BundleContext;
import com.buglabs.application.AbstractServiceTracker;
import com.buglabs.bug.module.gps.pub.IPositionProvider;
import com.buglabs.bug.module.lcd.pub.IModuleDisplay;
import com.buglabs.bug.module.motion.pub.IMotionSubject;
import com.buglabs.device.IButtonEventProvider;
/**
* Service tracker for the BugApp Bundle;
*
*/
public class GoogleTilesServiceTracker extends AbstractServiceTracker {
/**
* Handle to application.
*/
private GoogleTilesApp app;
public GoogleTilesServiceTracker(BundleContext context) {
super(context);
}
/**
* Determines if the application can start.
*/
public boolean canStart() {
return super.canStart();
}
/**
* If canStart returns true
* this method is called to start the application.
* Place your fun logic here.
*/
public void doStart() {
IModuleDisplay display = (IModuleDisplay) getService(IModuleDisplay.class);
IPositionProvider position = (IPositionProvider) getService(IPositionProvider.class);
IButtonEventProvider buttons = (IButtonEventProvider) getService(IButtonEventProvider.class);
app = new GoogleTilesApp(buttons, position, display);
app.start();
}
/**
* Called when a service that this application depends is unregistered.
*/
public void doStop() {
app.stop();
}
/**
* Allows the user to set the service dependencies by
* adding them to services list returned by getServices().
* i.e. getServices().add(MyService.class.getName());
*/
public void initServices() {
getServices().add("com.buglabs.bug.module.gps.pub.IPositionProvider");
getServices().add("com.buglabs.device.IButtonEventProvider");
getServices().add("com.buglabs.bug.module.lcd.pub.IModuleDisplay");
}
}