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


Java Mono.just方法代码示例

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


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

示例1: addComment

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@PostMapping("/comments")
public Mono<String> addComment(Mono<Comment> newComment) {
	if (commentSink != null) {
		return newComment
			.map(comment -> {
				commentSink.next(MessageBuilder
					.withPayload(comment)
					.setHeader(MessageHeaders.CONTENT_TYPE,
						MediaType.APPLICATION_JSON_VALUE)
					.build());
				return comment;
			})
			.flatMap(comment -> {
				meterRegistry
					.counter("comments.produced", "imageId", comment.getImageId())
					.increment();
				return Mono.just("redirect:/");
			});
	} else {
		return Mono.just("redirect:/");
	}
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:23,代码来源:CommentController.java

示例2: createPublisher

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Publisher<Message> createPublisher(long elements) {
    ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel);
    Mono<Message> request = Mono.just(toMessage((int) elements));
    Mono<Message> publisher = stub.oneToOne(request);

    return publisher.flux();
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:9,代码来源:ReactorGrpcPublisherOneToOneVerificationTest.java

示例3: update

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
Mono<Post> update(Long id, Post post) {
    Post updated = data.get(id);
    updated.setTitle(post.getTitle());
    updated.setContent(post.getContent());
    data.put(id, updated);
    return Mono.just(updated);
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:8,代码来源:PostRepository.java

示例4: deleteImageShouldWork

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Test
public void deleteImageShouldWork() {
	// given
	String imageName = "alpha.jpg";
	Mono<Image> image = Mono.just(new Image("1", imageName));
	given(repository.findByName(any())).willReturn(image);
	given(repository.delete((Image) any())).willReturn(Mono.empty());

	// when
	Mono<Void> done = imageService.deleteImage(imageName);

	// then
	then(done.block()).isNull();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:15,代码来源:ImageServiceTests.java

示例5: info

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@GetMapping("info")
public Mono<Object> info() {
	return Mono.just(singletonMap("token_endpoint", props.getExternalUrl()));
}
 
开发者ID:making,项目名称:spring-boot-actuator-dashboard,代码行数:5,代码来源:PseudoCloudController.java

示例6: getMonoFromJson

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
private static <T> Mono<T> getMonoFromJson(final String json, final Class<T> type) {
    final ObjectMapper objectMapper = new ObjectMapper();
    try {
        return Mono.just(objectMapper.readValue(json, type));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:LearningByExample,项目名称:reactive-ms-example,代码行数:9,代码来源:RestServiceHelper.java

示例7: index

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@GetMapping("/")
public Mono<String> index(Model model) {
	model.addAttribute("images",
		imageService
			.findAllImages()
			.map(image -> new HashMap<String, Object>() {{
				put("id", image.getId());
				put("name", image.getName());
				// tag::comments[]
				put("comments", commentHelper.getComments(image));
				// end::comments[]
			}})
	);
	return Mono.just("index");
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:16,代码来源:HomeController.java

示例8: oneToMany

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
/**
 * Implements a unary -> stream call as {@link Mono} -> {@link Flux}, where the server responds with a
 * stream of messages.
 */
public static <TRequest, TResponse> void oneToMany(
        TRequest request, StreamObserver<TResponse> responseObserver,
        Function<Mono<TRequest>, Flux<TResponse>> delegate) {
    try {
        Mono<TRequest> rxRequest = Mono.just(request);

        Flux<TResponse> rxResponse = Preconditions.checkNotNull(delegate.apply(rxRequest));
        rxResponse.subscribe(new ReactivePublisherBackpressureOnReadyHandler<>(
                (ServerCallStreamObserver<TResponse>) responseObserver));
    } catch (Throwable throwable) {
        responseObserver.onError(prepareError(throwable));
    }
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:18,代码来源:ServerCalls.java

示例9: findById

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
Mono<Post> findById(Long id) {
    return Mono.just(data.get(id));
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:4,代码来源:PostRepository.java

示例10: save

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
Mono<Post> save(Post post) {
    Long id = nextId();
    Post saved = Post.builder().id(id).title(post.getTitle()).content(post.getContent()).build();
    data.put(id, saved);
    return Mono.just(saved);
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:7,代码来源:PostRepository.java

示例11: deferred

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@GetMapping("deferred")
public Mono<String> deferred() {
	return Mono.just("Jesse");
}
 
开发者ID:mp911de,项目名称:reactive-spring,代码行数:5,代码来源:WorkshopController.java

示例12: delete

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
Mono<Post> delete(Long id) {
    Post deleted = data.get(id);
    data.remove(id);
    return Mono.just(deleted);
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:6,代码来源:PostRepository.java

示例13: accept

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<RSocket> accept(ConnectionSetupPayload connectionSetupPayload, RSocket rSocket) {
	logger.info("Receiving connection");
	return Mono.just(handler);
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-sockets,代码行数:6,代码来源:DispatchSocketAcceptor.java

示例14: findByName

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<ItemInventory> findByName(String name) {
	ItemInventory result = items.get(name);
	return result == null ? Mono.empty() : Mono.just(result);
}
 
开发者ID:guilhebl,项目名称:item-shop-reactive-backend,代码行数:6,代码来源:MapItemInventoryRepository.java

示例15: queryCardSet

import reactor.core.publisher.Mono; //导入方法依赖的package包/类
/**
 * 根据类型获取指定的卡号组
 *
 * @param type 卡号组的类型
 * @return 特定的卡号组
 */
public Mono<String[]> queryCardSet(CardType type) {
    return Mono.just(cardSetOperate.obtainCardSet(type.name()).block().getCardList());

}
 
开发者ID:bitkylin,项目名称:ClusterDeviceControlPlatform,代码行数:11,代码来源:DbPresenter.java


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