]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/Activator.java
d7a9e9e7f771f2802a15ad0b8d13beeae9868cbf
[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     private static BundleContext context;
17
18     public static BundleContext getContext() {
19         return context;
20     }
21
22     @SuppressWarnings({ "rawtypes", "unchecked" })
23     public void start(BundleContext bundleContext) throws Exception {
24         Activator.context = bundleContext;
25
26         Hashtable properties = new Hashtable();
27         bundleContext.registerService(ModuleSourceRepository.class,
28                 SourceRepositories.BUILTIN_SOURCE_REPOSITORY,
29                 properties);
30         bundleContext.registerService(ModuleSourceRepository.class,
31                 new ProceduralModuleSourceRepository() {
32                     @Override
33                     protected ModuleRepository getModuleRepository(UpdateListener listener) {
34                         return SCLOsgi.MODULE_REPOSITORY;
35                     }
36                 },
37                 properties);
38     }
39
40     public void stop(BundleContext bundleContext) throws Exception {
41         Activator.context = null;
42     }
43
44 }