Polishing

This commit is contained in:
Juergen Hoeller 2020-06-06 13:21:46 +02:00
parent 196bb6fe32
commit d14140da69
4 changed files with 24 additions and 23 deletions

View File

@ -76,9 +76,8 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
new InstanceComparator<>( new InstanceComparator<>(
Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class), Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class),
(Converter<Method, Annotation>) method -> { (Converter<Method, Annotation>) method -> {
AspectJAnnotation<?> annotation = AspectJAnnotation<?> ann = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method); return (ann != null ? ann.getAnnotation() : null);
return (annotation != null ? annotation.getAnnotation() : null);
}); });
Comparator<Method> methodNameComparator = new ConvertingComparator<>(Method::getName); Comparator<Method> methodNameComparator = new ConvertingComparator<>(Method::getName);
METHOD_COMPARATOR = adviceKindComparator.thenComparing(methodNameComparator); METHOD_COMPARATOR = adviceKindComparator.thenComparing(methodNameComparator);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -138,14 +138,8 @@ class AspectJPrecedenceComparator implements Comparator<Advisor> {
} }
private int getAspectDeclarationOrder(Advisor anAdvisor) { private int getAspectDeclarationOrder(Advisor anAdvisor) {
AspectJPrecedenceInformation precedenceInfo = AspectJPrecedenceInformation precedenceInfo = AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor);
AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor); return (precedenceInfo != null ? precedenceInfo.getDeclarationOrder() : 0);
if (precedenceInfo != null) {
return precedenceInfo.getDeclarationOrder();
}
else {
return 0;
}
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,6 +42,7 @@ public class DelegatingWebFluxConfiguration extends WebFluxConfigurationSupport
private final WebFluxConfigurerComposite configurers = new WebFluxConfigurerComposite(); private final WebFluxConfigurerComposite configurers = new WebFluxConfigurerComposite();
@Autowired(required = false) @Autowired(required = false)
public void setConfigurers(List<WebFluxConfigurer> configurers) { public void setConfigurers(List<WebFluxConfigurer> configurers) {
if (!CollectionUtils.isEmpty(configurers)) { if (!CollectionUtils.isEmpty(configurers)) {
@ -49,6 +50,7 @@ public class DelegatingWebFluxConfiguration extends WebFluxConfigurationSupport
} }
} }
@Override @Override
protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) { protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
this.configurers.configureContentTypeResolver(builder); this.configurers.configureContentTypeResolver(builder);
@ -100,4 +102,5 @@ public class DelegatingWebFluxConfiguration extends WebFluxConfigurationSupport
protected void configureViewResolvers(ViewResolverRegistry registry) { protected void configureViewResolvers(ViewResolverRegistry registry) {
this.configurers.configureViewResolvers(registry); this.configurers.configureViewResolvers(registry);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -93,10 +93,6 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
@Nullable @Nullable
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Nullable
public final ApplicationContext getApplicationContext() {
return this.applicationContext;
}
@Override @Override
public void setApplicationContext(@Nullable ApplicationContext applicationContext) { public void setApplicationContext(@Nullable ApplicationContext applicationContext) {
@ -108,6 +104,12 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
} }
} }
@Nullable
public final ApplicationContext getApplicationContext() {
return this.applicationContext;
}
@Bean @Bean
public DispatcherHandler webHandler() { public DispatcherHandler webHandler() {
return new DispatcherHandler(); return new DispatcherHandler();
@ -122,6 +124,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
@Bean @Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping( public RequestMappingHandlerMapping requestMappingHandlerMapping(
@Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) { @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) {
RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping(); RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping();
mapping.setOrder(0); mapping.setOrder(0);
mapping.setContentTypeResolver(contentTypeResolver); mapping.setContentTypeResolver(contentTypeResolver);
@ -205,7 +208,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
@Bean @Bean
public RouterFunctionMapping routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer) { public RouterFunctionMapping routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer) {
RouterFunctionMapping mapping = createRouterFunctionMapping(); RouterFunctionMapping mapping = createRouterFunctionMapping();
mapping.setOrder(-1); // go before RequestMappingHandlerMapping mapping.setOrder(-1); // go before RequestMappingHandlerMapping
mapping.setMessageReaders(serverCodecConfigurer.getReaders()); mapping.setMessageReaders(serverCodecConfigurer.getReaders());
mapping.setCorsConfigurations(getCorsConfigurations()); mapping.setCorsConfigurations(getCorsConfigurations());
@ -330,8 +333,8 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
* initializing all {@link WebDataBinder} instances. * initializing all {@link WebDataBinder} instances.
*/ */
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer( protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer(
FormattingConversionService webFluxConversionService, FormattingConversionService webFluxConversionService, Validator webFluxValidator) {
Validator webFluxValidator) {
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(webFluxConversionService); initializer.setConversionService(webFluxConversionService);
initializer.setValidator(webFluxValidator); initializer.setValidator(webFluxValidator);
@ -430,6 +433,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, @Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry,
ServerCodecConfigurer serverCodecConfigurer, ServerCodecConfigurer serverCodecConfigurer,
@Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) { @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) {
return new ResponseEntityResultHandler(serverCodecConfigurer.getWriters(), return new ResponseEntityResultHandler(serverCodecConfigurer.getWriters(),
contentTypeResolver, reactiveAdapterRegistry); contentTypeResolver, reactiveAdapterRegistry);
} }
@ -439,6 +443,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, @Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry,
ServerCodecConfigurer serverCodecConfigurer, ServerCodecConfigurer serverCodecConfigurer,
@Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) { @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) {
return new ResponseBodyResultHandler(serverCodecConfigurer.getWriters(), return new ResponseBodyResultHandler(serverCodecConfigurer.getWriters(),
contentTypeResolver, reactiveAdapterRegistry); contentTypeResolver, reactiveAdapterRegistry);
} }
@ -447,6 +452,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
public ViewResolutionResultHandler viewResolutionResultHandler( public ViewResolutionResultHandler viewResolutionResultHandler(
@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, @Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry,
@Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) { @Qualifier("webFluxContentTypeResolver") RequestedContentTypeResolver contentTypeResolver) {
ViewResolverRegistry registry = getViewResolverRegistry(); ViewResolverRegistry registry = getViewResolverRegistry();
List<ViewResolver> resolvers = registry.getViewResolvers(); List<ViewResolver> resolvers = registry.getViewResolvers();
ViewResolutionResultHandler handler = new ViewResolutionResultHandler( ViewResolutionResultHandler handler = new ViewResolutionResultHandler(
@ -457,8 +463,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
} }
@Bean @Bean
public ServerResponseResultHandler serverResponseResultHandler( public ServerResponseResultHandler serverResponseResultHandler(ServerCodecConfigurer serverCodecConfigurer) {
ServerCodecConfigurer serverCodecConfigurer) {
List<ViewResolver> resolvers = getViewResolverRegistry().getViewResolvers(); List<ViewResolver> resolvers = getViewResolverRegistry().getViewResolvers();
ServerResponseResultHandler handler = new ServerResponseResultHandler(); ServerResponseResultHandler handler = new ServerResponseResultHandler();
handler.setMessageWriters(serverCodecConfigurer.getWriters()); handler.setMessageWriters(serverCodecConfigurer.getWriters());