Java 类com.google.inject.util.Providers 实例源码

项目:rotabuilder    文件:DomainApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(ComponentFactoryRegistrar.class).to(MyComponentFactoryRegistrar.class);

            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("RotaBuilder");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("RotaBuilder");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
                    Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
            // if uncommented, then overrides isis.appManifest in config file.
            // bind(AppManifest.class).toInstance(new DomainAppAppManifest());
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:Proyecto2017Seguros    文件:PacinetesApplication.java   
@Override
 protected Module newIsisWicketModule() {
     final Module isisDefaults = super.newIsisWicketModule();

     final Module overrides = new AbstractModule() {
         @Override
         protected void configure() {
             bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("SiGeSe");
             bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
             bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
    bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/about/images/login.png");
    bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
    bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("SiGeSe");
    bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
     };

     return Modules.override(isisDefaults).with(overrides);
 }
项目:gossip    文件:Formatter.java   
Formatter(final String pattern) {
    final List<String> patterns = Splitter.on(VAR_BEGIN).omitEmptyStrings().splitToList(pattern);

    patterns.forEach(pt -> {
        if (!pt.contains(VAR_END)) {
            appenderList.add(Providers.of(pt));
        } else {
            StringTokenizer token = new StringTokenizer(pt, VAR_END);
            String guiceKey = token.nextToken();
            String rawString = null;
            if (token.hasMoreTokens()) {
                rawString = token.nextToken();
            }
            final KeyResolver resolver = new KeyResolver(guiceKey);
            appenderList.add(resolver);
            resolvers.add(resolver);
            appenderList.add(Providers.of(rawString));
        }
    });
}
项目:isis-agri    文件:DomainApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Food App");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Food App");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
                    Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
            // if uncommented, then overrides isis.appManifest in config file.
            // bind(AppManifest.class).toInstance(new DomainAppAppManifest());
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:riposte-microservice-template    文件:AppServerConfigTest.java   
@Test
public void constructor_does_not_blow_up_if_metricsListener_is_null() {
    // given
    AppServerConfig asc = new AppServerConfig(configForTesting) {
        @Override
        protected List<Module> getAppGuiceModules(Config appConfig) {
            return Arrays.asList(
                Modules.override(new AppGuiceModule(appConfig)).with(
                    binder -> binder
                        .bind(new TypeLiteral<CodahaleMetricsListener>() {})
                        .toProvider(Providers.of(null))),
                new BackstopperRiposteConfigGuiceModule()
            );
        }
    };

    // expect
    assertThat(asc.metricsListener()).isNull();
}
项目:ecpcrm    文件:EcpCrmApplication.java   
@Override
    protected Module newIsisWicketModule() {
        final Module isisDefaults = super.newIsisWicketModule();

        final Module overrides = new AbstractModule() {
            @Override
            protected void configure() {

                bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("ECP CRM");
                bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
                bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
//                bind(String.class).annotatedWith(Names.named("brandLogoHeader")).toInstance("/images/domainapp-logo-header.png");
//                bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/images/domainapp-logo-signin.png");
                bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
                bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("ECP CRM");
                bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
            }
        };

        return Modules.override(isisDefaults).with(overrides);
    }
