diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index f3b976a3d1..d34b6af0ea 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -79,19 +79,17 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** - * Spring's default implementation of the - * {@link org.springframework.beans.factory.ListableBeanFactory} and - * {@link BeanDefinitionRegistry} interfaces: a full-fledged bean factory - * based on bean definition objects. + * Spring's default implementation of the {@link ConfigurableListableBeanFactory} + * and {@link BeanDefinitionRegistry} interfaces: a full-fledged bean factory + * based on bean definition metadata, extensible through post-processors. * *

Typical usage is registering all bean definitions first (possibly read - * from a bean definition file), before accessing beans. Bean definition lookup + * from a bean definition file), before accessing beans. Bean lookup by name * is therefore an inexpensive operation in a local bean definition table, - * operating on pre-built bean definition metadata objects. + * operating on pre-resolved bean definition metadata objects. * - *

Can be used as a standalone bean factory, or as a superclass for custom - * bean factories. Note that readers for specific bean definition formats are - * typically implemented separately rather than as bean factory subclasses: + *

Note that readers for specific bean definition formats are typically + * implemented separately rather than as bean factory subclasses: * see for example {@link PropertiesBeanDefinitionReader} and * {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}. * @@ -108,9 +106,10 @@ import org.springframework.util.StringUtils; * @author Phillip Webb * @author Stephane Nicoll * @since 16 April 2001 - * @see StaticListableBeanFactory - * @see PropertiesBeanDefinitionReader - * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader + * @see #registerBeanDefinition + * @see #addBeanPostProcessor + * @see #getBean + * @see #resolveDependency */ @SuppressWarnings("serial") public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java index faafb3f18f..e486fc5842 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java @@ -41,9 +41,8 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; /** * Central entry point to Spring's functional web framework. - * Exposes routing functionality, such as to - * {@linkplain #route() create} a {@code RouterFunction} using a discoverable builder-style API, - * to + * Exposes routing functionality, such as to {@linkplain #route() create} a + * {@code RouterFunction} using a discoverable builder-style API, to * {@linkplain #route(RequestPredicate, HandlerFunction) create} a {@code RouterFunction} * given a {@code RequestPredicate} and {@code HandlerFunction}, and to do further * {@linkplain #nest(RequestPredicate, RouterFunction) subrouting} on an existing routing @@ -72,7 +71,9 @@ public abstract class RouterFunctions { public static final String URI_TEMPLATE_VARIABLES_ATTRIBUTE = RouterFunctions.class.getName() + ".uriTemplateVariables"; - private static final HandlerFunction NOT_FOUND_HANDLER = request -> ServerResponse.notFound().build(); + private static final HandlerFunction NOT_FOUND_HANDLER = + request -> ServerResponse.notFound().build(); + /** * Offers a discoverable way to create router functions through a builder-style interface. @@ -116,9 +117,8 @@ public abstract class RouterFunctions { * RouterFunction<ServerResponse> userRoutes = * RouterFunctions.route(RequestPredicates.method(HttpMethod.GET), this::listUsers) * .andRoute(RequestPredicates.method(HttpMethod.POST), this::createUser); - * * RouterFunction<ServerResponse> nestedRoute = - * RouterFunctions.nest(RequestPredicates.path("/user"),userRoutes); + * RouterFunctions.nest(RequestPredicates.path("/user"), userRoutes); * * @param predicate the predicate to test * @param routerFunction the nested router function to delegate to if the predicate applies @@ -158,7 +158,6 @@ public abstract class RouterFunctions { * Function<ServerRequest, Mono<Resource>> lookupFunction = * RouterFunctions.resourceLookupFunction("/resources/**", new FileSystemResource("public-resources/")) * .andThen(resourceMono -> resourceMono.switchIfEmpty(defaultResource)); - * * RouterFunction<ServerResponse> resources = RouterFunctions.resources(lookupFunction); * * @param pattern the pattern to match @@ -259,6 +258,7 @@ public abstract class RouterFunctions { }; } + private static Mono wrapException(Supplier> supplier) { try { return supplier.get(); @@ -283,9 +283,10 @@ public abstract class RouterFunctions { return (HandlerFunction) handlerFunction; } + /** - * Represents a discoverable builder for router functions. Obtained via - * {@link RouterFunctions#route()}. + * Represents a discoverable builder for router functions. + * Obtained via {@link RouterFunctions#route()}. * @since 5.1 */ public interface Builder { @@ -307,9 +308,8 @@ public abstract class RouterFunctions { * to the {@code listUsers} method in {@code userController}: *

 		 * RouterFunction<ServerResponse> route =
-		 *     RouterFunctions.route()
-		 *     .GET("/user", RequestPredicates.accept(MediaType.APPLICATION_JSON),
-		 *       userController::listUsers)
+		 *   RouterFunctions.route()
+		 *     .GET("/user", RequestPredicates.accept(MediaType.APPLICATION_JSON), userController::listUsers)
 		 *     .build();
 		 * 
