]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/src/org/simantics/district/maps/server/Activator.java
eaeda86acb88b6acf71432b556a3aa81d5d42aed
[simantics/district.git] / org.simantics.maps.server / src / org / simantics / district / maps / server / Activator.java
1 package org.simantics.district.maps.server;
2
3 import java.io.IOException;
4 import java.net.URISyntaxException;
5 import java.net.URL;
6 import java.nio.file.Path;
7 import java.nio.file.Paths;
8
9 import org.eclipse.core.runtime.FileLocator;
10 import org.osgi.framework.BundleActivator;
11 import org.osgi.framework.BundleContext;
12
13 public class Activator implements BundleActivator {
14
15     public static final String PLUGIN_ID = "org.simantics.maps.server";
16     private static BundleContext context;
17
18     static BundleContext getContext() {
19         return context;
20     }
21
22     /*
23      * (non-Javadoc)
24      * 
25      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.
26      * BundleContext)
27      */
28     public void start(BundleContext bundleContext) throws Exception {
29         Activator.context = bundleContext;
30     }
31
32     /*
33      * (non-Javadoc)
34      * 
35      * @see
36      * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
37      */
38     public void stop(BundleContext bundleContext) throws Exception {
39         Activator.context = null;
40     }
41
42     public static Path getNodeJSRoot() throws IOException, URISyntaxException {
43         URL nodeURL = getContext().getBundle().getEntry("/node");
44         URL nodeFileURL = FileLocator.toFileURL(nodeURL);
45         return Paths.get(nodeFileURL.toURI());
46     }
47     
48     public static Path getTileserverMapnikRoot() throws IOException, URISyntaxException {
49         URL serverURL = getContext().getBundle().getEntry("/server");
50         URL serverFileURL = FileLocator.toFileURL(serverURL);
51         return Paths.get(serverFileURL.toURI());
52     }
53
54 }