]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/Activator.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.reflection / src / org / simantics / scl / reflection / internal / Activator.java
1 package org.simantics.scl.reflection.internal;
2
3 import org.eclipse.core.runtime.ILog;
4 import org.eclipse.core.runtime.Platform;
5 import org.eclipse.core.runtime.Status;
6 import org.osgi.framework.Bundle;
7 import org.osgi.framework.BundleActivator;
8 import org.osgi.framework.BundleContext;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11
12 public class Activator implements BundleActivator {
13
14     private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
15     private BundleContext context;  
16     
17     private static Activator instance;
18     
19     @Override
20     public void start(BundleContext context) throws Exception {
21         this.context = context;
22         instance = this;
23     }
24
25     @Override
26     public void stop(BundleContext context) throws Exception {
27         instance = null;
28         this.context = null;
29     }
30     
31     public BundleContext getContext() {
32         return context;
33     }
34     
35     public static Activator getInstance() {
36         return instance;
37     }
38         
39     public static void logError(String description, Exception e) {
40         LOGGER.error(description);
41         if(e != null)
42             e.printStackTrace();
43         Bundle bundle = getInstance().getContext().getBundle();
44         ILog log = Platform.getLog(bundle);
45         log.log(new Status(Status.ERROR, bundle.getSymbolicName(), description, e));
46     }
47     
48     public static void logError(String description) {
49         logError(description, null);
50     }
51
52 }