1 package org.simantics.district.route.ui.internal;
3 import org.eclipse.ui.plugin.AbstractUIPlugin;
4 import org.osgi.framework.BundleContext;
5 import org.osgi.util.tracker.ServiceTracker;
6 import org.simantics.district.route.RouteService;
9 * The activator class controls the plug-in life cycle
11 public class Activator extends AbstractUIPlugin {
14 public static final String PLUGIN_ID = "org.simantics.district.route.ui"; //$NON-NLS-1$
16 // The shared instance
17 private static Activator plugin;
19 private ServiceTracker<RouteService, ?> routeServiceTracker;
23 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
25 public void start(BundleContext context) throws Exception {
29 // create a tracker and track the service
30 routeServiceTracker = new ServiceTracker<>(context, RouteService.class.getName(), null);
31 routeServiceTracker.open();
36 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
38 public void stop(BundleContext context) throws Exception {
39 // close the service tracker
40 routeServiceTracker.close();
41 routeServiceTracker = null;
48 * Returns the shared instance
50 * @return the shared instance
52 public static Activator getDefault() {
56 public RouteService getRouteService() {
57 return (RouteService) routeServiceTracker.getService();