Polishing

This commit is contained in:
Juergen Hoeller
2018-07-31 21:37:40 +02:00
parent a4be54d760
commit fd75600c26
9 changed files with 63 additions and 64 deletions

View File

@@ -80,7 +80,7 @@ public interface ServerWebExchange {
@SuppressWarnings("unchecked")
default <T> T getRequiredAttribute(String name) {
T value = getAttribute(name);
Assert.notNull(value, "Required attribute '" + name + "' is missing.");
Assert.notNull(value, () -> "Required attribute '" + name + "' is missing.");
return value;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ public interface WebSession {
@SuppressWarnings("unchecked")
default <T> T getRequiredAttribute(String name) {
T value = getAttribute(name);
Assert.notNull(value, "Required attribute '" + name + "' is missing.");
Assert.notNull(value, () -> "Required attribute '" + name + "' is missing.");
return value;
}
@@ -116,13 +116,19 @@ public interface WebSession {
Mono<Void> invalidate();
/**
* Save the session persisting attributes (e.g. if stored remotely) and also
* sending the session id to the client if the session is new.
* <p>Note that a session must be started explicitly via {@link #start()} or
* implicitly by adding attributes or otherwise this method has no effect.
* Save the session through the {@code WebSessionStore} as follows:
* <ul>
* <li>If the session is new (i.e. created but never persisted), it must have
* been started explicitly via {@link #start()} or implicitly by adding
* attributes, or otherwise this method should have no effect.
* <li>If the session was retrieved through the {@code WebSessionStore},
* the implementation for this method must check whether the session was
* {@link #invalidate() invalidated} and if so return an error.
* </ul>
* <p>Note that this method is not intended for direct use by applications.
* Instead it is automatically invoked just before the response is
* committed.
* @return {@code Mono} to indicate completion with success or error
* <p>Typically this method should be automatically invoked just before the
* response is committed so applications don't have to by default.
*/
Mono<Void> save();

View File

@@ -42,20 +42,18 @@ import org.springframework.web.server.session.DefaultWebSessionManager;
import org.springframework.web.server.session.WebSessionManager;
/**
* This builder has two purposes.
* This builder has two purposes:
*
* <p>One is to assemble a processing chain that consists of a target
* {@link WebHandler}, then decorated with a set of {@link WebFilter}'s, then
* further decorated with a set of {@link WebExceptionHandler}'s.
* <p>One is to assemble a processing chain that consists of a target {@link WebHandler},
* then decorated with a set of {@link WebFilter WebFilters}, then further decorated with
* a set of {@link WebExceptionHandler WebExceptionHandlers}.
*
* <p>The second purpose is to adapt the resulting processing chain to an
* {@link HttpHandler} -- the lowest level reactive HTTP handling abstraction,
* which can then be used with any of the supported runtimes. The adaptation
* is done with the help of {@link HttpWebHandlerAdapter}.
* <p>The second purpose is to adapt the resulting processing chain to an {@link HttpHandler}:
* the lowest-level reactive HTTP handling abstraction which can then be used with any of the
* supported runtimes. The adaptation is done with the help of {@link HttpWebHandlerAdapter}.
*
* <p>The processing chain can be assembled manually via builder methods, or
* detected from Spring configuration via
* {@link #applicationContext(ApplicationContext)}, or a mix of both.
* <p>The processing chain can be assembled manually via builder methods, or detected from
* a Spring {@link ApplicationContext} via {@link #applicationContext}, or a mix of both.
*
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
@@ -240,13 +238,12 @@ public class WebHttpHandlerBuilder {
}
/**
* Whether a {@code WebSessionManager} is configured or not, either
* detected from an {@code ApplicationContext} or explicitly configured via
* {@link #sessionManager(WebSessionManager)}.
* Whether a {@code WebSessionManager} is configured or not, either detected from an
* {@code ApplicationContext} or explicitly configured via {@link #sessionManager}.
* @since 5.0.9
*/
public boolean hasSessionManager() {
return this.sessionManager != null;
return (this.sessionManager != null);
}
/**
@@ -260,13 +257,12 @@ public class WebHttpHandlerBuilder {
/**
* Whether a {@code ServerCodecConfigurer} is configured or not, either
* detected from an {@code ApplicationContext} or explicitly configured via
* {@link #codecConfigurer(ServerCodecConfigurer)}.
* Whether a {@code ServerCodecConfigurer} is configured or not, either detected from an
* {@code ApplicationContext} or explicitly configured via {@link #codecConfigurer}.
* @since 5.0.9
*/
public boolean hasCodecConfigurer() {
return this.codecConfigurer != null;
return (this.codecConfigurer != null);
}
/**
@@ -280,13 +276,12 @@ public class WebHttpHandlerBuilder {
}
/**
* Whether a {@code LocaleContextResolver} is configured or not, either
* detected from an {@code ApplicationContext} or explicitly configured via
* {@link #localeContextResolver(LocaleContextResolver)}.
* Whether a {@code LocaleContextResolver} is configured or not, either detected from an
* {@code ApplicationContext} or explicitly configured via {@link #localeContextResolver}.
* @since 5.0.9
*/
public boolean hasLocaleContextResolver() {
return this.localeContextResolver != null;
return (this.localeContextResolver != null);
}