Modify pom file
[nemo.git] / nemo-tools / eclipse-plugin / nemo-editor / org.opendaylight.nemo.tool.eclipse.plugin.editor.tests / src-gen / org / opendaylight / nemo / tool / eclipse / plugin / EditorInjectorProvider.java
1 /*
2  * generated by Xtext
3  */
4 package org.opendaylight.nemo.tool.eclipse.plugin;
5
6 import org.eclipse.xtext.junit4.GlobalRegistries;
7 import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
8 import org.eclipse.xtext.junit4.IInjectorProvider;
9 import org.eclipse.xtext.junit4.IRegistryConfigurator;
10
11 import com.google.inject.Injector;
12
13 public class EditorInjectorProvider 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         @Override
24         public Injector getInjector()
25         {
26                 if (injector == null) {
27                         stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
28                         this.injector = internalCreateInjector();
29                         stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
30                 }
31                 return injector;
32         }
33         
34         protected Injector internalCreateInjector() {
35             return new EditorStandaloneSetup().createInjectorAndDoEMFRegistration();
36         }
37
38         @Override
39         public void restoreRegistry() {
40                 stateBeforeInjectorCreation.restoreGlobalState();
41         }
42
43         @Override
44         public void setupRegistry() {
45                 getInjector();
46                 stateAfterInjectorCreation.restoreGlobalState();
47         }
48 }