X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.maps.server%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fmaps%2Fserver%2FActivator.java;fp=org.simantics.maps.server%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fmaps%2Fserver%2FActivator.java;h=eaeda86acb88b6acf71432b556a3aa81d5d42aed;hb=2529be6d456deeb07c128603ce4971f1dc29b695;hp=0000000000000000000000000000000000000000;hpb=2636fc31c16c23711cf2b06a4ae8537bba9c1d35;p=simantics%2Fdistrict.git diff --git a/org.simantics.maps.server/src/org/simantics/district/maps/server/Activator.java b/org.simantics.maps.server/src/org/simantics/district/maps/server/Activator.java new file mode 100644 index 00000000..eaeda86a --- /dev/null +++ b/org.simantics.maps.server/src/org/simantics/district/maps/server/Activator.java @@ -0,0 +1,54 @@ +package org.simantics.district.maps.server; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.eclipse.core.runtime.FileLocator; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + public static final String PLUGIN_ID = "org.simantics.maps.server"; + 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; + } + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + + public static Path getNodeJSRoot() throws IOException, URISyntaxException { + URL nodeURL = getContext().getBundle().getEntry("/node"); + URL nodeFileURL = FileLocator.toFileURL(nodeURL); + return Paths.get(nodeFileURL.toURI()); + } + + public static Path getTileserverMapnikRoot() throws IOException, URISyntaxException { + URL serverURL = getContext().getBundle().getEntry("/server"); + URL serverFileURL = FileLocator.toFileURL(serverURL); + return Paths.get(serverFileURL.toURI()); + } + +}