Skip to content

Commit eb3254d

Browse files
committed
Polishing
1 parent 6cae065 commit eb3254d

File tree

2 files changed

+54
-47
lines changed

2 files changed

+54
-47
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,17 @@
7979
import org.springframework.util.StringUtils;
8080

8181
/**
82-
* Spring's default implementation of the
83-
* {@link org.springframework.beans.factory.ListableBeanFactory} and
84-
* {@link BeanDefinitionRegistry} interfaces: a full-fledged bean factory
85-
* based on bean definition objects.
82+
* Spring's default implementation of the {@link ConfigurableListableBeanFactory}
83+
* and {@link BeanDefinitionRegistry} interfaces: a full-fledged bean factory
84+
* based on bean definition metadata, extensible through post-processors.
8685
*
8786
* <p>Typical usage is registering all bean definitions first (possibly read
88-
* from a bean definition file), before accessing beans. Bean definition lookup
87+
* from a bean definition file), before accessing beans. Bean lookup by name
8988
* is therefore an inexpensive operation in a local bean definition table,
90-
* operating on pre-built bean definition metadata objects.
89+
* operating on pre-resolved bean definition metadata objects.
9190
*
92-
* <p>Can be used as a standalone bean factory, or as a superclass for custom
93-
* bean factories. Note that readers for specific bean definition formats are
94-
* typically implemented separately rather than as bean factory subclasses:
91+
* <p>Note that readers for specific bean definition formats are typically
92+
* implemented separately rather than as bean factory subclasses:
9593
* see for example {@link PropertiesBeanDefinitionReader} and
9694
* {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}.
9795
*
@@ -108,9 +106,10 @@
108106
* @author Phillip Webb
109107
* @author Stephane Nicoll
110108
* @since 16 April 2001
111-
* @see StaticListableBeanFactory
112-
* @see PropertiesBeanDefinitionReader
113-
* @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
109+
* @see #registerBeanDefinition
110+
* @see #addBeanPostProcessor
111+
* @see #getBean
112+
* @see #resolveDependency
114113
*/
115114
@SuppressWarnings("serial")
116115
public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory
@@ -1249,7 +1248,7 @@ private Comparator<Object> adaptDependencyComparator(Map<String, Object> matchin
12491248
}
12501249
}
12511250

