Polishing
This commit is contained in:
@@ -49,7 +49,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
|
||||
* @see ScopedProxyMode#NO
|
||||
*/
|
||||
public AnnotationScopeMetadataResolver() {
|
||||
this(ScopedProxyMode.NO);
|
||||
this.defaultProxyMode = ScopedProxyMode.NO;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,6 +62,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
|
||||
this.defaultProxyMode = defaultProxyMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the type of annotation that is checked for by this
|
||||
* {@code AnnotationScopeMetadataResolver}.
|
||||
@@ -72,6 +73,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
|
||||
this.scopeAnnotationType = scopeAnnotationType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
|
||||
ScopeMetadata metadata = new ScopeMetadata();
|
||||
@@ -81,7 +83,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
|
||||
if (attributes != null) {
|
||||
metadata.setScopeName(attributes.getAliasedString("value", this.scopeAnnotationType, definition.getSource()));
|
||||
ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");
|
||||
if ((proxyMode == null) || (proxyMode == ScopedProxyMode.DEFAULT)) {
|
||||
if (proxyMode == null || proxyMode == ScopedProxyMode.DEFAULT) {
|
||||
proxyMode = this.defaultProxyMode;
|
||||
}
|
||||
metadata.setScopedProxyMode(proxyMode);
|
||||
|
||||
@@ -478,7 +478,9 @@ public abstract class AbstractMethodMessageHandler<T>
|
||||
processHandlerMethodException(handlerMethod, ex, message);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.error("Error while processing message " + message, ex);
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("Error while processing message " + message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,9 +548,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
||||
}
|
||||
|
||||
protected void handleNoMatch(Set<T> ts, String lookupDestination, Message<?> message) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No matching methods.");
|
||||
}
|
||||
logger.debug("No matching methods.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -26,7 +26,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
@@ -61,7 +60,7 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return getArgumentResolver(parameter) != null;
|
||||
return (getArgumentResolver(parameter) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +72,9 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
|
||||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
|
||||
|
||||
HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
|
||||
Assert.notNull(resolver, "Unknown parameter type [" + parameter.getParameterType().getName() + "]");
|
||||
if (resolver == null) {
|
||||
throw new IllegalArgumentException("Unknown parameter type [" + parameter.getParameterType().getName() + "]");
|
||||
}
|
||||
return resolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -44,6 +43,7 @@ import org.springframework.http.InvalidMediaTypeException;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.Errors;
|
||||
@@ -134,8 +134,8 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
||||
* @throws IOException if the reading from the request fails
|
||||
* @throws HttpMediaTypeNotSupportedException if no suitable message converter is found
|
||||
*/
|
||||
protected <T> Object readWithMessageConverters(NativeWebRequest webRequest,
|
||||
MethodParameter methodParam, Type paramType) throws IOException, HttpMediaTypeNotSupportedException {
|
||||
protected <T> Object readWithMessageConverters(NativeWebRequest webRequest, MethodParameter methodParam,
|
||||
Type paramType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException {
|
||||
|
||||
HttpInputMessage inputMessage = createInputMessage(webRequest);
|
||||
return readWithMessageConverters(inputMessage, methodParam, paramType);
|
||||
@@ -154,8 +154,8 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
||||
* @throws HttpMediaTypeNotSupportedException if no suitable message converter is found
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage,
|
||||
MethodParameter param, Type targetType) throws IOException, HttpMediaTypeNotSupportedException {
|
||||
protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, MethodParameter param,
|
||||
Type targetType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException {
|
||||
|
||||
MediaType contentType;
|
||||
try {
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -33,6 +32,7 @@ import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.http.server.ServletServerHttpResponse;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -93,7 +93,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||
* {@link #writeWithMessageConverters(Object, MethodParameter, ServletServerHttpRequest, ServletServerHttpResponse)}
|
||||
*/
|
||||
protected <T> void writeWithMessageConverters(T returnValue, MethodParameter returnType, NativeWebRequest webRequest)
|
||||
throws IOException, HttpMediaTypeNotAcceptableException {
|
||||
throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
|
||||
|
||||
ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
|
||||
ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);
|
||||
@@ -113,7 +113,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> void writeWithMessageConverters(T returnValue, MethodParameter returnType,
|
||||
ServletServerHttpRequest inputMessage, ServletServerHttpResponse outputMessage)
|
||||
throws IOException, HttpMediaTypeNotAcceptableException {
|
||||
throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
|
||||
|
||||
Class<?> returnValueClass = getReturnValueType(returnValue, returnType);
|
||||
Type returnValueType = getGenericType(returnType);
|
||||
|
||||
@@ -18,17 +18,15 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
@@ -141,7 +139,7 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||
|
||||
@Override
|
||||
protected <T> Object readWithMessageConverters(NativeWebRequest webRequest, MethodParameter methodParam,
|
||||
Type paramType) throws IOException, HttpMediaTypeNotSupportedException {
|
||||
Type paramType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException {
|
||||
|
||||
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
|
||||
ServletServerHttpRequest inputMessage = new ServletServerHttpRequest(servletRequest);
|
||||
@@ -160,7 +158,7 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||
@Override
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType,
|
||||
ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
|
||||
throws IOException, HttpMediaTypeNotAcceptableException {
|
||||
throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
|
||||
|
||||
mavContainer.setRequestHandled(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user