]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/RuntimeEnvironmentImpl.java
Merge commit 'fd452722e97db9cf876f4f03a9e44fe750625a92'
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / runtime / RuntimeEnvironmentImpl.java
1 package org.simantics.scl.compiler.runtime;
2
3 import java.util.Collection;
4
5 import org.simantics.scl.compiler.environment.Environment;
6
7 import gnu.trove.map.hash.THashMap;
8
9 public class RuntimeEnvironmentImpl implements RuntimeEnvironment {
10
11     private final Environment environment;
12     private final THashMap<String, RuntimeModule> runtimeModuleMap;
13     private final ClassLoader parentClassLoader;
14     private MutableClassLoader classLoader;
15     
16     public RuntimeEnvironmentImpl(Environment environment,
17             ClassLoader parentClassLoader,
18             THashMap<String, RuntimeModule> runtimeModuleMap) {
19         this.environment = environment;
20         this.parentClassLoader = parentClassLoader;
21         this.runtimeModuleMap = runtimeModuleMap;
22     }
23
24     @Override
25     public Environment getEnvironment() {
26         return environment;
27     }
28
29     @Override
30     public RuntimeModule getRuntimeModule(String name) {
31         return runtimeModuleMap.get(name);
32     }
33
34     @Override
35     public synchronized MutableClassLoader getMutableClassLoader() {
36         if(classLoader == null)
37             classLoader = new ExpressionClassLoader(
38                     parentClassLoader, runtimeModuleMap, "Expression");
39         return classLoader;
40     }
41
42     @Override
43     public Collection<RuntimeModule> getRuntimeModules() {
44         return runtimeModuleMap.values();
45     }
46
47 }