]> gerrit.simantics Code Review - simantics/python.git/blob - org.simantics.pythonlink/src/org/simantics/pythonlink/Activator.java
Report and log failure of Python DLL loading
[simantics/python.git] / org.simantics.pythonlink / src / org / simantics / pythonlink / Activator.java
1 package org.simantics.pythonlink;\r
2 \r
3 import org.osgi.framework.BundleActivator;\r
4 import org.osgi.framework.BundleContext;\r
5 import org.slf4j.Logger;\r
6 import org.slf4j.LoggerFactory;\r
7 \r
8 public class Activator implements BundleActivator {\r
9 \r
10         private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);\r
11         private static BundleContext context;\r
12 \r
13         private static boolean loaded = false;\r
14         \r
15         static BundleContext getContext() {\r
16                 return context;\r
17         }\r
18 \r
19         /*\r
20          * (non-Javadoc)\r
21          * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r
22          */\r
23         public void start(BundleContext bundleContext) throws Exception {\r
24                 Activator.context = bundleContext;\r
25                 try {\r
26                         System.loadLibrary("jnipython");\r
27                         loaded = true;\r
28                 } catch (Exception e) {\r
29                         LOGGER.error("Loading of jnipython.dll failed", e);\r
30                 }\r
31         }\r
32         \r
33         public static boolean isPythonLoaded() {\r
34                 return loaded;\r
35         }\r
36 \r
37         /*\r
38          * (non-Javadoc)\r
39          * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
40          */\r
41         public void stop(BundleContext bundleContext) throws Exception {\r
42                 Activator.context = null;\r
43         }\r
44 \r
45 }\r