Java 类com.google.inject.Guice 实例源码

项目:jedai-ui    文件:WizardMain.java   
@Override
public void start(Stage primaryStage) throws Exception {
    final Injector injector = Guice.createInjector(new WizardModule());

    final URL fxml = WizardMain.class.getClassLoader().getResource("wizard-fxml/Wizard.fxml");

    if (fxml != null) {
        final Parent p = FXMLLoader.load(fxml,
                null,
                new JavaFXBuilderFactory(),
                injector::getInstance
        );

        final Scene scene = new Scene(p);

        primaryStage.setScene(scene);
        primaryStage.setWidth(800);
        primaryStage.setHeight(600);
        primaryStage.setTitle("Java gEneric DAta Integration (JedAI) Toolkit");

        primaryStage.show();
    }
}
项目:nifi-config    文件:MainTest.java   
@Test(expected = ConfigException.class)
public void mainExceptionTest() throws Exception {
    Injector injector = Guice.createInjector(new AbstractModule() {
        protected void configure() {
            bind(AccessService.class).toInstance(accessServiceMock);
            bind(InformationService.class).toInstance(informationServiceMock);
            bind(TemplateService.class).toInstance(templateServiceMock);
            bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(10);
            bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(10);
            bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
            bind(Double.class).annotatedWith(Names.named("placeWidth")).toInstance(1200d);
            bind(PositionDTO.class).annotatedWith(Names.named("startPosition")).toInstance(new PositionDTO());
        }
    });
    //given
    PowerMockito.mockStatic(Guice.class);
    Mockito.when(Guice.createInjector((AbstractModule)anyObject())).thenReturn(injector);
    doThrow(new ApiException()).when(accessServiceMock).addTokenOnConfiguration(false, null ,null);
    Main.main(new String[]{"-nifi","http://localhost:8080/nifi-api","-branch","\"root>N2\"","-conf","adr","-m","undeploy"});
}
项目:nifi-config    文件:PortServiceTest.java   
@Test
public void getByIdOutputTest() throws ApiException, IOException, URISyntaxException {
    Injector injector = Guice.createInjector(new AbstractModule() {
        protected void configure() {
            bind(InputPortsApi.class).toInstance(inputPortsApiMock);
            bind(OutputPortsApi.class).toInstance(outputPortsApiMock);
            bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(1);
            bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(1);
            bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
        }
    });
    PortService portService = injector.getInstance(PortService.class);
    PortEntity port = new PortEntity();
    port.setComponent(new PortDTO());
    port.getComponent().setId("id");
    when(outputPortsApiMock.getOutputPort("id")).thenReturn(port);
    PortEntity portResult = portService.getById("id", PortDTO.TypeEnum.OUTPUT_PORT);
    assertEquals("id", portResult.getComponent().getId());
}
项目:Equella    文件:GuicePlugin.java   
@Override
protected Injector doWork() throws Exception
{
    long start = System.currentTimeMillis();
    Iterable<URL> localClassPath = privatePluginService.getLocalClassPath(pluginId);
    final ClassLoader classLoader = privatePluginService.getClassLoader(pluginId);
    Collection<Parameter> params = extension.getParameters("class");
    List<Module> modules = new ArrayList<Module>();
    for( Parameter param : params )
    {
        Module module = (Module) privatePluginService.getBean(pluginId, param.valueAsString());
        modules.add(module);
    }

    modules.add(new ScannerModule(privatePluginService, classLoader, localClassPath, getBeanCheckers()));
    modules.add(new Jsr250Module());
    injector = Guice.createInjector(new ExternalProviders(getDependents(), modules));
    long end = System.currentTimeMillis();
    LOGGER.info("Guice module for " + pluginId + " took:" + (end - start));
    return injector;
}
项目:violet    文件:LazyTest.java   
@Test
public void testSingletonInScopeProvider() {
  final Injector injector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      this.bind(SingletonThing.class).in(LazySingleton.SCOPE);
    }
  });

  assertEquals(SingletonThing.CONSTRUCTION_COUNT.get(), 0);
  final SingletonThingProvider provider = injector.getInstance(SingletonThingProvider.class);
  assertEquals(SingletonThing.CONSTRUCTION_COUNT.get(), 0);
  final SingletonThing a = provider.provider.get();
  assertEquals(SingletonThing.CONSTRUCTION_COUNT.get(), 1);
  final SingletonThing b = provider.provider.get();
  assertEquals(SingletonThing.CONSTRUCTION_COUNT.get(), 1);
  assertSame(a, b);
}
项目:nifi-config    文件:ProcessorServiceTest.java   
@Test
public void setStateAlreadyTest() {
    Injector injector = Guice.createInjector(new AbstractModule() {
        protected void configure() {
            bind(ProcessorsApi.class).toInstance(processorsApiMock);
            bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(1);
            bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(1);
            bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
        }
    });
    ProcessorService processorService = injector.getInstance(ProcessorService.class);
    ProcessorEntity processor = TestUtils.createProcessorEntity("id", "name");
    processor.getComponent().setState(ProcessorDTO.StateEnum.RUNNING);
    processorService.setState(processor, ProcessorDTO.StateEnum.RUNNING);
    verify(processorsApiMock, never()).updateProcessor(anyString(), anyObject());
}
项目:violet    文件:LazyTest.java   
@Test
public void testSingletonBoundScopeProvider() {
  final Injector injector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      this.bindScope(LazySingleton.class, LazySingleton.SCOPE);
    }
  });

  assertEquals(AnnotatedSingletonThing.CONSTRUCTION_COUNT.get(), 0);
  final AnnotatedSingletonThingProvider provider = injector.getInstance(AnnotatedSingletonThingProvider.class);
  assertEquals(AnnotatedSingletonThing.CONSTRUCTION_COUNT.get(), 0);
  final AnnotatedSingletonThing ap = provider.provider.get();
  assertEquals(AnnotatedSingletonThing.CONSTRUCTION_COUNT.get(), 1);
  final AnnotatedSingletonThing bp = provider.provider.get();
  assertEquals(AnnotatedSingletonThing.CONSTRUCTION_COUNT.get(), 1);
  assertSame(ap, bp);
}
项目:nifi-config    文件:MainTest.java   
@Test
public void mainUpdateWithPasswordTest() throws Exception {
    Injector injector = Guice.createInjector(new AbstractModule() {
        protected void configure() {
            bind(AccessService.class).toInstance(accessServiceMock);
            bind(InformationService.class).toInstance(informationServiceMock);
            bind(UpdateProcessorService.class).toInstance(updateProcessorServiceMock);
           // bind(ConnectionPortService.class).toInstance(createRouteServiceMock);
            bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(10);
            bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(10);
            bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
            bind(Double.class).annotatedWith(Names.named("placeWidth")).toInstance(1200d);
            bind(PositionDTO.class).annotatedWith(Names.named("startPosition")).toInstance(new PositionDTO());
        }
    });
    //given
    PowerMockito.mockStatic(Guice.class);
    Mockito.when(Guice.createInjector((AbstractModule)anyObject())).thenReturn(injector);

    Main.main(new String[]{"-nifi","http://localhost:8080/nifi-api","-branch","\"root>N2\"","-conf","adr","-m","updateConfig","-user","user","-password","password"});
    verify(updateProcessorServiceMock).updateByBranch(Arrays.asList("root","N2"), "adr",false);
}
项目:bromium    文件:DefaultModuleTest.java   
@Test
public void ifCommmandIsInvalidResponseExceptionIsThrown() throws IOException, URISyntaxException {
    String command = "invalid";
    Map<String, Object> opts = new HashMap<>();
    opts.put(BROWSER, CHROME);
    opts.put(DRIVER, chromedriverFile.getAbsolutePath());
    opts.put(APPLICATION, configurationFile.getAbsolutePath());
    opts.put(URL, localhostUrl);
    opts.put(CASE, caseFile.getAbsolutePath());
    opts.put(SCREEN, screenString);
    opts.put(TIMEOUT, timeoutString);
    opts.put(PRECISION, precisionString);
    Module module = new DefaultModule(command, opts);
    Injector injector = Guice.createInjector(module);

    try {
        IOProvider<ResponseFilter> instance = injector.getInstance(new Key<IOProvider<ResponseFilter>>() {});
        instance.get();
    } catch (ProvisionException e) {
        assertTrue(e.getCause() instanceof NoSuchCommandException);
    }
}
项目:grpc-mate    文件:TransportClientProviderTest.java   
@Before
public void setUp() throws Exception {
  String ip = esContainer.getContainerIpAddress();
  Integer transportPort = esContainer.getMappedPort(9300);
  MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
  memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
  Injector injector = Guice.createInjector(
      Modules.override(new ElasticSearchModule()).with(
          binder -> {
            binder.bind(Configuration.class).toInstance(memoryParams);
          }
      )
  );
  transportClientProvider = injector.getInstance(TransportClientProvider.class);
}
项目:violet    文件:DuplexTest.java   
@Test
public void testNotExposed() {
  final Injector injector = Guice.createInjector(new AbstractModule() {
    @Override
    protected void configure() {
      DuplexBinder.create(this.binder()).install(new DuplexModule() {
        @Override
        protected void configure() {
          this.bind(Thing.class).annotatedWith(Names.named("r0")).toInstance(new Thing("r0"));
        }
      });
    }
  });
  try {
    injector.getInstance(ShouldNotWork.class);
  } catch(final ConfigurationException expected) {
    final String message = expected.getMessage();
    if(message.contains("It was already configured on one or more child injectors or private modules")
      && message.contains("If it was in a PrivateModule, did you forget to expose the binding?")) {
      return;
    }
  }
  fail("should not be exposed");
}
项目:bromium    文件:DefaultModuleTest.java   
@Test
public void canCreateRecordBrowserProvider() throws IOException, URISyntaxException {
    String command = RECORD;
    Map<String, Object> opts = new HashMap<>();
    opts.put(DRIVER, chromedriverFile.getAbsolutePath());
    opts.put(APPLICATION, configurationFile.getAbsolutePath());
    opts.put(URL, localhostUrl);
    opts.put(OUTPUT, "output.json");
    opts.put(BROWSER, CHROME);
    opts.put(TIMEOUT, timeoutString);
    opts.put(SCREEN, screenString);
    Module module = new DefaultModule(command, opts);
    Injector injector = Guice.createInjector(module);
    IOURIProvider<RecordBrowser> instance = injector.getInstance(new Key<IOURIProvider<RecordBrowser>>() {});
    RecordBrowser recordBrowser = instance.get();

    // cleanup
    recordBrowser.cleanUp();
}
项目:bromium    文件:DefaultModuleTest.java   
@Test
public void ifCommmandIsInvalidExceptionIsThrown() throws IOException, URISyntaxException {
    String command = "invalid";
    Map<String, Object> opts = new HashMap<>();
    opts.put(BROWSER, CHROME);
    opts.put(DRIVER, chromedriverFile.getAbsolutePath());
    opts.put(APPLICATION, configurationFile.getAbsolutePath());
    opts.put(URL, localhostUrl);
    opts.put(CASE, caseFile.getAbsolutePath());
    opts.put(SCREEN, screenString);
    opts.put(TIMEOUT, timeoutString);
    opts.put(PRECISION, precisionString);
    Module module = new DefaultModule(command, opts);
    Injector injector = Guice.createInjector(module);

    try {
        RequestFilter instance = injector.getInstance(
                Key.get(new TypeLiteral<IOProvider<RequestFilter>>() {})).get();
    } catch (ProvisionException e) {
        assertTrue(e.getCause() instanceof NoSuchCommandException);
    }
}
项目:verify-hub    文件:StateControllerFactoryTest.java   
@Before
public void setup() {
    Injector injector = Guice.createInjector(
            Modules.override(new PolicyModule()
            ).with(new AbstractModule() {
                @Override
                protected void configure() {
                    bind(EventSinkProxy.class).toInstance(mock(EventSinkProxy.class));
                    bind(IdentityProvidersConfigProxy.class).toInstance(mock(IdentityProvidersConfigProxy.class));
                    bind(Client.class).toInstance(mock(Client.class));
                    bind(Environment.class).toInstance(mock(Environment.class));
                    bind(PolicyConfiguration.class).toInstance(aPolicyConfiguration().build());
                    InfinispanCacheManager infinispanCacheManager = anInfinispanCacheManager().build(InfinispanJunitRunner.EMBEDDED_CACHE_MANAGER);
                    bind(InfinispanCacheManager.class).toInstance(infinispanCacheManager);
                    bind(EventSinkHubEventLogger.class).toInstance(mock(EventSinkHubEventLogger.class));
                    bind(JsonClient.class).annotatedWith(Names.named("samlSoapProxyClient")).toInstance(mock(JsonClient.class));
                    bind(JsonClient.class).toInstance(mock(JsonClient.class));
                }
            })
    );

    factory = new StateControllerFactory(injector);
}
项目:stroom-stats    文件:App.java   
@Override
public void run(Config config, Environment environment) throws UnsupportedEncodingException {
    injector = Guice.createInjector(new StroomStatsServiceModule(config, hibernateBundle.getSessionFactory()));
    injector.getInstance(ServiceDiscoveryManager.class);

    if(config.isLogRequestsAndResponses()) {
        environment.jersey().register(new LoggingFeature(java.util.logging.Logger.getLogger(
                getClass().getName()),
                Level.OFF,
                LoggingFeature.Verbosity.PAYLOAD_TEXT,
                8192));
    }

    configureAuthentication(environment, injector.getInstance(JwtVerificationFilter.class));
    registerResources(environment);
    registerTasks(environment);
    HealthChecks.register(environment, injector);
    registerManagedObjects(environment);
}
项目:fx-animation-editor    文件:EventTest.java   
@Before
public void setUp() {
    Injector injector = Guice.createInjector(new EventTestModule());
    eventBus = injector.getInstance(EventBus.class);
    sceneModel = injector.getInstance(SceneModel.class);
    timelineModel = injector.getInstance(TimelineModel.class);
    addInterpolators(injector.getInstance(InterpolatorListModel.class));
    configureMockFileChooser(injector.getInstance(FileChooserComponent.class));
    configureMockSaveDialog(injector.getInstance(SaveDialogComponent.class));

    KeyFrameModel keyFrame = new KeyFrameModel();
    timelineModel.getKeyFrames().add(keyFrame);
    timelineModel.setSelectedKeyFrame(keyFrame);

    actions.remove(MenuActionEvent.EXIT);
}
项目:rejoiner    文件:SchemaProviderModuleTest.java   
@Test
public void schemaModuleShouldProvideQueryType() {
  Injector injector =
      Guice.createInjector(
          new SchemaProviderModule(),
          new SchemaModule() {
            @Query
            GraphQLFieldDefinition greeting =
                GraphQLFieldDefinition.newFieldDefinition()
                    .name("greeting")
                    .type(Scalars.GraphQLString)
                    .staticValue("hello world")
                    .build();
          });
  assertThat(
          injector
              .getInstance(Key.get(GraphQLSchema.class, Schema.class))
              .getQueryType()
              .getFieldDefinition("greeting"))
      .isNotNull();
}
项目:nifi-config    文件:MainTest.java   
@Test
public void mainHttpsUndeployTest() throws Exception {
    Injector injector = Guice.createInjector(new AbstractModule() {
        protected void configure() {
            bind(AccessService.class).toInstance(accessServiceMock);
            bind(InformationService.class).toInstance(informationServiceMock);
            bind(TemplateService.class).toInstance(templateServiceMock);
            bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(10);
            bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(10);
            bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
            bind(Double.class).annotatedWith(Names.named("placeWidth")).toInstance(1200d);
            bind(PositionDTO.class).annotatedWith(Names.named("startPosition")).toInstance(new PositionDTO());
        }
    });
    //given
    PowerMockito.mockStatic(Guice.class);
    Mockito.when(Guice.createInjector((AbstractModule)anyObject())).thenReturn(injector);

    Main.main(new String[]{"-nifi","https://localhost:8080/nifi-api","-branch","\"root>N2\"","-m","undeploy","-noVerifySsl"});
    verify(templateServiceMock).undeploy(Arrays.asList("root","N2"));
}
项目:pyplyn    文件:AppBootstrap.java   
/**
 * Initializes the required components
 */
