当前位置: 首页>>代码示例>>Java>>正文


Java Providers.of方法代码示例

本文整理汇总了Java中com.google.inject.util.Providers.of方法的典型用法代码示例。如果您正苦于以下问题:Java Providers.of方法的具体用法?Java Providers.of怎么用?Java Providers.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.inject.util.Providers的用法示例。


在下文中一共展示了Providers.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: materializedCopy

import com.google.inject.util.Providers; //导入方法依赖的package包/类
/**
 * Returns a materialized copy of the user with all dependencies.
 *
 * <p>Invoke all providers and factories of dependent objects and store the references to a copy
 * of the current identified user.
 *
 * @return copy of the identified user
 */
public IdentifiedUser materializedCopy() {
  Provider<SocketAddress> remotePeer;
  try {
    remotePeer = Providers.of(remotePeerProvider.get());
  } catch (OutOfScopeException | ProvisionException e) {
    remotePeer =
        new Provider<SocketAddress>() {
          @Override
          public SocketAddress get() {
            throw e;
          }
        };
  }
  return new IdentifiedUser(
      authConfig,
      realm,
      anonymousCowardName,
      Providers.of(canonicalUrl.get()),
      accountCache,
      groupBackend,
      disableReverseDnsLookup,
      remotePeer,
      state,
      realUser);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:34,代码来源:IdentifiedUser.java

示例2: actionPerformed

import com.google.inject.util.Providers; //导入方法依赖的package包/类
@Override
public void actionPerformed(final ActionEvent event) {
    final DCFileChooser fileChooser = new DCFileChooser(_userPreferences.getAnalysisJobDirectory());

    final OpenAnalysisJobFileChooserAccessory accessory =
            new OpenAnalysisJobFileChooserAccessory(_windowContext, _configuration, fileChooser,
                    Providers.of(this));
    fileChooser.setAccessory(accessory);

    fileChooser.addChoosableFileFilter(FileFilters.ANALYSIS_XML);
    fileChooser.addChoosableFileFilter(FileFilters.ANALYSIS_RESULT_SER);
    fileChooser.setFileFilter(FileFilters
            .combined("DataCleaner analysis files", FileFilters.ANALYSIS_XML, FileFilters.ANALYSIS_RESULT_SER));
    final int openFileResult = fileChooser.showOpenDialog(_parentWindow.toComponent());

    if (openFileResult == JFileChooser.APPROVE_OPTION) {
        final FileObject file = fileChooser.getSelectedFileObject();
        openFile(file);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:21,代码来源:OpenAnalysisJobActionListener.java

示例3: getDialog

import com.google.inject.util.Providers; //导入方法依赖的package包/类
private OpenAnalysisJobAsTemplateDialog getDialog() {
    if (_dialog == null) {
        try {
            final WindowContext windowContext = new SimpleWindowContext();
            final Datastore datastore = TestHelper.createSampleDatabaseDatastore("orderdb");
            final DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(datastore);
            final SimpleDescriptorProvider descriptorProvider = new SimpleDescriptorProvider();
            final DataCleanerConfiguration configuration =
                    new DataCleanerConfigurationImpl().withDatastoreCatalog(datastoreCatalog).withEnvironment(
                            new DataCleanerEnvironmentImpl().withDescriptorProvider(descriptorProvider));
            final FileObject file = VFSUtils.getFileSystemManager()
                    .resolveFile("src/test/resources/cli-examples/date_analysis_job.xml");
            final Provider<OpenAnalysisJobActionListener> providerMock = Providers.of(null);

            _dialog = new OpenAnalysisJobAsTemplateDialog(windowContext, configuration, file, createMetadata(),
                    providerMock);
        } catch (final FileSystemException e) {
            logger.error("Problem occurred while creating dialog instance. \n" + e.getMessage());
        }
    }

    return _dialog;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:OpenAnalysisJobAsTemplateDialogTest.java

示例4: testFieldBoundAsProvider_lazy

import com.google.inject.util.Providers; //导入方法依赖的package包/类
public void testFieldBoundAsProvider_lazy() {
  LazyProviderClass asProvider = new LazyProviderClass();
  Provider<Integer> provider =
      Guice.createInjector(BoundFieldModule.of(asProvider)).getProvider(Integer.class);
  assertNull(provider.get());
  asProvider.foo = Providers.of(1);
  assertEquals(1, provider.get().intValue());
  asProvider.foo =
      new Provider<Integer>() {
        @Override
        public Integer get() {
          throw new RuntimeException("boom");
        }
      };
  try {
    provider.get();
    fail();
  } catch (ProvisionException e) {
    assertContains(e.getMessage(), "boom");
  }
}
 
开发者ID:google,项目名称:guice,代码行数:22,代码来源:BoundFieldModuleTest.java

示例5: testModuleOverrideRepeatedInstallsAndMultibindings_toProviderInstance

import com.google.inject.util.Providers; //导入方法依赖的package包/类
public void testModuleOverrideRepeatedInstallsAndMultibindings_toProviderInstance() {
  // Providers#of() does not redefine equals/hashCode, so use the same one both times.
  final Provider<String> aProvider = Providers.of("A");
  final Provider<String> bProvider = Providers.of("B");
  Module ab = new AbstractModule() {
    @Override protected void configure() {
      Multibinder<String> multibinder = Multibinder.newSetBinder(binder(), String.class);
      multibinder.addBinding().toProvider(aProvider);
      multibinder.addBinding().toProvider(bProvider);
    }
  };

  // Guice guarantees this assertion, as the same module cannot be installed twice.
  assertEquals(ImmutableSet.of("A", "B"),
      Guice.createInjector(ab, ab).getInstance(Key.get(setOfString)));

  // Guice will only guarantee this assertion if Multibinder ensures the bindings match.
  Injector injector = Guice.createInjector(ab, Modules.override(ab).with(ab));
  assertEquals(ImmutableSet.of("A", "B"),
      injector.getInstance(Key.get(setOfString)));
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:22,代码来源:MultibinderTest.java

示例6: testModuleOverrideRepeatedInstalls_toProviderInstance

import com.google.inject.util.Providers; //导入方法依赖的package包/类
public void testModuleOverrideRepeatedInstalls_toProviderInstance() {
  // Providers#of() does not redefine equals/hashCode, so use the same one both times.
  final Provider<String> aProvider = Providers.of("A");
  final Provider<String> bProvider = Providers.of("B");
  Module m = new AbstractModule() {
    @Override protected void configure() {
      OptionalBinder<String> b = OptionalBinder.newOptionalBinder(binder(), String.class);
      b.setDefault().toProvider(aProvider);
      b.setBinding().toProvider(bProvider);
    }
  };

  assertEquals("B", Guice.createInjector(m, m).getInstance(Key.get(String.class)));

  Injector injector = Guice.createInjector(m, Modules.override(m).with(m));
  assertEquals("B", injector.getInstance(Key.get(String.class)));

  assertOptionalVisitor(stringKey,
      setOf(m, Modules.override(m).with(m)),
      VisitType.BOTH,
      0,
      providerInstance("A"),
      providerInstance("B"));
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:25,代码来源:OptionalBinderTest.java

示例7: setUp

import com.google.inject.util.Providers; //导入方法依赖的package包/类
@Before
public void setUp() {
  mockServlet = createMock(HttpServlet.class);

  filter =
      new ShiroKerberosPermissiveAuthenticationFilter(Providers.of(createMock(Subject.class)));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:ShiroKerberosPermissiveAuthenticationFilterTest.java

示例8: setUp

import com.google.inject.util.Providers; //导入方法依赖的package包/类
@Before
public void setUp() {
  subject = createMock(Subject.class);
  mockServlet = createMock(HttpServlet.class);

  filter = new ShiroKerberosAuthenticationFilter(Providers.of(subject));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:ShiroKerberosAuthenticationFilterTest.java

示例9: findModule

import com.google.inject.util.Providers; //导入方法依赖的package包/类
@Override
public ModuleType findModule(Location location, ContextPlanner planner, List<String> modulePath) {
    String name = Joiner.on(".").join(modulePath);
    if("test".equals(name)) {
        Provider<Exports> moduleProvider = Providers.of(new TestModule());
        ExportUnitGenerator adapter = new ExportUnitGenerator(planner.getGambitScope());
        return adapter.apply(modulePath, moduleProvider);
    }
    return super.findModule(location, planner, modulePath);
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:11,代码来源:EvaluateStatementTest.java

示例10: setUp

import com.google.inject.util.Providers; //导入方法依赖的package包/类
@BeforeMethod
public void setUp() {
    _dataStore = new InMemoryDataStore(new MetricRegistry());
    _cacheRegistry = mock(CacheRegistry.class);
    _cacheHandle = mock(CacheHandle.class);
    when(_cacheRegistry.register(eq("settings"), any(Cache.class), eq(true))).thenReturn(_cacheHandle);

    _settingsManager = new SettingsManager(Providers.of(_dataStore), "__system:settings",
            "app_global:sys", _cacheRegistry);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:11,代码来源:SettingsManagerTest.java

示例11: asUser

import com.google.inject.util.Providers; //导入方法依赖的package包/类
Arguments asUser(CurrentUser otherUser) {
  return new Arguments(
      db,
      queryProvider,
      rewriter,
      opFactories,
      hasOperands,
      userFactory,
      Providers.of(otherUser),
      permissionBackend,
      notesFactory,
      changeDataFactory,
      commentsUtil,
      accountResolver,
      groupBackend,
      allProjectsName,
      allUsersName,
      patchListCache,
      repoManager,
      projectCache,
      listChildProjects,
      submitDryRun,
      conflictsCache,
      index,
      indexConfig,
      listMembers,
      starredChangesUtil,
      accountCache,
      allowsDrafts,
      notesMigration);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:ChangeQueryBuilder.java

示例12: ManualRequestContext

import com.google.inject.util.Providers; //导入方法依赖的package包/类
public ManualRequestContext(
    CurrentUser user,
    SchemaFactory<ReviewDb> schemaFactory,
    ThreadLocalRequestContext requestContext)
    throws OrmException {
  this(Providers.of(user), schemaFactory, requestContext);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:ManualRequestContext.java

示例13: create

import com.google.inject.util.Providers; //导入方法依赖的package包/类
public IdentifiedUser create(AccountState state) {
  return new IdentifiedUser(
      authConfig,
      realm,
      anonymousCowardName,
      canonicalUrl,
      accountCache,
      groupBackend,
      disableReverseDnsLookup,
      Providers.of((SocketAddress) null),
      state,
      null);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:IdentifiedUser.java

示例14: runAs

import com.google.inject.util.Providers; //导入方法依赖的package包/类
public IdentifiedUser runAs(
    SocketAddress remotePeer, Account.Id id, @Nullable CurrentUser caller) {
  return new IdentifiedUser(
      authConfig,
      realm,
      anonymousCowardName,
      canonicalUrl,
      accountCache,
      groupBackend,
      disableReverseDnsLookup,
      Providers.of(remotePeer),
      id,
      caller);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:IdentifiedUser.java

示例15: newMigrator

import com.google.inject.util.Providers; //导入方法依赖的package包/类
private PrimaryStorageMigrator newMigrator(
    @Nullable Retryer<NoteDbChangeState> ensureRebuiltRetryer) {
  return new PrimaryStorageMigrator(
      cfg,
      Providers.of(db),
      repoManager,
      allUsers,
      rebuilderWrapper,
      ensureRebuiltRetryer,
      changeNotesFactory,
      queryProvider,
      updateFactory,
      internalUserFactory,
      retryHelper);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:NoteDbPrimaryIT.java


注:本文中的com.google.inject.util.Providers.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。