當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。