1 package org.simantics.scl.reflection.internal;
3 import java.util.concurrent.ForkJoinPool;
5 import org.eclipse.core.runtime.ILog;
6 import org.eclipse.core.runtime.Platform;
7 import org.eclipse.core.runtime.Status;
8 import org.osgi.framework.Bundle;
9 import org.osgi.framework.BundleActivator;
10 import org.osgi.framework.BundleContext;
11 import org.simantics.scl.reflection.internal.registry.BindingRegistry;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public class Activator implements BundleActivator {
17 private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
18 private BundleContext context;
20 private static Activator instance;
23 public void start(BundleContext context) throws Exception {
24 this.context = context;
27 primeBindingRegistry();
30 private static void primeBindingRegistry() {
31 LOGGER.info("Priming BindingRegistry");
32 ForkJoinPool.commonPool().submit(() -> {
34 // this forces static initialzation of the registry in advance
35 BindingRegistry.primeBindingRegistry();
36 } catch (Exception e) {
37 LOGGER.error("Could not prime binding registry", e);
39 LOGGER.info("Priming done");
44 public void stop(BundleContext context) throws Exception {
49 public BundleContext getContext() {
53 public static Activator getInstance() {
57 public static void logError(String description, Exception e) {
58 LOGGER.error(description);
61 Bundle bundle = getInstance().getContext().getBundle();
62 ILog log = Platform.getLog(bundle);
63 log.log(new Status(Status.ERROR, bundle.getSymbolicName(), description, e));
66 public static void logError(String description) {
67 logError(description, null);