Polishing
This commit is contained in:
parent
22aba8bf60
commit
33b5bc2aae
|
|
@ -281,6 +281,40 @@ class BeanDefinitionValueResolver {
|
|||
return value.resolveTargetType(this.beanFactory.getBeanClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a reference to another bean in the factory.
|
||||
*/
|
||||
@Nullable
|
||||
private Object resolveReference(Object argName, RuntimeBeanReference ref) {
|
||||
try {
|
||||
Object bean;
|
||||
String refName = ref.getBeanName();
|
||||
refName = String.valueOf(doEvaluate(refName));
|
||||
if (ref.isToParent()) {
|
||||
if (this.beanFactory.getParentBeanFactory() == null) {
|
||||
throw new BeanCreationException(
|
||||
this.beanDefinition.getResourceDescription(), this.beanName,
|
||||
"Can't resolve reference to bean '" + refName +
|
||||
"' in parent factory: no parent factory available");
|
||||
}
|
||||
bean = this.beanFactory.getParentBeanFactory().getBean(refName);
|
||||
}
|
||||
else {
|
||||
bean = this.beanFactory.getBean(refName);
|
||||
this.beanFactory.registerDependentBean(refName, this.beanName);
|
||||
}
|
||||
if (bean instanceof NullBean) {
|
||||
bean = null;
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
catch (BeansException ex) {
|
||||
throw new BeanCreationException(
|
||||
this.beanDefinition.getResourceDescription(), this.beanName,
|
||||
"Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an inner bean definition.
|
||||
* @param argName the name of the argument that the inner bean is defined for
|
||||
|
|
@ -345,40 +379,6 @@ class BeanDefinitionValueResolver {
|
|||
return actualInnerBeanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a reference to another bean in the factory.
|
||||
*/
|
||||
@Nullable
|
||||
private Object resolveReference(Object argName, RuntimeBeanReference ref) {
|
||||
try {
|
||||
Object bean;
|
||||
String refName = ref.getBeanName();
|
||||
refName = String.valueOf(doEvaluate(refName));
|
||||
if (ref.isToParent()) {
|
||||
if (this.beanFactory.getParentBeanFactory() == null) {
|
||||
throw new BeanCreationException(
|
||||
this.beanDefinition.getResourceDescription(), this.beanName,
|
||||
"Can't resolve reference to bean '" + refName +
|
||||
"' in parent factory: no parent factory available");
|
||||
}
|
||||
bean = this.beanFactory.getParentBeanFactory().getBean(refName);
|
||||
}
|
||||
else {
|
||||
bean = this.beanFactory.getBean(refName);
|
||||
this.beanFactory.registerDependentBean(refName, this.beanName);
|
||||
}
|
||||
if (bean instanceof NullBean) {
|
||||
bean = null;
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
catch (BeansException ex) {
|
||||
throw new BeanCreationException(
|
||||
this.beanDefinition.getResourceDescription(), this.beanName,
|
||||
"Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For each element in the managed array, resolve reference if necessary.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -130,8 +130,8 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
|
|||
@Override
|
||||
public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) {
|
||||
ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event));
|
||||
for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) {
|
||||
Executor executor = getTaskExecutor();
|
||||
Executor executor = getTaskExecutor();
|
||||
for (ApplicationListener<?> listener : getApplicationListeners(event, type)) {
|
||||
if (executor != null) {
|
||||
executor.execute(() -> invokeListener(listener, event));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
|
|
@ -658,6 +658,9 @@ public class MBeanClientInterceptor
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof MethodCacheKey)) {
|
||||
return false;
|
||||
}
|
||||
MethodCacheKey otherKey = (MethodCacheKey) other;
|
||||
return (this.name.equals(otherKey.name) && Arrays.equals(this.parameterTypes, otherKey.parameterTypes));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ final class IntegerToEnumConverterFactory implements ConverterFactory<Integer, E
|
|||
}
|
||||
|
||||
|
||||
private class IntegerToEnum<T extends Enum> implements Converter<Integer, T> {
|
||||
private static class IntegerToEnum<T extends Enum> implements Converter<Integer, T> {
|
||||
|
||||
private final Class<T> enumType;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
|
|||
}
|
||||
|
||||
|
||||
private class StringToEnum<T extends Enum> implements Converter<String, T> {
|
||||
private static class StringToEnum<T extends Enum> implements Converter<String, T> {
|
||||
|
||||
private final Class<T> enumType;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import org.springframework.lang.Nullable;
|
|||
import org.springframework.util.NumberUtils;
|
||||
|
||||
/**
|
||||
* A simple basic {@link TypeComparator} implementation.
|
||||
* It supports comparison of Numbers and types implementing Comparable.
|
||||
* A basic {@link TypeComparator} implementation: supports comparison of
|
||||
* {@link Number} types as well as types implementing {@link Comparable}.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @author Juergen Hoeller
|
||||
|
|
@ -89,10 +89,10 @@ public class StandardTypeComparator implements TypeComparator {
|
|||
return Integer.compare(leftNumber.intValue(), rightNumber.intValue());
|
||||
}
|
||||
else if (leftNumber instanceof Short || rightNumber instanceof Short) {
|
||||
return leftNumber.shortValue() - rightNumber.shortValue();
|
||||
return Short.compare(leftNumber.shortValue(), rightNumber.shortValue());
|
||||
}
|
||||
else if (leftNumber instanceof Byte || rightNumber instanceof Byte) {
|
||||
return leftNumber.byteValue() - rightNumber.byteValue();
|
||||
return Byte.compare(leftNumber.byteValue(), rightNumber.byteValue());
|
||||
}
|
||||
else {
|
||||
// Unknown Number subtypes -> best guess is double multiplication
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
|
|
@ -522,7 +522,8 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
|||
public boolean equals(Object other) {
|
||||
// Effectively checking object equality as well as toString equality.
|
||||
// On WebSphere MQ, Destination objects do not implement equals...
|
||||
return (this == other || destinationEquals((DestinationCacheKey) other));
|
||||
return (this == other || (other instanceof DestinationCacheKey &&
|
||||
destinationEquals((DestinationCacheKey) other)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -577,6 +578,9 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ConsumerCacheKey)) {
|
||||
return false;
|
||||
}
|
||||
ConsumerCacheKey otherKey = (ConsumerCacheKey) other;
|
||||
return (destinationEquals(otherKey) &&
|
||||
ObjectUtils.nullSafeEquals(this.selector, otherKey.selector) &&
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
|
|
@ -38,6 +38,7 @@ import org.springframework.web.util.pattern.PathPattern;
|
|||
|
||||
/**
|
||||
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
|
||||
*
|
||||
* <p>If no {@link RouterFunction} is provided at
|
||||
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping
|
||||
* will detect all router functions in the application context, and consult them in
|
||||
|
|
@ -56,8 +57,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
|
|||
|
||||
/**
|
||||
* Create an empty {@code RouterFunctionMapping}.
|
||||
* <p>If this constructor is used, this mapping will detect all {@link RouterFunction} instances
|
||||
* available in the application context.
|
||||
* <p>If this constructor is used, this mapping will detect all
|
||||
* {@link RouterFunction} instances available in the application context.
|
||||
*/
|
||||
public RouterFunctionMapping() {
|
||||
}
|
||||
|
|
@ -154,20 +155,18 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setAttributes(Map<String, Object> attributes, ServerRequest serverRequest,
|
||||
HandlerFunction<?> handlerFunction) {
|
||||
private void setAttributes(
|
||||
Map<String, Object> attributes, ServerRequest serverRequest, HandlerFunction<?> handlerFunction) {
|
||||
|
||||
attributes.put(RouterFunctions.REQUEST_ATTRIBUTE, serverRequest);
|
||||
attributes.put(BEST_MATCHING_HANDLER_ATTRIBUTE, handlerFunction);
|
||||
|
||||
PathPattern matchingPattern =
|
||||
(PathPattern) attributes.get(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE);
|
||||
PathPattern matchingPattern = (PathPattern) attributes.get(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE);
|
||||
if (matchingPattern != null) {
|
||||
attributes.put(BEST_MATCHING_PATTERN_ATTRIBUTE, matchingPattern);
|
||||
}
|
||||
Map<String, String> uriVariables =
|
||||
(Map<String, String>) attributes
|
||||
.get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
(Map<String, String>) attributes.get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
if (uriVariables != null) {
|
||||
attributes.put(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue