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


Java Provides类代码示例

本文整理汇总了Java中com.google.inject.Provides的典型用法代码示例。如果您正苦于以下问题:Java Provides类的具体用法?Java Provides怎么用?Java Provides使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: providesKafkaInputStream

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
JavaInputDStream<ConsumerRecord<String, RawRating>> providesKafkaInputStream(JavaStreamingContext streamingContext) {
    Map<String, Object> kafkaParams = new HashedMap();
    kafkaParams.put("bootstrap.servers", "localhost:9092");
    kafkaParams.put("key.deserializer", StringDeserializer.class);
    kafkaParams.put("value.deserializer", JsonDeserializer.class);
    kafkaParams.put("serializedClass", RawRating.class);
    kafkaParams.put("group.id", "rating_stream");
    kafkaParams.put("auto.offset.reset", "latest");
    kafkaParams.put("enable.auto.commit", false);
    Collection<String> topics = Arrays.asList("topicA", "topicB");

    return KafkaUtils.createDirectStream(
            streamingContext,
            LocationStrategies.PreferConsistent(),
            ConsumerStrategies.<String, RawRating>Subscribe(topics, kafkaParams)
    );
}
 
开发者ID:cosminseceleanu,项目名称:movie-recommender,代码行数:19,代码来源:SparkModule.java

示例2: getFeedbackRegistry

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
public FeedbackRegistry getFeedbackRegistry() {
    if (this.feedbackRegistry == null) {
        FeedbackRegistry registry = mock(FeedbackRegistry.class);
        List<Feedback> moduleFeedbackList = new FeedbackCreator(GOOD_MP3, WRONG_MP3, ALLOK_MP3).createFeedbackList();
        List<Feedback> containerFeedbackList = new FeedbackCreator(CONTAINER_OK_MP3, CONTAINER_WRONG_MP3, CONTAINER_ALL_OK_MP3).createFeedbackList();

        when(registry.isModuleRegistered(sender)).thenReturn(true);
        when(registry.getModuleFeedbacks(sender)).thenReturn(moduleFeedbackList);

        when(registry.isModuleRegistered(container)).thenReturn(true);
        when(registry.getModuleFeedbacks(container)).thenReturn(containerFeedbackList);
        when(registry.hasFeedbacks()).thenReturn(true);

        this.feedbackRegistry = registry;
    }

    return this.feedbackRegistry;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:20,代码来源:FeedbackProcessingWithContainerIntegrationJUnitTest.java

示例3:

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@SuppressWarnings("unused")
private Function<HubAttributeQueryRequest, Element> getMatchingServiceRequestElementTransformer(
        IdaKeyStore keyStore,
        EncryptionKeyStore encryptionKeyStore,
        EntityToEncryptForLocator entityToEncryptForLocator,
        SignatureAlgorithm signatureAlgorithm,
        DigestAlgorithm digestAlgorithm,
        @Named("HubEntityId") String hubEntityId
) {
    return hubTransformersFactory.getMatchingServiceRequestToElementTransformer(
            keyStore,
            encryptionKeyStore,
            entityToEncryptForLocator,
            signatureAlgorithm,
            digestAlgorithm,
            hubEntityId
    );
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:SamlEngineModule.java

示例4: getCertificateStore

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Singleton
public CertificateStore getCertificateStore(MatchingServiceAdapterConfiguration configuration) {
    List<Certificate> publicSigningCertificates = configuration.getSigningKeys().stream()
        .map(KeyPairConfiguration::getPublicKey)
        .map(key -> cert(key.getName(), key.getCert(), Signing))
        .collect(Collectors.toList());

    List<Certificate> publicEncryptionCertificates = Stream.of(configuration.getEncryptionKeys().get(0).getPublicKey())
        .map(key -> cert(key.getName(), key.getCert(), Encryption))
        .collect(Collectors.toList());

    return new CertificateStore(
        publicEncryptionCertificates,
        publicSigningCertificates);
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:17,代码来源:MatchingServiceAdapterModule.java

示例5: traceRecorder

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Singleton
protected TraceRecorder traceRecorder() {
    TracePublisherRESTClient publisher = new TracePublisherRESTClient(
            PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_USERNAME, "jdoe"),
            PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_PASSWORD, "password"),
            PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_URI, "http://localhost:8080")
    );
    BatchTraceRecorder.BatchTraceRecorderBuilder builder = new BatchTraceRecorder.BatchTraceRecorderBuilder();
    builder.withTracePublisher(publisher);

    String batchSize = PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_COLLECTOR_BATCHSIZE);
    if (batchSize != null) {
        builder.withBatchSize(Integer.parseInt(batchSize));
    }
    String batchTime = PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_COLLECTOR_BATCHTIME);
    if (batchTime != null) {
        builder.withBatchTime(Integer.parseInt(batchTime));
    }
    String threadPoolSize = PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_COLLECTOR_BATCHTHREADS);
    if (threadPoolSize != null) {
        builder.withBatchPoolSize(Integer.parseInt(threadPoolSize));
    }
    builder.withTenantId(PropertyUtil.getProperty("HAWKULAR_APM_TENANTID"));
    return new BatchTraceRecorder(builder);
}
 
