SmachDSLInjectorProvider.java
Go to the documentation of this file.
00001 /*
00002 * generated by Xtext
00003 */
00004 package org.best.of.robotics;
00005 
00006 import org.eclipse.xtext.junit4.GlobalRegistries;
00007 import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento;
00008 import org.eclipse.xtext.junit4.IInjectorProvider;
00009 import org.eclipse.xtext.junit4.IRegistryConfigurator;
00010 
00011 import com.google.inject.Injector;
00012 
00013 public class SmachDSLInjectorProvider implements IInjectorProvider, IRegistryConfigurator {
00014         
00015     protected GlobalStateMemento stateBeforeInjectorCreation;
00016         protected GlobalStateMemento stateAfterInjectorCreation;
00017         protected Injector injector;
00018 
00019         static {
00020                 GlobalRegistries.initializeDefaults();
00021         }
00022 
00023         public Injector getInjector()
00024         {
00025                 if (injector == null) {
00026                         stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
00027                         this.injector = internalCreateInjector();
00028                         stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
00029                 }
00030                 return injector;
00031         }
00032         
00033         protected Injector internalCreateInjector() {
00034             return new SmachDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
00035         }
00036 
00037         public void restoreRegistry() {
00038                 stateBeforeInjectorCreation.restoreGlobalState();
00039         }
00040 
00041         public void setupRegistry() {
00042                 getInjector();
00043                 stateAfterInjectorCreation.restoreGlobalState();
00044         }
00045 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


bride_plugin_source
Author(s): Alexander Bubeck
autogenerated on Wed Aug 14 2013 10:06:09