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


Java Mono.map方法代码示例

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


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

示例1: requestResponse

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Payload> requestResponse(Payload payload) {
	JsonNode metadata = readConnectionMetadata(payload.getMetadataUtf8());
	try {
		MethodHandler handler = handlerFor(metadata);
		Converter converter = converterFor(MimeType.valueOf(metadata.get("MIME_TYPE").textValue()));
		Object converted = converter.read(ServiceUtils.toByteArray(payload.getData()), getActualType(handler.getInfo().getParameterType()));
		Object result = handler.invoke(handler.getInfo().buildInvocationArguments(converted, null));
		Mono monoResult = monoOF(result);
		return monoResult.map(o -> {
			byte[] data = converter.write(o);
			return new PayloadImpl(data);
		});

	}catch (Exception e){
		return Mono.error(e);
	}
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-sockets,代码行数:19,代码来源:DispatcherHandler.java

示例2: getTransaction

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
public Mono<SignedBigchaindbTransaction> getTransaction(final String transactionId) {
    ClientRequest<Void> request =
            ClientRequest.GET("http://{hostAddress}:{port}/transactions/{id}", hostAddress, port, transactionId)
            .build();
    Mono<ObjectNode> monoObject = webClient.exchange(request).then(response -> response.body(toMono(ObjectNode.class)));
    return monoObject.map(object -> new SignedBigchaindbTransactionImpl(object));
}
 
开发者ID:mgrand,项目名称:bigchaindb-java-driver,代码行数:8,代码来源:BigchainDB.java

示例3: getActiveProfiles

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<ProfileInfo> getActiveProfiles(Mono<Empty> request) {
    return request.map(e -> {
        ProfileInfo.Builder builder = ProfileInfo.newBuilder();
        String[] activeProfiles = DefaultProfileUtil.getActiveProfiles(env);
        if (activeProfiles != null) {
            builder.addAllActiveProfiles(Arrays.asList(activeProfiles));
        }
        String ribbonEnv = getRibbonEnv(activeProfiles);
        if (ribbonEnv != null) {
            builder.setRibbonEnv(ribbonEnv);
        }
        return builder.build();
    });
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:16,代码来源:_ProfileInfoService.java

示例4: getHealth

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Health> getHealth(Mono<Empty> request) {
    Map<String, HealthIndicator> healthIndicatorProtos = new HashMap<>();
    this.healthIndicators.forEach((key, indicator) -> healthIndicatorProtos.put(key, healthIndicatorToHealthIndicatorProto(indicator)));

    return request.map( e ->
        Health.newBuilder()
            .setStatus(Status.valueOf(this.healthIndicator.health().getStatus().toString()))
            .putAllHealthIndicators(healthIndicatorProtos)
            .build()
    );
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:13,代码来源:_HealthService.java

示例5: getEnv

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Environment> getEnv(Mono<Empty> request) {
    return request.map( empty -> {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return Environment.newBuilder()
                .setValue(mapper.writeValueAsString(endpoint.invoke()))
                .build();
        } catch (JsonProcessingException e) {
            throw Status.INTERNAL.withCause(e).asRuntimeException();
        }
    });
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:14,代码来源:_EnvironmentService.java

示例6: isAuthenticated

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<StringValue> isAuthenticated(Mono<Empty> request) {
    return request.map(e -> {
        log.debug("gRPC request to check if the current user is authenticated");
        Authentication principal = SecurityContextHolder.getContext().getAuthentication();
        StringValue.Builder builder = StringValue.newBuilder();
        if (principal != null) {
            builder.setValue(principal.getName());
        }
        return builder.build();
    });
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:13,代码来源:_AccountService.java

示例7: postMessage

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Empty> postMessage(Mono<ChatProto.ChatMessage> request) {
    return request.map(this::broadcast);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:5,代码来源:ChatImpl.java

示例8: oneToOne

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Message> oneToOne(Mono<Message> request) {
    return request.map(this::maybeExplode);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:5,代码来源:TckService.java

示例9: getConfigurationProperties

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<ConfigurationPropertiesReport> getConfigurationProperties(Mono<Empty> request) {
    return request.map(e -> mapToConfigurationPropertiesReport(endpoint.invoke()));
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:5,代码来源:_ConfigurationPropertiesReportService.java

示例10: monoShouldMapValueToUpperCaseHelloWorld

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Test
public void monoShouldMapValueToUpperCaseHelloWorld() {

	Mono<String> mono = Mono.just("Heisenberg");

	mono = mono.map(String::toUpperCase);

	StepVerifier.create(mono).expectNext("HEISENBERG").verifyComplete();
}
 
开发者ID:mp911de,项目名称:reactive-spring,代码行数:10,代码来源:Step4Transformations.java


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