当前位置: 首页>>代码示例>>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;未经允许,请勿转载。