项目:guice-persist-neo4j    文件:Neo4jPersistModule.java   
protected void configurePersistence() {
    bind(String[].class).annotatedWith(Neo4j.class).toInstance(packages);

    if (null != properties) {
        bind(Properties.class).annotatedWith(Neo4j.class).toInstance(properties);
    } else {
        bind(Properties.class).annotatedWith(Neo4j.class).toProvider(Providers.of(null));
    }

    bind(Neo4jPersistService.class).in(Singleton.class);
    bind(PersistService.class).to(Neo4jPersistService.class);
    bind(UnitOfWork.class).to(Neo4jPersistService.class);
    bind(Session.class).toProvider(Neo4jPersistService.class);

    transactionInterceptor = new Neo4jLocalTxnInterceptor();
    requestInjection(transactionInterceptor);
}
项目:salta    文件:Jsr330Test.java   
public void testGuicify330Provider() {
    Provider<String> jsr330Provider = new Provider<String>() {
        @Override
        public String get() {
            return "A";
        }

        @Override
        public String toString() {
            return "jsr330Provider";
        }
    };

    com.google.inject.Provider<String> guicified = Providers
            .guicify(jsr330Provider);
    assertEquals("guicified(jsr330Provider)", guicified.toString());
    assertEquals("A", guicified.get());

    // when you guicify the Guice-friendly, it's a no-op
    assertSame(guicified, Providers.guicify(guicified));

}
项目:salta    文件:ProvisionListenerTest.java   
public void testBindToInjectorWithListeningGivesSaneException() {
    try {
        Guice.createInjector(new AbstractModule() {
            @Override
            protected void configure() {
                bindListener(Matchers.any(), new Counter());
                bind(Injector.class)
                        .toProvider(Providers.<Injector> of(null));
            }
        });
        fail();
    } catch (SaltaException ce) {
        assertContains(ce.getMessage(),
                "Binding to core guice framework type is not allowed: Injector.");
    }
}
项目:salta    文件:BinderTest.java   
@Test
public void testBindingToProvider() {
    try {
        Guice.createInjector(new AbstractModule() {
            @Override
            protected void configure() {
                bind(new TypeLiteral<Provider<String>>() {
                }).toInstance(Providers.of("A"));
            }
        });
        fail();
    } catch (SaltaException expected) {
        assertContains(expected.getMessage(),
                "Binding to core guice framework type is not allowed: Provider.");
    }
}
项目:salta    文件:BinderTest.java   
@Override
protected void configure() {
    bind(AbstractModule.class).annotatedWith(red)
            .toProvider(Providers.<AbstractModule> of(null));
    bind(Binder.class).annotatedWith(red)
            .toProvider(Providers.<Binder> of(null));
    bind(Binding.class).annotatedWith(red)
            .toProvider(Providers.<Binding> of(null));
    bind(Injector.class).annotatedWith(red)
            .toProvider(Providers.<Injector> of(null));
    bind(Key.class).annotatedWith(red)
            .toProvider(Providers.<Key> of(null));
    bind(Module.class).annotatedWith(red)
            .toProvider(Providers.<Module> of(null));
    bind(Provider.class).annotatedWith(red)
            .toProvider(Providers.<Provider> of(null));
    bind(Scope.class).annotatedWith(red)
            .toProvider(Providers.<Scope> of(null));
    bind(Stage.class).annotatedWith(red)
            .toProvider(Providers.<Stage> of(null));
    bind(TypeLiteral.class).annotatedWith(red)
            .toProvider(Providers.<TypeLiteral> of(null));
    bind(new TypeLiteral<Key<String>>() {
    }).toProvider(Providers.<Key<String>> of(null));
}
项目:keywhiz    文件:CliModule.java   
@Override protected void configure() {
  bind(CliConfiguration.class).toInstance(config);

  bind(JCommander.class).annotatedWith(Names.named("ParentCommander"))
      .toInstance(parentCommander);

  if (commander == null) {
    bind(JCommander.class).annotatedWith(Names.named("Commander"))
        .toProvider(Providers.of((JCommander) null));
    bind(String.class).annotatedWith(Names.named("Command"))
        .toProvider(Providers.of((String) null));
  } else {
    bind(JCommander.class).annotatedWith(Names.named("Commander")).toInstance(commander);
    bindConstant().annotatedWith(Names.named("Command")).to(command);
  }

  bind(Map.class).annotatedWith(Names.named("CommandMap")).toInstance(commands);
}
项目:isis-app-quickstart    文件:DomainApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {

            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Domain App");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("brandLogoHeader")).toInstance("/images/domainapp-logo-header.png");
            bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/images/domainapp-logo-signin.png");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Domain App");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:isis-app-simpledsl    文件:DomainApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Simple App");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Simple App");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
                    Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
            // if uncommented, then overrides isis.appManifest in config file.
            // bind(AppManifest.class).toInstance(new DomainAppAppManifest());
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:TarjetasISIS    文件:SimpleApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(" Mejorar ");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(" Mejorar ");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:isis-app-todoapp    文件:ToDoApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {

            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("ToDo App");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("brandLogoHeader")).toInstance("/images/todoapp-logo-header.png");
            bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/images/todoapp-logo-signin.png");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("ToDo App");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:presto    文件:BackupModule.java   
