當前位置: 首頁>>代碼示例>>Java>>正文


Java Injector.injectMembers方法代碼示例

本文整理匯總了Java中com.google.inject.Injector.injectMembers方法的典型用法代碼示例。如果您正苦於以下問題:Java Injector.injectMembers方法的具體用法?Java Injector.injectMembers怎麽用?Java Injector.injectMembers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.inject.Injector的用法示例。


在下文中一共展示了Injector.injectMembers方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTest

import com.google.inject.Injector; //導入方法依賴的package包/類
/**
 * Implements behavior from: org.junit.runners.Parameterized$TestClassRunnerForParameters
 * org.eclipse.xtext.testing.XtextRunner
 */
@Override
public Object createTest() throws Exception {
	Object object;
	// Functionality of
	// org.junit.runners.Parameterized$TestClassRunnerForParameters
	if (fieldsAreAnnotated()) {
		object = createTestUsingFieldInjection();
	} else {
		object = createTestUsingConstructorInjection();
	}

	// Functionality of org.eclipse.xtext.testing.XtextRunner
	IInjectorProvider injectorProvider = getOrCreateInjectorProvider();
	if (injectorProvider != null) {
		Injector injector = injectorProvider.getInjector();
		if (injector != null)
			injector.injectMembers(object);
	}
	return object;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:25,代碼來源:XtextParametrizedRunner.java

示例2: setUp

import com.google.inject.Injector; //導入方法依賴的package包/類
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(
          Modules.override(
                  new DatasetModule(), new CannedDatasetsModule(), new ConfigurationModule())
              .with(
                  new MongoOverrideModule(),
                  new AbstractModule() {
                    @Override
                    protected void configure() {
                      bind(CannedDatasetsLoader.class)
                          .toInstance(Mockito.mock(CannedDatasetsLoader.class));
                    }
                  }));
  injector.injectMembers(this);

  when(mongoProvider.provide()).thenReturn(getMongoClient());
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:20,代碼來源:MongoCannedDatasetsWriterTest.java

示例3: start

import com.google.inject.Injector; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws IOException {
    Module module = new ETUmulatorModule();
    Injector injector = Guice.createInjector(module);

    primaryStage.setTitle("ETUmulator");
    ClassLoader classLoader = ETUmulator.class.getClassLoader();
    FXMLLoader fxmlLoader = new FXMLLoader(classLoader.getResource("fxml/ETUmulator.fxml"));
    fxmlLoader.setControllerFactory(injector::getInstance);
    Parent root = (Parent) fxmlLoader.load();
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();

    injector.injectMembers(this);
    fileMenuController.setWindow(primaryStage.getOwner());

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            processor.stop();
        }
    });
    primaryStage.setOnCloseRequest((event) -> {
        processor.terminate();
        primaryStage.close();
    });
}
 
開發者ID:kasirgalabs,項目名稱:ETUmulator,代碼行數:29,代碼來源:ETUmulator.java

示例4: configureGuice

import com.google.inject.Injector; //導入方法依賴的package包/類
private Injector configureGuice(T configuration, Environment environment) throws Exception {
  // setup our core modules...
  appModules.add(new MetricRegistryModule(environment.metrics()));
  appModules.add(new ServletModule());
  // ...and add the app's modules
  appModules.addAll(addModules(configuration, environment));

  final Injector injector = Guice.createInjector(ImmutableList.copyOf(this.appModules));

  // Taken from https://github.com/Squarespace/jersey2-guice/wiki#complex-example. HK2 is no fun.
  JerseyGuiceUtils.install((name, parent) -> {
    if (!name.startsWith("__HK2_Generated_")) {
      return null;
    }

    return injector.createChildInjector(Lists.newArrayList(new JerseyGuiceModule(name)))
        .getInstance(ServiceLocator.class);
  });

  injector.injectMembers(this);
  registerWithInjector(environment, injector);
  return injector;
}
 
開發者ID:dehora,項目名稱:outland,代碼行數:24,代碼來源:GuiceApplication.java

示例5: actionPerformed

