]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/Activator.java
8bfea3dbea9fb3291b4716b408a5f0921375d590
[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
10 public class Activator implements BundleActivator {
11
12     private BundleContext context;  
13     
14     private static Activator instance;
15     
16     @Override
17     public void start(BundleContext context) throws Exception {
18         this.context = context;
19         instance = this;
20     }
21
22     @Override
23     public void stop(BundleContext context) throws Exception {
24         instance = null;
25         this.context = null;
26     }
27     
28     public BundleContext getContext() {
29         return context;
30     }
31     
32     public static Activator getInstance() {
33         return instance;
34     }
35         
36     public static void logError(String description, Exception e) {
37         System.err.println(description);
38         if(e != null)
39             e.printStackTrace();
40         Bundle bundle = getInstance().getContext().getBundle();
41         ILog log = Platform.getLog(bundle);
42         log.log(new Status(Status.ERROR, bundle.getSymbolicName(), description, e));
43     }
44     
45     public static void logError(String description) {
46         logError(description, null);
47     }
48
49 }