1252-
private FactoryAwareOrderSourceProvider createFactoryAwareOrderSourceProvider(Map<String, Object> beans) {
1251+
private OrderComparator.OrderSourceProvider createFactoryAwareOrderSourceProvider(Map<String, Object> beans) {
12531252
IdentityHashMap<Object, String> instancesToBeanNames = new IdentityHashMap<>();
12541253
beans.forEach((beanName, instance) -> instancesToBeanNames.put(instance, beanName));
12551254
return new FactoryAwareOrderSourceProvider(instancesToBeanNames);
@@ -1616,6 +1615,29 @@ private Object readResolve() {
16161615
}
16171616

16181617

1618+
/**
1619+
* A dependency descriptor marker for nested elements.
1620+
*/
1621+
private static class NestedDependencyDescriptor extends DependencyDescriptor {
1622+
1623+
public NestedDependencyDescriptor(DependencyDescriptor original) {
1624+
super(original);
1625+
increaseNestingLevel();
1626+
}
1627+
}
1628+
1629+
1630+
/**
1631+
* A dependency descriptor marker for multiple elements.
1632+
*/
1633+
private static class MultiElementDescriptor extends NestedDependencyDescriptor {
1634+
1635+
public MultiElementDescriptor(DependencyDescriptor original) {
1636+
super(original);
1637+
}
1638+
}
1639+
1640+
16191641
/**
16201642
* Serializable ObjectFactory/ObjectProvider for lazy resolution of a dependency.
16211643
*/
@@ -1720,7 +1742,7 @@ protected Object getValue() throws BeansException {
17201742

17211743

17221744
/**
1723-
* Serializable ObjectFactory for lazy resolution of a dependency.
1745+
* A {@code javax.inject.Provider} implementation for lazy resolution of a dependency.
17241746
*/
17251747
private class Jsr330DependencyProvider extends DependencyObjectProvider implements Provider<Object> {
17261748

@@ -1793,21 +1815,4 @@ private RootBeanDefinition getRootBeanDefinition(@Nullable String beanName) {
17931815
}
17941816
}
17951817

1796-
1797-
private static class NestedDependencyDescriptor extends DependencyDescriptor {
1798-
1799-
public NestedDependencyDescriptor(DependencyDescriptor original) {
1800-
super(original);
1801-
increaseNestingLevel();
1802-
}
1803-
}
1804-
1805-
1806-
private static class MultiElementDescriptor extends NestedDependencyDescriptor {
1807-
1808-
public MultiElementDescriptor(DependencyDescriptor original) {
1809-
super(original);
1810-
}
1811-
}
1812-
18131818
}

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public abstract class RouterFunctions {
6767
public static final String URI_TEMPLATE_VARIABLES_ATTRIBUTE =
6868
RouterFunctions.class.getName() + ".uriTemplateVariables";
6969

70-
private static final HandlerFunction<ServerResponse> NOT_FOUND_HANDLER = request -> ServerResponse.notFound().build();
70+
private static final HandlerFunction<ServerResponse> NOT_FOUND_HANDLER =
71+
request -> ServerResponse.notFound().build();
7172

7273

7374
/**
@@ -103,9 +104,8 @@ public static <T extends ServerResponse> RouterFunction<T> route(
103104
* RouterFunction&lt;ServerResponse&gt; userRoutes =
104105
* RouterFunctions.route(RequestPredicates.method(HttpMethod.GET), this::listUsers)
105106
* .andRoute(RequestPredicates.method(HttpMethod.POST), this::createUser);
106-
*
107107
* RouterFunction&lt;ServerResponse&gt; nestedRoute =
108-
* RouterFunctions.nest(RequestPredicates.path("/user"),userRoutes);
108+
* RouterFunctions.nest(RequestPredicates.path("/user"), userRoutes);
109109
* </pre>
110110
* @param predicate the predicate to test
111111
* @param routerFunction the nested router function to delegate to if the predicate applies
@@ -125,7 +125,7 @@ public static <T extends ServerResponse> RouterFunction<T> nest(
125125
* For instance
126126
* <pre class="code">
127127
* Resource location = new FileSystemResource("public-resources/");
128-
* RoutingFunction&lt;ServerResponse&gt; resources = RouterFunctions.resources("/resources/**", location);
128+
* RouterFunction&lt;ServerResponse&gt; resources = RouterFunctions.resources("/resources/**", location);
129129
* </pre>
130130
* @param pattern the pattern to match
131131
* @param location the location directory relative to which resources should be resolved
@@ -225,12 +225,13 @@ public static WebHandler toWebHandler(RouterFunction<?> routerFunction, HandlerS
225225
};
226226
}
227227

228+
228229
private static <T> Mono<T> wrapException(Supplier<Mono<T>> supplier) {
229230
try {
230231
return supplier.get();
231232
}
232-
catch (Throwable t) {
233-
return Mono.error(t);
233+
catch (Throwable ex) {
234+
return Mono.error(ex);
234235
}
235236
}
236237

@@ -303,6 +304,7 @@ public String toString() {
303304
}
304305
}
305306

307+
306308
static final class SameComposedRouterFunction<T extends ServerResponse> extends AbstractRouterFunction<T> {
307309

308310
private final RouterFunction<T> first;
@@ -350,9 +352,9 @@ public void accept(Visitor visitor) {
350352
this.first.accept(visitor);
351353
this.second.accept(visitor);
352354
}
353-
354355
}
355356

357+
356358
static final class FilteredRouterFunction<T extends ServerResponse, S extends ServerResponse>
357359
implements RouterFunction<S> {
358360

@@ -383,8 +385,8 @@ public String toString() {
383385
}
384386
}
385387

386-
private static final class DefaultRouterFunction<T extends ServerResponse>
387-
extends AbstractRouterFunction<T> {
388+
389+
private static final class DefaultRouterFunction<T extends ServerResponse> extends AbstractRouterFunction<T> {
388390

389391
private final RequestPredicate predicate;
390392

@@ -414,11 +416,10 @@ public Mono<HandlerFunction<T>> route(ServerRequest request) {
414416
public void accept(Visitor visitor) {
415417
visitor.route(this.predicate, this.handlerFunction);
416418
}
417-
418419
}
419420

420-
private static final class DefaultNestedRouterFunction<T extends ServerResponse>
421-
extends AbstractRouterFunction<T> {
421+
422+
private static final class DefaultNestedRouterFunction<T extends ServerResponse> extends AbstractRouterFunction<T> {
422423

423424
private final RequestPredicate predicate;
424425

@@ -446,15 +447,15 @@ public Mono<HandlerFunction<T>> route(ServerRequest serverRequest) {
446447
mergeTemplateVariables(serverRequest, nestedRequest.pathVariables());
447448
});
448449
}
449-
)
450-
.orElseGet(Mono::empty);
450+
).orElseGet(Mono::empty);
451451
}
452452

453453
@SuppressWarnings("unchecked")
454454
private void mergeTemplateVariables(ServerRequest request, Map<String, String> variables) {
455455
if (!variables.isEmpty()) {
456456
Map<String, Object> attributes = request.attributes();
457-
Map<String, String> oldVariables = (Map<String, String>)request.attribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE)
457+
Map<String, String> oldVariables =
458+
(Map<String, String>) request.attribute(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE)
458459
.orElseGet(LinkedHashMap::new);
459460
Map<String, String> mergedVariables = new LinkedHashMap<>(oldVariables);
460461
mergedVariables.putAll(variables);
@@ -469,9 +470,9 @@ public void accept(Visitor visitor) {
469470
this.routerFunction.accept(visitor);
470471
visitor.endNested(this.predicate);
471472
}
472-
473473
}
474474

475+
475476
private static class ResourcesRouterFunction extends AbstractRouterFunction<ServerResponse> {
476477

477478
private final Function<ServerRequest, Mono<Resource>> lookupFunction;
@@ -492,6 +493,7 @@ public void accept(Visitor visitor) {
492493
}
493494
}
494495

496+
495497
private static class HandlerStrategiesResponseContext implements ServerResponse.Context {
496498

497499
private final HandlerStrategies strategies;

0 commit comments

Comments
 (0)