blob: 2db4590e301241de0ac2fa131ab37b02ccdeae8d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package tools.refinery.language.web;
import org.eclipse.xtext.ide.ExecutorServiceProvider;
import org.eclipse.xtext.util.DisposableRegistry;
import org.eclipse.xtext.util.Modules2;
import com.google.inject.Guice;
import com.google.inject.Injector;
import tools.refinery.language.ide.ProblemIdeModule;
import tools.refinery.language.tests.ProblemInjectorProvider;
import tools.refinery.language.web.xtext.servlet.AwaitTerminationExecutorServiceProvider;
public class ProblemWebInjectorProvider extends ProblemInjectorProvider {
protected Injector internalCreateInjector() {
return new ProblemWebSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(
Modules2.mixin(createRuntimeModule(), new ProblemIdeModule(), createWebModule()));
}
}.createInjectorAndDoEMFRegistration();
}
protected ProblemWebModule createWebModule() {
// Await termination of the executor service to avoid race conditions between
// the tasks in the service and the {@link
// org.eclipse.xtext.testing.extensions.InjectionExtension}.
return new ProblemWebModule() {
@SuppressWarnings("unused")
public Class<? extends ExecutorServiceProvider> bindExecutorServiceProvider() {
return AwaitTerminationExecutorServiceProvider.class;
}
};
}
@Override
public void restoreRegistry() {
// Also make sure to dispose any IDisposable instances (that may depend on the
// global state) created by Xtext before restoring the global state.
var disposableRegistry = getInjector().getInstance(DisposableRegistry.class);
disposableRegistry.dispose();
super.restoreRegistry();
}
}
|