--- /dev/null
+package org.simantics.maps.server.ui;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.simantics.district.maps.server.TileserverMapnikInstance;
+import org.simantics.district.maps.server.prefs.MapsServerPreferences;
+
+public class Activator implements BundleActivator {
+
+ public static final String PLUGIN_ID = "org.simantics.maps.server.ui";
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
+ * BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+
+ // Let's see if server should be automatically started
+ if (MapsServerPreferences.startAutomatically()) {
+ // execute in a separate thread to not slow down the startup process
+ new Thread(() -> {
+ try {
+ TileserverMapnikInstance.get().start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ // Stop the server
+ TileserverMapnikInstance.get().stop();
+ Activator.context = null;
+ }
+
+}