本文整理了Java中reactor.core.publisher.Mono.empty()
方法的一些代码示例,展示了Mono.empty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.empty()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:empty
[英]Create a Mono that completes without emitting any item.
[中]创建一个单声道,完成后不发射任何项目。
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> removeSession(String id) {
this.sessions.remove(id);
return Mono.empty();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> invalidate() {
this.state.set(State.EXPIRED);
getAttributes().clear();
InMemoryWebSessionStore.this.sessions.remove(this.id.get());
return Mono.empty();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Resource> resolveResource(@Nullable ServerWebExchange exchange, String requestPath,
List<? extends Resource> locations) {
return (this.resolver != null && this.nextChain != null ?
this.resolver.resolveResource(exchange, requestPath, locations, this.nextChain) :
Mono.empty());
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<String> resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
return (this.resolver != null && this.nextChain != null ?
this.resolver.resolveUrlPath(resourcePath, locations, this.nextChain) :
Mono.empty());
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> doFilter(ServerWebExchange exchange, WebFilterChain chain) {
return Mono.empty();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
this.request = request;
return Mono.empty();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
protected Mono<String> resolveUrlPathInternal(String path, List<? extends Resource> locations,
ResourceResolverChain chain) {
if (StringUtils.hasText(path)) {
return getResource(path, locations).map(resource -> path);
}
else {
return Mono.empty();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) {
WebHandler webHandler = (WebHandler) handler;
Mono<Void> mono = webHandler.handle(exchange);
return mono.then(Mono.empty());
}
代码示例来源:origin: spring-projects/spring-framework
private <T> Function<Flux<T>, Publisher<?>> reconnectFunction(ReconnectStrategy reconnectStrategy) {
return flux -> flux
.scan(1, (count, element) -> count++)
.flatMap(attempt -> Optional.ofNullable(reconnectStrategy.getTimeToNextAttempt(attempt))
.map(time -> Mono.delay(Duration.ofMillis(time), this.scheduler))
.orElse(Mono.empty()));
}
代码示例来源:origin: spring-projects/spring-framework
private HandshakeInfo createHandshakeInfo(URI url, DefaultNegotiation negotiation) {
HttpHeaders responseHeaders = negotiation.getResponseHeaders();
String protocol = responseHeaders.getFirst("Sec-WebSocket-Protocol");
return new HandshakeInfo(url, responseHeaders, Mono.empty(), protocol);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> close(CloseStatus status) {
getDelegate().close(status.getCode(), status.getReason());
return Mono.empty();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Send a redirect back to the HTTP client.
* @param targetUrl the target URL to redirect to
* @param exchange current exchange
*/
protected Mono<Void> sendRedirect(String targetUrl, ServerWebExchange exchange) {
String transformedUrl = (isRemoteHost(targetUrl) ? targetUrl : exchange.transformUrl(targetUrl));
ServerHttpResponse response = exchange.getResponse();
response.getHeaders().setLocation(URI.create(transformedUrl));
response.setStatusCode(getStatusCode());
return Mono.empty();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
exchange.getResponse().setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
return Mono.empty();
}
}
代码示例来源:origin: spring-projects/spring-framework
private ServerHttpRequest adaptFromForwardedHeaders(MockServerHttpRequest.BaseBuilder<?> builder) {
AtomicReference<ServerHttpRequest> requestRef = new AtomicReference<>();
MockServerWebExchange exchange = MockServerWebExchange.from(builder);
new ForwardedHeaderFilter().filter(exchange, exchange2 -> {
requestRef.set(exchange2.getRequest());
return Mono.empty();
}).block();
return requestRef.get();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void cancellationAfterTerminated() {
Future<Void> future = new MonoToListenableFutureAdapter<>(Mono.empty());
assertFalse("Should return false if task already completed", future.cancel(true));
assertFalse(future.isCancelled());
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> close(CloseStatus status) {
CloseMessage cm = new CloseMessage(status.getCode(), status.getReason());
if (!getDelegate().isCloseFrameSent()) {
WebSockets.sendClose(cm, getDelegate(), null);
}
return Mono.empty();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> close(CloseStatus status) {
try {
CloseReason.CloseCode code = CloseCodes.getCloseCode(status.getCode());
getDelegate().close(new CloseReason(code, status.getReason()));
}
catch (IOException ex) {
return Mono.error(ex);
}
return Mono.empty();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
URI uri = request.getURI();
assertEquals("http", uri.getScheme());
assertNotNull(uri.getHost());
assertNotEquals(-1, uri.getPort());
assertNotNull(request.getRemoteAddress());
assertEquals("/foo", uri.getPath());
assertEquals("param=bar", uri.getQuery());
return Mono.empty();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void resolveUrlExistingNotInJarFile() {
this.locations = singletonList(new ClassPathResource("/META-INF/resources/webjars/", getClass()));
String file = "foo/foo.txt";
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(Mono.empty());
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain).block(TIMEOUT);
assertNull(actual);
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
verify(this.chain, never()).resolveUrlPath("foo/2.3/foo.txt", this.locations);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void resolveUrlWebJarResourceNotFound() {
String file = "something/something.js";
given(this.chain.resolveUrlPath(file, this.locations)).willReturn(Mono.empty());
String actual = this.resolver.resolveUrlPath(file, this.locations, this.chain).block(TIMEOUT);
assertNull(actual);
verify(this.chain, times(1)).resolveUrlPath(file, this.locations);
verify(this.chain, never()).resolveUrlPath(null, this.locations);
}
内容来源于网络,如有侵权,请联系作者删除!