* @param pattern the pattern to match to @@ -359,9 +359,8 @@ public abstract class RouterFunctions { * to the {@code addUser} method in {@code userController}: *
 		 * RouterFunction<ServerResponse> route =
-		 *     RouterFunctions.route()
-		 *     .POST("/user", RequestPredicates.contentType(MediaType.APPLICATION_JSON),
-		 *       userController::addUser)
+		 *   RouterFunctions.route()
+		 *     .POST("/user", RequestPredicates.contentType(MediaType.APPLICATION_JSON), userController::addUser)
 		 *     .build();
 		 * 
* @param pattern the pattern to match to @@ -389,9 +388,8 @@ public abstract class RouterFunctions { * to the {@code editUser} method in {@code userController}: *
 		 * RouterFunction<ServerResponse> route =
-		 *     RouterFunctions.route()
-		 *     .PUT("/user", RequestPredicates.contentType(MediaType.APPLICATION_JSON),
-		 *       userController::editUser)
+		 *   RouterFunctions.route()
+		 *     .PUT("/user", RequestPredicates.contentType(MediaType.APPLICATION_JSON), userController::editUser)
 		 *     .build();
 		 * 
* @param pattern the pattern to match to @@ -419,9 +417,8 @@ public abstract class RouterFunctions { * to the {@code editUser} method in {@code userController}: *
 		 * RouterFunction<ServerResponse> route =
-		 *     RouterFunctions.route()
-		 *     .PATCH("/user", RequestPredicates.contentType(MediaType.APPLICATION_JSON),
-		 *       userController::editUser)
+		 *   RouterFunctions.route()
+		 *     .PATCH("/user", RequestPredicates.contentType(MediaType.APPLICATION_JSON), userController::editUser)
 		 *     .build();
 		 * 
* @param pattern the pattern to match to @@ -483,11 +480,11 @@ public abstract class RouterFunctions { * {@code OrderController.routerFunction()}. * to the {@code changeUser} method in {@code userController}: *
-		 * RouterFunction<ServerResponse> route =
+		 * RouterFunctionlt;ServerResponsegt; route =
 		 *   RouterFunctions.route()
-		 *   .GET("/users", userController::listUsers)
-		 *   .add(orderController.routerFunction());
-		 *   .build();
+		 *     .GET("/users", userController::listUsers)
+		 *     .add(orderController.routerFunction());
+		 *     .build();
 		 * 
* @param routerFunction the router function to be added * @return this builder @@ -529,10 +526,9 @@ public abstract class RouterFunctions { * RouterFunctions.route() * .nest(RequestPredicates.path("/user"), () -> * RouterFunctions.route() - * .GET(this::listUsers) - * .POST(this::createUser); - * .build(); - * ) + * .GET(this::listUsers) + * .POST(this::createUser) + * .build()) * .build(); * * @param predicate the predicate to test @@ -555,8 +551,7 @@ public abstract class RouterFunctions { * RouterFunctions.route() * .nest(RequestPredicates.path("/user"), builder -> * builder.GET(this::listUsers) - * .POST(this::createUser); - * ) + * .POST(this::createUser)) * .build(); * * @param predicate the predicate to test @@ -601,8 +596,7 @@ public abstract class RouterFunctions { * RouterFunctions.route() * .path("/user", builder -> * builder.GET(this::listUsers) - * .POST(this::createUser); - * ) + * .POST(this::createUser)) * .build(); * * @param pattern the pattern to match to @@ -727,7 +721,6 @@ public abstract class RouterFunctions { * @return the built router function */ RouterFunction build(); - } @@ -784,11 +777,11 @@ public abstract class RouterFunctions { } } + /** * A composed routing function that first invokes one function, and then invokes the * another function (of the same response type {@code T}) if this route had * {@linkplain Mono#empty() no result}. - * * @param the server response type */ static final class SameComposedRouterFunction extends AbstractRouterFunction { @@ -815,6 +808,7 @@ public abstract class RouterFunctions { } } + /** * A composed routing function that first invokes one function, and then invokes * another function (of a different response type) if this route had @@ -843,13 +837,12 @@ public abstract class RouterFunctions { this.first.accept(visitor); this.second.accept(visitor); } - } + /** * Filter the specified {@linkplain HandlerFunction handler functions} with the given * {@linkplain HandlerFilterFunction filter function}. - * * @param the type of the {@linkplain HandlerFunction handler function} to filter * @param the type of the response of the function */ @@ -883,8 +876,8 @@ public abstract class RouterFunctions { } } - private static final class DefaultRouterFunction - extends AbstractRouterFunction { + + private static final class DefaultRouterFunction extends AbstractRouterFunction { private final RequestPredicate predicate; @@ -915,11 +908,10 @@ public abstract class RouterFunctions { public void accept(Visitor visitor) { visitor.route(this.predicate, this.handlerFunction); } - } - private static final class DefaultNestedRouterFunction - extends AbstractRouterFunction { + + private static final class DefaultNestedRouterFunction extends AbstractRouterFunction { private final RequestPredicate predicate; @@ -952,7 +944,8 @@ public abstract class RouterFunctions { private void mergeTemplateVariables(ServerRequest request, Map variables) { if (!variables.isEmpty()) { Map attributes = request.attributes(); - Map oldVariables = (Map)request.attribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE) + Map oldVariables = + (Map) request.attribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE) .orElseGet(LinkedHashMap::new); Map mergedVariables = new LinkedHashMap<>(oldVariables); mergedVariables.putAll(variables); @@ -967,9 +960,9 @@ public abstract class RouterFunctions { this.routerFunction.accept(visitor); visitor.endNested(this.predicate); } - } + private static class ResourcesRouterFunction extends AbstractRouterFunction { private final Function> lookupFunction; @@ -990,6 +983,7 @@ public abstract class RouterFunctions { } } + private static class HandlerStrategiesResponseContext implements ServerResponse.Context { private final HandlerStrategies strategies;