X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.maps.server.ui%2Fsrc%2Forg%2Fsimantics%2Fmaps%2Fserver%2Fui%2FActivator.java;fp=org.simantics.maps.server.ui%2Fsrc%2Forg%2Fsimantics%2Fmaps%2Fserver%2Fui%2FActivator.java;h=cd46e1a517f5c57dcaf64acef5cfe6d8a5570740;hb=2529be6d456deeb07c128603ce4971f1dc29b695;hp=0000000000000000000000000000000000000000;hpb=2636fc31c16c23711cf2b06a4ae8537bba9c1d35;p=simantics%2Fdistrict.git diff --git a/org.simantics.maps.server.ui/src/org/simantics/maps/server/ui/Activator.java b/org.simantics.maps.server.ui/src/org/simantics/maps/server/ui/Activator.java new file mode 100644 index 00000000..cd46e1a5 --- /dev/null +++ b/org.simantics.maps.server.ui/src/org/simantics/maps/server/ui/Activator.java @@ -0,0 +1,52 @@ +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; + } + +}