/
Activator.java
58 lines (46 loc) · 1.75 KB
/
Activator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Generated by Dragonfly SDK.
*/
package arrowtelematicssolution;
import com.buglabs.bug.module.gps.pub.IPositionProvider;
import com.buglabs.bug.module.gps.pub.INMEASentenceProvider;
import com.buglabs.bug.module.gps.pub.INMEARawFeed;
import com.buglabs.bug.module.lcd.pub.IML8953Accelerometer;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
import com.buglabs.application.ServiceTrackerHelper;
/**
* BundleActivator for ArrowTelematicsSolution. The OSGi entry point to the application.
*
*/
public class Activator implements BundleActivator {
/**
* OSGi services the application depends on.
*/
private static final String [] services = {
IPositionProvider.class.getName(),
INMEASentenceProvider.class.getName(),
INMEARawFeed.class.getName(),
IML8953Accelerometer.class.getName(),
};
private ServiceTracker serviceTracker;
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
//Begin tracking services, and when all services are available, create thread and call ManagedRunnable.run().
serviceTracker = ServiceTrackerHelper.openServiceTracker(context, services, new ArrowTelematicsSolutionApplication());
System.out.println("DEBUG (" + this.getClass().getName() + "): Bundle Start");
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
System.out.println("DEBUG (" + this.getClass().getName() + "): Bundle Stop");
//Will cause the ManagedRunnable.shutdown() to be called.
serviceTracker.close();
}
}