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 3da1b9ecc9a..932dc587c89 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 @@ -1249,7 +1248,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } } - private FactoryAwareOrderSourceProvider createFactoryAwareOrderSourceProvider(Map beans) { + private OrderComparator.OrderSourceProvider createFactoryAwareOrderSourceProvider(Map beans) { IdentityHashMap instancesToBeanNames = new IdentityHashMap<>(); beans.forEach((beanName, instance) -> instancesToBeanNames.put(instance, beanName)); return new FactoryAwareOrderSourceProvider(instancesToBeanNames); @@ -1616,6 +1615,29 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } + /** + * A dependency descriptor marker for nested elements. + */ + private static class NestedDependencyDescriptor extends DependencyDescriptor { + + public NestedDependencyDescriptor(DependencyDescriptor original) { + super(original); + increaseNestingLevel(); + } + } + + + /** + * A dependency descriptor marker for multiple elements. + */ + private static class MultiElementDescriptor extends NestedDependencyDescriptor { + + public MultiElementDescriptor(DependencyDescriptor original) { + super(original); + } + } + + /** * Serializable ObjectFactory/ObjectProvider for lazy resolution of a dependency. */ @@ -1720,7 +1742,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto /** - * Serializable ObjectFactory for lazy resolution of a dependency. + * A {@code javax.inject.Provider} implementation for lazy resolution of a dependency. */ private class Jsr330DependencyProvider extends DependencyObjectProvider implements Provider { @@ -1793,21 +1815,4 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } } - - private static class NestedDependencyDescriptor extends DependencyDescriptor { - - public NestedDependencyDescriptor(DependencyDescriptor original) { - super(original); - increaseNestingLevel(); - } - } - - - private static class MultiElementDescriptor extends NestedDependencyDescriptor { - - public MultiElementDescriptor(DependencyDescriptor original) { - super(original); - } - } - } 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 fa01cb4dfd5..e4a76e6c165 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 @@ -67,7 +67,8 @@ 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(); /** @@ -103,9 +104,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 @@ -125,7 +125,7 @@ public abstract class RouterFunctions { * For instance *
 	 * Resource location = new FileSystemResource("public-resources/");
-	 * RoutingFunction<ServerResponse> resources = RouterFunctions.resources("/resources/**", location);
+	 * RouterFunction<ServerResponse> resources = RouterFunctions.resources("/resources/**", location);
      * 
* @param pattern the pattern to match * @param location the location directory relative to which resources should be resolved @@ -225,12 +225,13 @@ public abstract class RouterFunctions { }; } + private static Mono wrapException(Supplier> supplier) { try { return supplier.get(); } - catch (Throwable t) { - return Mono.error(t); + catch (Throwable ex) { + return Mono.error(ex); } } @@ -303,6 +304,7 @@ public abstract class RouterFunctions { } } + static final class SameComposedRouterFunction extends AbstractRouterFunction { private final RouterFunction first; @@ -350,9 +352,9 @@ public abstract class RouterFunctions { this.first.accept(visitor); this.second.accept(visitor); } - } + static final class FilteredRouterFunction implements RouterFunction { @@ -383,8 +385,8 @@ public abstract class RouterFunctions { } } - private static final class DefaultRouterFunction - extends AbstractRouterFunction { + + private static final class DefaultRouterFunction extends AbstractRouterFunction { private final RequestPredicate predicate; @@ -414,11 +416,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; @@ -446,15 +447,15 @@ public abstract class RouterFunctions { mergeTemplateVariables(serverRequest, nestedRequest.pathVariables()); }); } - ) - .orElseGet(Mono::empty); + ).orElseGet(Mono::empty); } @SuppressWarnings("unchecked") 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); @@ -469,9 +470,9 @@ public abstract class RouterFunctions { this.routerFunction.accept(visitor); visitor.endNested(this.predicate); } - } + private static class ResourcesRouterFunction extends AbstractRouterFunction { private final Function> lookupFunction; @@ -492,6 +493,7 @@ public abstract class RouterFunctions { } } + private static class HandlerStrategiesResponseContext implements ServerResponse.Context { private final HandlerStrategies strategies;