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;
18 private static Activator defaultt;
20 static BundleContext getContext() {
27 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
30 public void start(BundleContext bundleContext) throws Exception {
31 Activator.context = bundleContext;
32 Activator.defaultt = this;
39 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
41 public void stop(BundleContext bundleContext) throws Exception {
42 Activator.context = null;
43 Activator.defaultt = null;
46 public static Path getNodeJSRoot() throws IOException, URISyntaxException {
47 return resolvePath("/node");
50 public static Path getTileserverMapnikRoot() throws IOException, URISyntaxException {
51 return resolvePath("/server");
54 private static Path resolvePath(String entry) throws IOException, URISyntaxException {
55 URL entryURL = getContext().getBundle().getEntry(entry);
56 URL entryFileURL = FileLocator.toFileURL(entryURL);
57 URI encodedUri = new URI(entryFileURL.getProtocol(), entryFileURL.getPath(), null).normalize();
58 return Paths.get(encodedUri);
61 public static Activator getDefault() {