@Override
protected void setup(Binder binder)
{
    configBinder(binder).bindConfig(BackupConfig.class);

    String provider = buildConfigObject(BackupConfig.class).getProvider();
    if (provider == null) {
        binder.bind(BackupStore.class).toProvider(Providers.of(null));
    }
    else {
        Module module = providers.get(provider);
        if (module == null) {
            binder.addError("Unknown backup provider: %s", provider);
        }
        else {
            binder.install(module);
        }
    }
    binder.bind(BackupService.class).to(BackupServiceManager.class).in(Scopes.SINGLETON);
}
项目:isis-app-petclinic    文件:PetClinicApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Simple App");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Simple App");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:gerrit    文件:Init.java   
@Override
protected void afterInit(SiteRun run) throws Exception {
  List<Module> modules = new ArrayList<>();
  modules.add(
      new AbstractModule() {
        @Override
        protected void configure() {
          bind(Path.class).annotatedWith(SitePath.class).toInstance(getSitePath());
          bind(Browser.class);
          bind(String.class)
              .annotatedWith(SecureStoreClassName.class)
              .toProvider(Providers.of(getConfiguredSecureStoreClass()));
        }
      });
  modules.add(new GerritServerConfigModule());
  Guice.createInjector(modules).injectMembers(this);
  start(run);
}
项目:gerrit    文件:Passwd.java   
private Injector getSysInjector() {
  List<Module> modules = new ArrayList<>();
  modules.add(
      new FactoryModule() {
        @Override
        protected void configure() {
          bind(Path.class).annotatedWith(SitePath.class).toInstance(getSitePath());
          bind(ConsoleUI.class).toInstance(ConsoleUI.getInstance(password != null));
          factory(Section.Factory.class);
          bind(Boolean.class).annotatedWith(InstallAllPlugins.class).toInstance(Boolean.FALSE);
          bind(new TypeLiteral<List<String>>() {})
              .annotatedWith(InstallPlugins.class)
              .toInstance(new ArrayList<String>());
          bind(String.class)
              .annotatedWith(SecureStoreClassName.class)
              .toProvider(Providers.of(getConfiguredSecureStoreClass()));
        }
      });
  modules.add(new GerritServerConfigModule());
  return Guice.createInjector(modules);
}
项目:gerrit    文件:InProcessProtocol.java   
Context(
    SchemaFactory<ReviewDb> schemaFactory,
    IdentifiedUser.GenericFactory userFactory,
    Account.Id accountId,
    Project.NameKey project) {
  this.schemaFactory = schemaFactory;
  this.userFactory = userFactory;
  this.accountId = accountId;
  this.project = project;
  map = new HashMap<>();
  cleanup = new RequestCleanup();
  map.put(DB_KEY, new RequestScopedReviewDbProvider(schemaFactory, Providers.of(cleanup)));
  map.put(RC_KEY, cleanup);

  IdentifiedUser user = userFactory.create(accountId);
  user.setAccessPath(AccessPath.GIT);
  map.put(USER_KEY, user);
}
项目:gerrit    文件:GuiceRequestScopePropagator.java   
/** @see RequestScopePropagator#wrap(Callable) */
// ServletScopes#continueRequest is deprecated, but it's not obvious their
// recommended replacement is an appropriate drop-in solution; see
// https://gerrit-review.googlesource.com/83971
@SuppressWarnings("deprecation")
@Override
protected <T> Callable<T> wrapImpl(Callable<T> callable) {
  Map<Key<?>, Object> seedMap = new HashMap<>();

  // Request scopes appear to use specific keys in their map, instead of only
  // providers. Add bindings for both the key to the instance directly and the
  // provider to the instance to be safe.
  seedMap.put(Key.get(typeOfProvider(String.class), CanonicalWebUrl.class), Providers.of(url));
  seedMap.put(Key.get(String.class, CanonicalWebUrl.class), url);

  seedMap.put(Key.get(typeOfProvider(SocketAddress.class), RemotePeer.class), Providers.of(peer));
  seedMap.put(Key.get(SocketAddress.class, RemotePeer.class), peer);

  return ServletScopes.continueRequest(callable, seedMap);
}
项目:gerrit    文件:IdentifiedUser.java   
/**
 * 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);
}
项目:gerrit    文件:DynamicSetTest.java   
@Test
public void containsDynamic() throws Exception {
  DynamicSet<Integer> ds = new DynamicSet<>();
  ds.add(2);

  Key<Integer> key = Key.get(Integer.class);
  ReloadableRegistrationHandle<Integer> handle = ds.add(key, Providers.of(4));

  ds.add(6);

  // At first, 4 is contained.
  assertThat(ds.contains(4)).isTrue(); //See above comment about ds.contains

  // Then we remove 4.
  handle.remove();

  // And now 4 should no longer be contained.
  assertThat(ds.contains(4)).isFalse(); //See above comment about ds.contains
}
项目:gerrit    文件:CommitsCollectionTest.java   
@Before
public void setUp() throws Exception {
  Injector injector = Guice.createInjector(new InMemoryModule());
  injector.injectMembers(this);
  lifecycle = new LifecycleManager();
  lifecycle.add(injector);
  lifecycle.start();

  db = schemaFactory.open();
  schemaCreator.create(db);
  // Need to create at least one user to be admin before creating a "normal"
  // registered user.
  // See AccountManager#create().
  accountManager.authenticate(AuthRequest.forUser("admin")).getAccountId();
  admins = groupCache.get(new AccountGroup.NameKey("Administrators")).orElse(null).getGroupUUID();
  setUpPermissions();

  Account.Id userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
  user = userFactory.create(userId);

  Project.NameKey name = new Project.NameKey("project");
  InMemoryRepository inMemoryRepo = repoManager.createRepository(name);
  project = new ProjectConfig(name);
  project.load(inMemoryRepo);
  repo = new TestRepository<>(inMemoryRepo);

  requestContext.setContext(
      new RequestContext() {
        @Override
        public CurrentUser getUser() {
          return user;
        }

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
          return Providers.of(db);
        }
      });
}
项目:DataCleaner    文件:OpenAnalysisJobActionListener.java   
@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);
    }
}
项目:DataCleaner    文件:OpenAnalysisJobAsTemplateDialogTest.java   
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;
}
项目:isis-module-devutils    文件:DevUtilsModuleApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module simpleOverrides = new AbstractModule() {
        @Override
        protected void configure() {

            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(APP_NAME);
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(APP_NAME);
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(simpleOverrides);
}
项目:isis-app-kitchensink    文件:KitchensinkApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module simpleOverrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(APP_NAME);
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(APP_NAME);
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(simpleOverrides);
}
项目:isis-module-pdf    文件:PdfModuleApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module simpleOverrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(APP_NAME);
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(APP_NAME);
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(simpleOverrides);
}
项目:isis-module-audit    文件:AuditModuleApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(APP_NAME);
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(APP_NAME);
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
项目:guice-old    文件:DuplicateBindingsTest.java   
@SuppressWarnings("unchecked")
public void testMixedTargetsFails() {
  try {
    Guice.createInjector(
        new SimpleModule(foo, pFoo, pclFoo, clFoo, cFoo),
        new SimpleModule(new FooImpl(), Providers.<Foo>of(new FooImpl()), 
            (Class)BarProvider.class, (Class)Bar.class, (Constructor)Bar.cxtor())
    );
    fail("expected exception");
  } catch(CreationException ce) {
    assertContains(ce.getMessage(), 
        "A binding to " + Foo.class.getName() + " annotated with " + named("pInstance") + " was already configured at " + SimpleModule.class.getName(),
        "at " + SimpleModule.class.getName(), 
        "A binding to " + Foo.class.getName() + " annotated with " + named("pKey") + " was already configured at " + SimpleModule.class.getName(),
        "at " + SimpleModule.class.getName(), 
        "A binding to " + Foo.class.getName() + " annotated with " + named("linkedKey") + " was already configured at " + SimpleModule.class.getName(),
        "at " + SimpleModule.class.getName(),
        "A binding to " + Foo.class.getName() + " annotated with " + named("constructor") + " was already configured at " + SimpleModule.class.getName(),
        "at " + SimpleModule.class.getName());
  }
}
项目:isis-module-security    文件:SecurityModuleApplication.java   
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();

    final Module simpleOverrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(APP_NAME);
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(APP_NAME);
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
        }
    };

    return Modules.override(isisDefaults).with(simpleOverrides);
}
项目:guice    文件:BoundFieldModuleTest.java   
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");
  }
}
项目:guice    文件:ServletTest.java   
private Injector createInjector(Module... modules) throws CreationException {
  return Guice.createInjector(
      Lists.<Module>asList(
          new AbstractModule() {
            @Override
            protected void configure() {
              install(new ServletModule());
              bind(InSession.class);
              bind(IN_SESSION_NULL_KEY)
                  .toProvider(Providers.<InSession>of(null))
                  .in(SessionScoped.class);
              bind(InRequest.class);
              bind(IN_REQUEST_NULL_KEY)
                  .toProvider(Providers.<InRequest>of(null))
                  .in(RequestScoped.class);
            }
          },
          modules));
}
项目:guice    文件:InjectorImpl.java   
ConvertedConstantBindingImpl(
    InjectorImpl injector,
    Key<T> key,
    T value,
    Binding<String> originalBinding,
    TypeConverterBinding typeConverterBinding) {
  super(
      injector,
      key,
      originalBinding.getSource(),
      new ConstantFactory<T>(Initializables.of(value)),
      Scoping.UNSCOPED);
  this.value = value;
  provider = Providers.of(value);
  this.originalBinding = originalBinding;
  this.typeConverterBinding = typeConverterBinding;
}
项目:guice    文件:Jsr330Test.java   
public void testGuicify330Provider() {
  Provider<String> jsr330Provider =
      new Provider<String>() {
        @Override
        public String get() {
          return "A";
        }

        @Override
        public String toString() {
          return "jsr330Provider";
        }
      };

  com.google.inject.Provider<String> guicified = Providers.guicify(jsr330Provider);
  assertEquals("guicified(jsr330Provider)", guicified.toString());
  assertEquals("A", guicified.get());

  // when you guicify the Guice-friendly, it's a no-op
  assertSame(guicified, Providers.guicify(guicified));

  assertFalse(guicified instanceof HasDependencies);
}
项目:guice    文件:ProvisionListenerTest.java   
public void testBindToInjectorWithListeningGivesSaneException() {
  try {
    Guice.createInjector(
        new AbstractModule() {
          @Override
          protected void configure() {
            bindListener(Matchers.any(), new Counter());
            bind(Injector.class).toProvider(Providers.<Injector>of(null));
          }
        });
    fail();
  } catch (CreationException ce) {
    assertContains(
        ce.getMessage(), "Binding to core guice framework type is not allowed: Injector.");
  }
}
项目:guice    文件:BinderTest.java   
public void testBindingToProvider() {
  try {
    Guice.createInjector(
        new AbstractModule() {
          @Override
          protected void configure() {
            bind(new TypeLiteral<Provider<String>>() {}).toInstance(Providers.of("A"));
          }
        });
    fail();
  } catch (CreationException expected) {
    assertContains(
        expected.getMessage(),
        "1) Binding to Provider is not allowed.",
        "at " + BinderTest.class.getName(),
        getDeclaringSourcePart(getClass()));
  }
}