]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/Activator.java
SCL expressions to SCL Issues view
[simantics/platform.git] / bundles / org.simantics.scl.osgi / src / org / simantics / scl / osgi / internal / Activator.java
1 package org.simantics.scl.osgi.internal;
2
3 import java.util.Hashtable;
4
5 import org.osgi.framework.BundleActivator;
6 import org.osgi.framework.BundleContext;
7 import org.simantics.scl.compiler.module.repository.ModuleRepository;
8 import org.simantics.scl.compiler.module.repository.UpdateListener;
9 import org.simantics.scl.compiler.source.repository.ModuleSourceRepository;
10 import org.simantics.scl.compiler.source.repository.ProceduralModuleSourceRepository;
11 import org.simantics.scl.compiler.source.repository.SourceRepositories;
12 import org.simantics.scl.osgi.SCLOsgi;
13
14 public class Activator implements BundleActivator {
15
16     public static final String PLUGIN_ID = "org.simantics.scl.osgi";
17
18     private static BundleContext context;
19
20     public static BundleContext getContext() {
21         return context;
22     }
23
24     @SuppressWarnings({ "rawtypes", "unchecked" })
25     public void start(BundleContext bundleContext) throws Exception {
26         Activator.context = bundleContext;
27
28         Hashtable properties = new Hashtable();
29         bundleContext.registerService(ModuleSourceRepository.class,
30                 SourceRepositories.BUILTIN_SOURCE_REPOSITORY,
31                 properties);
32         bundleContext.registerService(ModuleSourceRepository.class,
33                 new ProceduralModuleSourceRepository() {
34                     @Override
35                     protected ModuleRepository getModuleRepository(UpdateListener listener) {
36                         return SCLOsgi.MODULE_REPOSITORY;
37                     }
38                 },
39                 properties);
40     }
41
42     public void stop(BundleContext bundleContext) throws Exception {
43         Activator.context = null;
44     }
45
46 }