1 package org.simantics.district.maps.server;
3 import java.io.IOException;
5 import java.net.URISyntaxException;
7 import java.nio.file.Path;
8 import java.nio.file.Paths;
10 import org.eclipse.core.runtime.FileLocator;
11 import org.osgi.framework.BundleActivator;
12 import org.osgi.framework.BundleContext;
14 public class Activator implements BundleActivator {
16 public static final String PLUGIN_ID = "org.simantics.maps.server";
17 private static BundleContext context;
19 static BundleContext getContext() {
26 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
29 public void start(BundleContext bundleContext) throws Exception {
30 Activator.context = bundleContext;
37 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
39 public void stop(BundleContext bundleContext) throws Exception {
40 Activator.context = null;
43 public static Path getNodeJSRoot() throws IOException, URISyntaxException {
44 return resolvePath("/node");
47 public static Path getTileserverMapnikRoot() throws IOException, URISyntaxException {
48 return resolvePath("/server");
51 private static Path resolvePath(String entry) throws IOException, URISyntaxException {
52 URL entryURL = getContext().getBundle().getEntry(entry);
53 URL entryFileURL = FileLocator.toFileURL(entryURL);
54 URI encodedUri = new URI(entryFileURL.getProtocol(), entryFileURL.getPath(), null).normalize();
55 return Paths.get(encodedUri);