X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.maps.server%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fmaps%2Fserver%2FActivator.java;h=65227c669af3fe3ce0d26641a8d1ffdbae6f0ce0;hb=refs%2Fchanges%2F43%2F2843%2F1;hp=eaeda86acb88b6acf71432b556a3aa81d5d42aed;hpb=2529be6d456deeb07c128603ce4971f1dc29b695;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 index eaeda86a..65227c66 100644 --- 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 @@ -1,6 +1,7 @@ package org.simantics.district.maps.server; import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -14,6 +15,7 @@ public class Activator implements BundleActivator { public static final String PLUGIN_ID = "org.simantics.maps.server"; private static BundleContext context; + private static Activator defaultt; static BundleContext getContext() { return context; @@ -27,6 +29,7 @@ public class Activator implements BundleActivator { */ public void start(BundleContext bundleContext) throws Exception { Activator.context = bundleContext; + Activator.defaultt = this; } /* @@ -37,18 +40,26 @@ public class Activator implements BundleActivator { */ public void stop(BundleContext bundleContext) throws Exception { Activator.context = null; + Activator.defaultt = null; } public static Path getNodeJSRoot() throws IOException, URISyntaxException { - URL nodeURL = getContext().getBundle().getEntry("/node"); - URL nodeFileURL = FileLocator.toFileURL(nodeURL); - return Paths.get(nodeFileURL.toURI()); + return resolvePath("/node"); } public static Path getTileserverMapnikRoot() throws IOException, URISyntaxException { - URL serverURL = getContext().getBundle().getEntry("/server"); - URL serverFileURL = FileLocator.toFileURL(serverURL); - return Paths.get(serverFileURL.toURI()); + return resolvePath("/server"); + } + + private static Path resolvePath(String entry) throws IOException, URISyntaxException { + URL entryURL = getContext().getBundle().getEntry(entry); + URL entryFileURL = FileLocator.toFileURL(entryURL); + URI encodedUri = new URI(entryFileURL.getProtocol(), entryFileURL.getPath(), null).normalize(); + return Paths.get(encodedUri); + } + + public static Activator getDefault() { + return defaultt; } }