import com.google.inject.Injector; //導入方法依賴的package包/類
@Override
public void actionPerformed(@Nonnull AnActionEvent event) {
    if (!isAvailable(event)) {
        return;
    }

    project = event.getProject();
    ideView = event.getData(DataKeys.IDE_VIEW);

    final Injector injector = GuiceManager.getInstance(project).getInjector();
    injector.injectMembers(this);

    // 'selected' is null when directory selection is canceled although multiple directories are chosen.
    final PsiDirectory selected = ideView.getOrChooseDirectory();
    if (selected == null) {
        return;
    }

    final NewClassDialog dialog = NewClassDialog.builder(project, bundle)
            .nameValidator(nameValidatorProvider.get())
            .jsonValidator(jsonValidatorProvider.get())
            .actionListener(this)
            .build();
    dialog.show();
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:26,代碼來源:NewClassAction.java

示例6: initInjection

import com.google.inject.Injector; //導入方法依賴的package包/類
/** Creates the injector for the test and injects all fields with the initialized injector. */
private void initInjection(Properties properties) {

	// STEP 1: set up language N4JS

	// the following is doing roughly the same as N4JSStandaloneSetup.doSetup(), but is using a custom-built
	// Guice module for injector creation:

	TypesPackage.eINSTANCE.getNsURI();
	TypeRefsPackage.eINSTANCE.getNsURI();
	N4JSPackage.eINSTANCE.getNsURI();
	N4mfPackage.eINSTANCE.getNsURI();
	XMLTypePackage.eINSTANCE.getNsURI();

	// combine all modules for N4JSC
	final Module combinedModule = Modules.combine(new N4JSRuntimeModule(), new TesterModule(),
			new N4JSHeadlessGeneratorModule(properties));

	// override with customized bindings
	final Module overridenModule = Modules.override(combinedModule).with(binder -> {
		binder.bind(TestTreeTransformer.class)
				.to(CliTestTreeTransformer.class);
		binder.bind(IHeadlessLogger.class)
				.toInstance(new ConfigurableHeadlessLogger(verbose, debug));
	});

	RegularExpressionStandaloneSetup.doSetup();
	TypesStandaloneSetup.doSetup();
	N4MFStandaloneSetup.doSetup();
	TypeExpressionsStandaloneSetup.doSetup();

	final Injector injector = Guice.createInjector(overridenModule);
	new N4JSStandaloneSetup().register(injector);
	injector.injectMembers(this);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:36,代碼來源:N4jscBase.java

示例7: start

import com.google.inject.Injector; //導入方法依賴的package包/類
@BeforeEach
@SuppressWarnings("unchecked")
public void start() {
  Injector injector =
      Guice.createInjector(
          Modules.override(new DragomanModule()).with(new RestOverridesModule()));
  injector.injectMembers(this);

  startHttpServer();
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:11,代碼來源:AbstractResourceTest.java

示例8: setUp

import com.google.inject.Injector; //導入方法依賴的package包/類
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(
          Modules.override(new DatasetModule(), new ConfigurationModule())
              .with(new MongoOverrideModule()));
  injector.injectMembers(this);

  when(mongoProvider.provide()).thenReturn(getMongoClient());
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:11,代碼來源:MongoDatasetDaoTest.java

示例9: setUp

import com.google.inject.Injector; //導入方法依賴的package包/類
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(
          Modules.override(new AuthenticationModule(), new ConfigurationModule())
              .with(new MongoOverrideModule()));
  injector.injectMembers(this);

  when(mongoProvider.provide()).thenReturn(getMongoClient());
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:11,代碼來源:MongoAuthenticationDaoTest.java

示例10: setUp

import com.google.inject.Injector; //導入方法依賴的package包/類
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(
          Modules.override(new MongoModule(), new ConfigurationModule())
              .with(new MongoOverrideModule()));
  injector.injectMembers(this);

  bill =
      new Document("name", "Bill")
          .append("type", "Human")
          .append("age", 35)
          .append("biped", true)
          .append("shoeSize", 9)
          .append("rating", 1.2)
          .append("comments", "likes pianos")
          .append("expirationDate", toDate(LocalDate.parse("2017-10-27").plusYears(10)))
          .append("createdAt", toDate(LocalDateTime.now()));

  martin =
      new Document("name", "Martin")
          .append("type", "Martian")
          .append("age", 1156)
          .append("biped", false)
          .append("shoeSize", 4.5)
          .append("rating", null)
          .append("comments", "interplanetary travel")
          .append("expirationDate", toDate(LocalDate.parse("2017-10-27").plusYears(100)))
          .append("createdAt", toDate(LocalDateTime.now()));

  storageCoordinates = seed(bill, martin);

  dataset = mock(Dataset.class);
  when(dataset.getSource())
      .thenReturn(
          storageCoordinates.getDatabaseName() + ":" + storageCoordinates.getCollectionName());

  when(mongoProvider.provide()).thenReturn(getMongoClient());
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:40,代碼來源:MongoRepositoryTest.java

示例11: setUp

import com.google.inject.Injector; //導入方法依賴的package包/類
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(Modules.override(new HttpModule()).with(new HttpOverrideModule()));
  injector.injectMembers(this);

  bill = Maps.newHashMap();
  bill.put("name", "Bill");
  bill.put("type", "Human");
  bill.put("age", 35);
  bill.put("biped", true);
  bill.put("shoeSize", 9);
  bill.put("rating", 1.2);
  bill.put("comments", "likes pianos");
  bill.put("expirationDate", "2027-10-27");
  bill.put("createdAt", LocalDateTime.now().toString());

  martin = Maps.newHashMap();
  martin.put("name", "Martin");
  martin.put("type", "Martian");
  martin.put("age", 1156);
  martin.put("biped", false);
  martin.put("shoeSize", 4.5);
  martin.put("rating", null);
  martin.put("comments", "interplanetary travel");
  martin.put("expirationDate", "2117-10-27");
  martin.put("createdAt", LocalDateTime.now().toString());

  when(httpDataProvider.getAll()).thenReturn(Lists.newArrayList(bill, martin));

  dataset = mock(Dataset.class);
  // point us at the in-process HTTP server
  when(dataset.getSource()).thenReturn(getUrl());
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:35,代碼來源:HttpRepositoryTest.java

示例12: setInitParameters

import com.google.inject.Injector; //導入方法依賴的package包/類
/**
 * Inject some values that might have been configured at bind-time.
 * Override web.xml <init-param> settings in each case that injection
 * is successful.
 */
private void setInitParameters(ModifiableServletConfig config)
{
    Injector injector = getInjector();
    InjectedConfig cfg = new InjectedConfig(config);
    injector.injectMembers(cfg);
    cfg.setParameters();
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:13,代碼來源:DwrGuiceServlet.java

示例13: beforeTestExecution

import com.google.inject.Injector; //導入方法依賴的package包/類
@Override
public void beforeTestExecution(ExtensionContext context) throws Exception {
	IInjectorProvider injectorProvider = getOrCreateInjectorProvider(context);
	if (injectorProvider instanceof IRegistryConfigurator) {
		final IRegistryConfigurator registryConfigurator = (IRegistryConfigurator) injectorProvider;
		registryConfigurator.setupRegistry();
	}
	if (injectorProvider != null) {
		Injector injector = injectorProvider.getInjector();
		if (injector != null)
			injector.injectMembers(context.getRequiredTestInstance());
	}
}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:14,代碼來源:InjectionExtension.java

示例14: N4IDEXpectFileSetup

import com.google.inject.Injector; //導入方法依賴的package包/類
/**
 * Creates setup with provided context. Adds members to provided injector.
 */
public N4IDEXpectFileSetup(FileSetupContext ctx, Injector injector) {
	this.ctx = ctx;
	injector.injectMembers(this);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:8,代碼來源:N4IDEXpectFileSetup.java

示例15: Dragoman

import com.google.inject.Injector; //導入方法依賴的package包/類
/** Instances the Guice injector, passing in the main configuration module. */
private Dragoman() {
  Injector injector = Guice.createInjector(new DragomanModule());
  injector.injectMembers(this);
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:6,代碼來源:Dragoman.java


注:本文中的com.google.inject.Injector.injectMembers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。