package injectorProvider;
import net.sf.co_op.coopiii.CoopIIIInjectorProvider;
import net.sf.co_op.coopiii.CoopIIIRuntimeModule;
import net.sf.co_op.coopiii.CoopIIIStandaloneSetup;
import org.eclipse.xtext.junit4.GlobalRegistries;
import com.google.inject.Guice;
import com.google.inject.Injector;
public class InjectorProviderCustom extends CoopIIIInjectorProvider {
public Injector getInjector() {
if (injector == null) {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
this.injector = new CoopIIIStandaloneSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(new CoopIIIRuntimeModule() {
@Override
public ClassLoader bindClassLoaderToInstance() {
return InjectorProviderCustom.class
.getClassLoader();
}
});
}
}.createInjectorAndDoEMFRegistration();
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}
}