本文整理汇总了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)
);
}
示例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
);
}
示例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);
}
示例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);
}
示例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 )
);
}
示例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();
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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()));
}
示例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);
}