source: default/v2/trunk/de.ugoe.cs.swe.bnftools.ebnf.tests/src-gen/de/ugoe/cs/swe/bnftools/EbnfInjectorProvider.java @ 61

Last change on this file since 61 was 61, checked in by hkaulbersch, 10 years ago

initial commit

  • Property svn:mime-type set to text/plain
File size: 1.2 KB
Line 
1/*
2* generated by Xtext
3*/
4package de.ugoe.cs.swe.bnftools;
5
6import org.eclipse.xtext.junit4.GlobalRegistries;
7import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
8import org.eclipse.xtext.junit4.IInjectorProvider;
9import org.eclipse.xtext.junit4.IRegistryConfigurator;
10
11import com.google.inject.Injector;
12
13public class EbnfInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
14       
15    protected GlobalStateMemento stateBeforeInjectorCreation;
16        protected GlobalStateMemento stateAfterInjectorCreation;
17        protected Injector injector;
18
19        static {
20                GlobalRegistries.initializeDefaults();
21        }
22
23        public Injector getInjector()
24        {
25                if (injector == null) {
26                        stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
27                        this.injector = internalCreateInjector();
28                        stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
29                }
30                return injector;
31        }
32       
33        protected Injector internalCreateInjector() {
34            return new EbnfStandaloneSetup().createInjectorAndDoEMFRegistration();
35        }
36
37        public void restoreRegistry() {
38                stateBeforeInjectorCreation.restoreGlobalState();
39        }
40
41        public void setupRegistry() {
42                getInjector();
43                stateAfterInjectorCreation.restoreGlobalState();
44        }
45}
Note: See TracBrowser for help on using the repository browser.