public final AppBootstrap bootstrap() {
    // prevent multiple bootstrap operations
    guardInitialized();

    // initialize injector, using configFile, modules(), and defaultModules()
    injector = Guice.createInjector(modules());

    // mark bootstrap complete, if injector was created
    initialized = true;

    // register the shutdown hook into the runtime, to allow it to control program flow if interrupted
    Runtime.getRuntime().addShutdownHook(injector.getInstance(ShutdownHook.class));

    // call hook
    hookAfterBootstrap();

    return this;
}
项目:endpoint-health    文件:Main.java   
public static void main(final String[] args) {
    try {
        final MainArgs mainArgs = new MainArgs();

        new CmdLineParser(mainArgs).parseArgument(args);

        if (mainArgs.isHelp()) {
            printUsage();
        } else if (mainArgs.isVersion()) {
            printVersion();
        } else {
            Guice.createInjector(new EndPointHealthModule())
                    .getInstance(Main.class).run(mainArgs);
        }
    } catch (final CmdLineException e) {
        System.err.println(e.getMessage());
        printUsage();
    }
}
项目:gw4e.project    文件:DSLPoliciesInjectorProvider.java   
protected Injector internalCreateInjector() {
    return new DSLPoliciesStandaloneSetup() {
        @Override
        public Injector createInjector() {
            return Guice.createInjector(createRuntimeModule());
        }
    }.createInjectorAndDoEMFRegistration();
}
项目:wayf-cloud    文件:DeviceIdentityProviderBlacklistDaoDbImplTest.java   
@Before
public void setUp() {
    Guice.createInjector(new WayfGuiceModule()).injectMembers(this);

    WayfReactivexConfig.initializePlugins();
    RequestContextAccessor.set(new RequestContext());
}
项目:ProjectAres    文件:InjectableMethodTest.java   
@Test
public void constant() throws Exception {
    class Woot {
        String foo() {
            return "hi";
        }
    }

    InjectableMethod<?> method = InjectableMethod.forDeclaredMethod(new Woot(), "foo");
    String hi = Guice.createInjector(method.bindingModule()).getInstance(String.class);

    assertEquals("hi", hi);
}
项目:bromium    文件:Main.java   
public static void main(String[] args) {
    logger.info("Running CLI with arguments {}", Arrays.toString(args));
    try {
        InputStream inputStream = Main.class.getResourceAsStream("/cli-specification.txt");
        String doc = IOUtils.toString(inputStream);
        Docopt docopt = new Docopt(doc);
        Map<String, Object> opts = docopt
                .withVersion("bromium 0.1")
                .withHelp(true)
                .withExit(false)
                .parse(args);

        Map<String, Supplier<Command>> commandToHandler = getCommands();
        String selectedCommand = commandToHandler
                .keySet()
                .stream()
                .filter(command -> opts.get(command).equals(true))
                .findAny()
                // we know that a command must be present because otherwise docopt would have stopped
                .get();

        injector = Guice.createInjector(new DefaultModule(selectedCommand, opts));
        commandToHandler.get(selectedCommand).get().run();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }

}
项目:Building_Effective_Microservices    文件:RxNettyServer.java   
public void start(){
    this.injector = Guice.createInjector(modules);
    this.adapter = injector.getInstance(RequrestAdapter.class);
    this.adapter.setInjector(injector);

    server = RxNetty.createHttpServer(port,
        (req, resp) -> adapter.handle(req, resp)
    );
    server.startAndWait();
}
项目:hrrs    文件:Distiller.java   
public static void main(String[] args, DistillerModuleFactory moduleFactory) throws IOException {
    Config config = Config.of(args);
    config.dump();
    DistillerModule module = moduleFactory.create(config);
    Injector injector = Guice.createInjector(module);
    LoggerLevelAccessor loggerLevelAccessor = injector.getInstance(LoggerLevelAccessor.class);
    LoggerLevels.applyLoggerLevelSpecs(config.getLoggerLevelSpecs(), loggerLevelAccessor);
    Distiller distiller = injector.getInstance(Distiller.class);
    try {
        distiller.run();
    } finally {
        distiller.close();
    }
}
项目:n4js    文件:N4JSActivator.java   
protected Injector createInjector(String language) {
    try {
        Module runtimeModule = getRuntimeModule(language);
        Module sharedStateModule = getSharedStateModule();
        Module uiModule = getUiModule(language);
        Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
        return Guice.createInjector(mergedModule);
    } catch (Exception e) {
        logger.error("Failed to create injector for " + language);
        logger.error(e.getMessage(), e);
        throw new RuntimeException("Failed to create injector for " + language, e);
    }
}
项目:nifi-config    文件:PortServiceTest.java   
@Test
public void setStateOutputTest() throws ApiException, IOException, URISyntaxException {
    Injector injector = Guice.createInjector(new AbstractModule() {
        protected void configure() {
            bind(InputPortsApi.class).toInstance(inputPortsApiMock);
            bind(OutputPortsApi.class).toInstance(outputPortsApiMock);
            bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(1);
            bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(1);
            bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
        }
    });
    PortService portService = injector.getInstance(PortService.class);
    PortEntity portStopped = new PortEntity();
    portStopped.setComponent(new PortDTO());
    portStopped.getComponent().setName("name");
    portStopped.getComponent().setId("id");
    portStopped.getComponent().setState(PortDTO.StateEnum.STOPPED);
    when(outputPortsApiMock.updateOutputPort(eq("id"),any())).thenReturn(portStopped);
    PortEntity port = new PortEntity();
    port.setId("id");
    port.setComponent(new PortDTO());
    port.getComponent().setId("id");
    port.getComponent().setState(PortDTO.StateEnum.RUNNING);
    port.getComponent().setType(PortDTO.TypeEnum.OUTPUT_PORT);
    portService.setState(port, PortDTO.StateEnum.STOPPED);
    verify(outputPortsApiMock, times(1)).updateOutputPort(eq("id"), any());
}
项目:n4js    文件:RegularExpressionActivator.java   
protected Injector createInjector(String language) {
    try {
        Module runtimeModule = getRuntimeModule(language);
        Module sharedStateModule = getSharedStateModule();
        Module uiModule = getUiModule(language);
        Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
        return Guice.createInjector(mergedModule);
    } catch (Exception e) {
        logger.error("Failed to create injector for " + language);
        logger.error(e.getMessage(), e);
        throw new RuntimeException("Failed to create injector for " + language, e);
    }
}
项目:Equella    文件:ObjectExpressionDeserialiserTest.java   
private static void setupBullshit()
{
    Injector injector = Guice.createInjector(new Module()
    {
        @SuppressWarnings({"unchecked", "nls"})
        @Override
        public void configure(Binder arg0)
        {
            arg0.bind(PluginService.class).toInstance(new FakePluginService());
            ParameterizedType type = Types.newParameterizedType(PluginTracker.class, SectionsConverter.class);
            TrackerProvider<SectionsConverter> trackerProvider = new TrackerProvider<SectionsConverter>(
                "", "", "")
            {
                @Override
                public PluginTracker<SectionsConverter> get()
                {
                    return new FakePluginTracker();
                }
            };

            TypeLiteral<PluginTracker<SectionsConverter>> typeLiteral = (TypeLiteral<PluginTracker<SectionsConverter>>) TypeLiteral
                .get(type);
            LinkedBindingBuilder<PluginTracker<SectionsConverter>> bindingBuilder = arg0.bind(typeLiteral);
            bindingBuilder.toProvider(trackerProvider).in(Scopes.SINGLETON);
        }
    });
    injector.getInstance(Conversion.class);
}
项目:n4js    文件:TypesActivator.java   
protected Injector createInjector(String language) {
    try {
        Module runtimeModule = getRuntimeModule(language);
        Module sharedStateModule = getSharedStateModule();
        Module uiModule = getUiModule(language);
        Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
        return Guice.createInjector(mergedModule);
    } catch (Exception e) {
        logger.error("Failed to create injector for " + language);
        logger.error(e.getMessage(), e);
        throw new RuntimeException("Failed to create injector for " + language, e);
    }
}
项目:bromium    文件:DslActivator.java   
protected Injector createInjector(String language) {
    try {
        Module runtimeModule = getRuntimeModule(language);
        Module sharedStateModule = getSharedStateModule();
        Module uiModule = getUiModule(language);
        Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule);
        return Guice.createInjector(mergedModule);
    } catch (Exception e) {
        logger.error("Failed to create injector for " + language);
        logger.error(e.getMessage(), e);
        throw new RuntimeException("Failed to create injector for " + language, e);
    }
}
项目:bot4j-example    文件:Application.java   
public static void main(final String[] args) {
    final Injector injector = Guice.createInjector(new Module());

    final AlexaWebhook alexaWebhook = injector.getInstance(AlexaWebhook.class);
    final FacebookWebhook facebookWebhook = injector.getInstance(FacebookWebhook.class);
    final SlackActionWebhook slackActionWebhook = injector.getInstance(SlackActionWebhook.class);
    final SlackEventWebhook slackEventWebhook = injector.getInstance(SlackEventWebhook.class);
    final SlackOAuthWebhook slackOAuthWebhook = injector.getInstance(SlackOAuthWebhook.class);
    final TelegramWebhook telegramWebhook = injector.getInstance(TelegramWebhook.class);

    if (System.getenv("PORT") != null) {
        port(Integer.valueOf(System.getenv("PORT")));
    }

    post("/alexa", (req, res) -> alexaWebhook.post(req.raw(), res.raw()));

    get("/facebook", (req, res) -> facebookWebhook.get(req.raw(), res.raw()));
    post("/facebook", (req, res) -> facebookWebhook.post(req.raw(), res.raw()));

    get("/slack/oauth", (req, res) -> slackOAuthWebhook.get(req.raw(), res.raw()));
    post("/slack/action", (req, res) -> slackActionWebhook.post(req.raw(), res.raw()));
    post("/slack/event", (req, res) -> slackEventWebhook.post(req.raw(), res.raw()));

    post("/slack/event", (req, res) -> slackEventWebhook.post(req.raw(), res.raw()));

    post("/telegram", (req, res) -> telegramWebhook.post(req.raw(), res.raw()));
}
项目:bromium    文件:DefaultModuleTest.java   
@Test
public void invalidBrowserThrowsExceptionWhenDriverServiceSupplier() throws IOException, URISyntaxException {
    String command = RECORD;
    Map<String, Object> opts = new HashMap<>();
    opts.put(BROWSER, "asd");
    Module module = new DefaultModule(command, opts);
    Injector injector = Guice.createInjector(module);
    try {
        DriverServiceSupplier instance = injector.getInstance(DriverServiceSupplier.class);
    } catch (ProvisionException e) {
        assertTrue(e.getCause() instanceof BrowserTypeNotSupportedException);
    }
}
项目:Re-Collector    文件:CollectorInjector.java   
public static Injector createInjector(Module... modules) {
    final Injector injector = Guice.createInjector(Stage.PRODUCTION, new CollectorModule() {
        @Override
        protected void configure() {
            binder().requireExplicitBindings();
        }
    });

    return injector.createChildInjector(modules);
}
项目:violet    文件:SingletonModuleTest.java   
@Test
public void testModuleInstallation() {
  Guice.createInjector(new com.google.inject.AbstractModule() {
    @Override
    protected void configure() {
      this.install(new TestSingletonModule());
      this.install(new TestSingletonModule());
    }
  });
}
项目:hadoop    文件:TestRMWebServicesAppsModification.java   
private Injector getNoAuthInjectorCap() {
  return Guice.createInjector(new CapTestServletModule() {
    @Override
    protected void configureServlets() {
      setAuthFilter = false;
      super.configureServlets();
    }
  });
}
项目:dragoman    文件:AbstractResourceTest.java   
@BeforeEach
@SuppressWarnings("unchecked")
public void start() {
  Injector injector =
      Guice.createInjector(
          Modules.override(new DragomanModule()).with(new RestOverridesModule()));
  injector.injectMembers(this);

  startHttpServer();
}
项目:dragoman    文件:MongoDatasetDaoTest.java   
@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());
}
项目:movie-recommender    文件:Application.java   
public static void main(String[] arguments) {
    parseArgs(arguments);
    Injector injector = Guice.createInjector(new MainModule(), new SparkModule());

    JobExecutor executor = injector.getInstance(JobExecutor.class);
    executor.execute(args.getCommandName());
}