开发者ID:opentracing-contrib,项目名称:java-span-reporter,代码行数:27,代码来源:HawkularTracerModule.java

示例6: buildByApiVersion

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Singleton
public Map<ApiVersion, Function<Build, BuildData>> buildByApiVersion( ) {
    return ImmutableMap.of(
            ApiVersion.API_6_0,
            build -> new BuildData( build.getId( ), build.getStatus( ),
                    build.isRunning( ) ? BuildState.running : BuildState.finished,
                    build.isRunning( ) ? build.getRunningInformation( ).getPercentageComplete( ) : 100,
                    Optional.ofNullable( build.getFinishDate( ) ),
                    build.isRunning( ) ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ),


            ApiVersion.API_7_0,
            build -> new BuildData( build.getId( ), build.getStatus( ),
                    build.isRunning( ) ? BuildState.running : BuildState.finished,
                    build.isRunning( ) ? build.getRunningInformation( ).getPercentageComplete( ) : 100,
                    Optional.ofNullable( build.getFinishDate( ) ),
                    build.isRunning( ) ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ),

            ApiVersion.API_8_0,
            build -> new BuildData( build.getId( ), build.getStatus( ),
                    build.isRunning( ) ? BuildState.running : BuildState.finished,
                    build.isRunning( ) ? build.getRunningInformation( ).getPercentageComplete( ) : 100,
                    Optional.ofNullable( build.getFinishDate( ) ),
                    build.isRunning( ) ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO ),

            ApiVersion.API_8_1,
            build -> new BuildData( build.getId( ), build.getStatus( ),
                    build.getState( ),
                    build.getState( ) == BuildState.running ? build.getRunningInformation( ).getPercentageComplete( ) : 100,
                    Optional.ofNullable( build.getFinishDate( ) ),
                    build.getState( ) == BuildState.running ? Duration.of( build.getRunningInformation( ).getEstimatedTotalTime( ) - build.getRunningInformation( ).getElapsedTime( ), ChronoUnit.SECONDS ) : Duration.ZERO )
    );
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:35,代码来源:ApiModule.java

示例7: soapClientProvider

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Singleton
@Named("SoapClient")
private Client soapClientProvider(Environment environment, SamlSoapProxyConfiguration samlSoapProxyConfiguration) {
    return new ClientProvider(
            environment,
            samlSoapProxyConfiguration.getSoapJerseyClientConfiguration(),
            samlSoapProxyConfiguration.getEnableRetryTimeOutConnections(),
            "SoapClient")
            .get();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:12,代码来源:SamlSoapProxyModule.java

示例8: getMatchingServiceClient

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Singleton
@Named("MatchingServiceClient")
public JsonClient getMatchingServiceClient(Environment environment, MatchingServiceAdapterConfiguration configuration) {
    Client matchingServiceClient = new JerseyClientBuilder(environment).using(configuration.getMatchingServiceClientConfiguration()).build("MatchingServiceClient");
    return new JsonClient(new ErrorHandlingClient(matchingServiceClient), new JsonResponseProcessor(environment.getObjectMapper()));
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:8,代码来源:MatchingServiceAdapterModule.java

示例9: providesCassandraRatingIO

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
CassandraIo<RawRating> providesCassandraRatingIO(JavaSparkContext sparkContext) {
    if (ratingCassandraIo != null) {
        return ratingCassandraIo;
    }
    ratingCassandraIo = new CassandraIo<>(RawRating.class, "dev", "ratings");
    ratingCassandraIo.setSparkContext(sparkContext);


    return ratingCassandraIo;
}
 
开发者ID:cosminseceleanu,项目名称:movie-recommender,代码行数:12,代码来源:SparkModule.java

示例10: getFeedbackRegistry

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
public FeedbackRegistry getFeedbackRegistry() {
    if (feedbackRegistry == null) {
        FeedbackRegistry registry = mock(FeedbackRegistry.class);
        List<Feedback> feedbackList = new FeedbackCreator(GOOD_MP3, WRONG_MP3, ALLOK_MP3).createFeedbackList();

        when(registry.isModuleRegistered(sender)).thenReturn(true);
        when(registry.getModuleFeedbacks(sender)).thenReturn(feedbackList);
        this.feedbackRegistry = registry;
    }

    return this.feedbackRegistry;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:14,代码来源:FeedbackProcessingIntegrationJUnitTest.java

示例11: getSettings

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
public Settings getSettings() {

	// provider all needed settings for running backend
	// simulate provided settings
	if (settings == null || settings.isEmpty()) {
		settings = new Settings();
		settings.put("A", "1");
		settings.put("B", "2");
	}

	return settings;
}
 
开发者ID:zandero,项目名称:rest.vertx,代码行数:14,代码来源:GuiceInjectionProvider.java

示例12: properties

import com.google.inject.Provides; //导入依赖的package包/类
/**
 * Generate properties out of the database config. The DatabaseConfig must be provided by a user's configuration.
 */
@Provides
@Jpa
public Map<?, ?> properties(final DatabaseConfig cfg) {
	Properties props = new Properties();
	props.setProperty(DRIVER, Driver.class.getName());
	props.setProperty(URL, cfg.getUrl());
	props.setProperty(USER, cfg.getUser());
	props.setProperty(PASS, cfg.getPassword());

	props.putAll(cfg.getProperties());

	return props;
}
 
开发者ID:stickfigure,项目名称:postguice,代码行数:17,代码来源:PostguiceBridgeModule.java

示例13: getLoadingCache

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Named("publisherSaltRedisCache")
@Singleton
public LoadingCache<Long, String> getLoadingCache(
        @Named("publisherSaltRedisDao") RedisDao<Long, String> publisherSaltRedisDao,
        PublisherDao publisherDao) {
    LoadingCacheRedisImpl<Long, String> l2Cache = new LoadingCacheRedisImpl<>();
    l2Cache.setRedisDao(publisherSaltRedisDao);
    l2Cache.setCacheLoader((key) -> publisherDao.read(key).map((publisher) -> {LOG.debug("found publisher for l3 [{}]", publisher.getSalt());return publisher.getSalt();}));

    return l2Cache;
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:13,代码来源:WayfGuiceModule.java

示例14: getInScopePredicate

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
Predicate<DocLevelEventArg> getInScopePredicate(Parameters params) throws IOException {
  final Set<Symbol> bannedRoles = params.getSymbolSet("bannedRoles");
  // provide files under data/2016.types.txt
  final Set<Symbol> inScopeEventTypes = FileUtils.loadSymbolMultimap(
      Files.asCharSource(params.getExistingFile("eventTypesToScore"), Charsets.UTF_8)).keySet();

  return and(
      compose(in(inScopeEventTypes), eventType()),
      compose(not(in(bannedRoles)), eventArgumentType()));
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:12,代码来源:ScoreKBPAgainstERE.java

示例15: provideMetricReporter

import com.google.inject.Provides; //导入依赖的package包/类
@Provides
@Singleton
public MetricReporter provideMetricReporter(Config config, MetricRegistry metricRegistry) {
    return config.getMetricsOutputFile() == null
            ? MetricNullReporter.getInstance()
            : new MetricFileReporter(config, metricRegistry);
}
 
开发者ID:vy,项目名称:hrrs,代码行数:8,代码来源:ReplayerModule.java


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