Polishing

This commit is contained in:
Juergen Hoeller
2018-07-18 14:03:54 +02:00
parent 55563c16b5
commit c0040a5508
52 changed files with 331 additions and 253 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
@@ -40,13 +40,13 @@ public class CachingConfigurerSupport implements CachingConfigurer {
@Override
@Nullable
public KeyGenerator keyGenerator() {
public CacheResolver cacheResolver() {
return null;
}
@Override
@Nullable
public CacheResolver cacheResolver() {
public KeyGenerator keyGenerator() {
return null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -112,21 +112,21 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
*/
private static void parseCacheResolution(Element element, BeanDefinition def, boolean setBoth) {
String name = element.getAttribute("cache-resolver");
if (StringUtils.hasText(name)) {
boolean hasText = StringUtils.hasText(name);
if (hasText) {
def.getPropertyValues().add("cacheResolver", new RuntimeBeanReference(name.trim()));
}
if (!StringUtils.hasText(name) || setBoth) {
if (!hasText || setBoth) {
def.getPropertyValues().add("cacheManager",
new RuntimeBeanReference(CacheNamespaceHandler.extractCacheManager(element)));
}
}
private static BeanDefinition parseErrorHandler(Element element, BeanDefinition def) {
private static void parseErrorHandler(Element element, BeanDefinition def) {
String name = element.getAttribute("error-handler");
if (StringUtils.hasText(name)) {
def.getPropertyValues().add("errorHandler", new RuntimeBeanReference(name.trim()));
}
return def;
}
@@ -175,12 +175,12 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
}
/**
* Registers a
* Registers a cache aspect.
* <pre class="code">
* <bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
* <property name="cacheManager" ref="cacheManager"/>
* <property name="keyGenerator" ref="keyGenerator"/>
* </bean>
* &lt;bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf"&gt;
* &lt;property name="cacheManager" ref="cacheManager"/&gt;
* &lt;property name="keyGenerator" ref="keyGenerator"/&gt;
* &lt;/bean&gt;
* </pre>
*/
private static void registerCacheAspect(Element element, ParserContext parserContext) {

View File

@@ -192,8 +192,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
}
catch (NoUniqueBeanDefinitionException ex) {
throw new IllegalStateException("No CacheResolver specified, and no unique bean of type " +
"CacheManager found. Mark one as primary (or give it the name 'cacheManager') or " +
"declare a specific CacheManager to use, that serves as the default one.");
"CacheManager found. Mark one as primary or declare a specific CacheManager to use.");
}
catch (NoSuchBeanDefinitionException ex) {
throw new IllegalStateException("No CacheResolver specified, and no bean of type CacheManager found. " +
@@ -650,6 +649,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
}
/**
* A {@link CacheOperationInvocationContext} context for a {@link CacheOperation}.
*/
protected class CacheOperationContext implements CacheOperationInvocationContext<CacheOperation> {
private final CacheOperationMetadata metadata;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -100,7 +100,9 @@ public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements B
/**
* Specify the default task executor to use for asynchronous methods.
* @deprecated as of 5.0.8, in favor of {@link #AsyncAnnotationAdvisor(Executor, AsyncUncaughtExceptionHandler)}
*/
@Deprecated
public void setTaskExecutor(Executor executor) {
this.advice = buildAdvice(executor, this.exceptionHandler);
}

View File

@@ -321,9 +321,8 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
@Override
public String[] resolveMessageCodes(String errorCode, @Nullable String field) {
Class<?> fieldType = (getTarget() != null ? getFieldType(field) : null);
return getMessageCodesResolver().resolveMessageCodes(
errorCode, getObjectName(), fixedField(field), fieldType);
errorCode, getObjectName(), fixedField(field), getFieldType(field));
}
@Override
@@ -332,7 +331,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
}
@Override
public void recordFieldValue(String field, Class<?> type, Object value) {
public void recordFieldValue(String field, Class<?> type, @Nullable Object value) {
this.fieldTypes.put(field, type);
this.fieldValues.put(field, value);
}

View File

@@ -275,7 +275,7 @@ public class BindException extends Exception implements BindingResult {
}
@Override
public void recordFieldValue(String field, Class<?> type, Object value) {
public void recordFieldValue(String field, Class<?> type, @Nullable Object value) {
this.bindingResult.recordFieldValue(field, type, value);
}

View File

@@ -143,7 +143,7 @@ public interface BindingResult extends Errors {
* @param value the original value
* @since 5.0.4
*/
default void recordFieldValue(String field, Class<?> type, Object value) {
default void recordFieldValue(String field, Class<?> type, @Nullable Object value) {
}
/**

View File

@@ -853,7 +853,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @see #getBindingResult()
*/
public void validate() {
for (Validator validator : this.validators) {
for (Validator validator : getValidators()) {
validator.validate(getTarget(), getBindingResult());
}
}