|
Last change
on this file was
61,
checked in by hkaulbersch, 12 years ago
|
|
initial commit
|
-
Property svn:mime-type set to
text/plain
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | /* |
|---|
| 2 | * generated by Xtext |
|---|
| 3 | */ |
|---|
| 4 | package de.ugoe.cs.swe.bnftools; |
|---|
| 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 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.