Package injectorProvider

Source Code of injectorProvider.InjectorProviderCustom

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;
  }
}
TOP

Related Classes of injectorProvider.InjectorProviderCustom

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.