default config for web binding initializer and formatting/conversion system w/ mvc namespace
This commit is contained in:
@@ -24,9 +24,12 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.core.GenericCollectionTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.style.StylerUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import com.sun.xml.internal.rngom.ast.builder.Annotations;
|
||||
|
||||
/**
|
||||
* Context about a type to convert to.
|
||||
*
|
||||
@@ -277,7 +280,7 @@ public class TypeDescriptor {
|
||||
}
|
||||
return this.cachedFieldAnnotations;
|
||||
} else if (this.methodParameter != null) {
|
||||
return this.methodParameter.getMethod().getAnnotations();
|
||||
return this.methodParameter.getParameterAnnotations();
|
||||
} else {
|
||||
return new Annotation[0];
|
||||
}
|
||||
@@ -411,7 +414,15 @@ public class TypeDescriptor {
|
||||
if (this == TypeDescriptor.NULL) {
|
||||
return "[TypeDescriptor.NULL]";
|
||||
} else {
|
||||
return "[TypeDescriptor type=" + getType().getName() + "]";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[TypeDescriptor ");
|
||||
Annotation[] anns = getAnnotations();
|
||||
for (Annotation ann : anns) {
|
||||
builder.append("@" + ann.annotationType().getName()).append(' ');
|
||||
}
|
||||
builder.append(getType().getName());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -45,6 +47,8 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class GenericConversionService implements ConversionService, ConverterRegistry {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(GenericConversionService.class);
|
||||
|
||||
private static final GenericConverter NO_OP_CONVERTER = new GenericConverter() {
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
return source;
|
||||
@@ -326,6 +330,9 @@ public class GenericConversionService implements ConversionService, ConverterReg
|
||||
}
|
||||
|
||||
private GenericConverter findConverterForClassPair(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Looking for Converter to convert from " + sourceType + " to " + targetType);
|
||||
}
|
||||
Class<?> sourceObjectType = sourceType.getObjectType();
|
||||
if (sourceObjectType.isInterface()) {
|
||||
LinkedList<Class<?>> classQueue = new LinkedList<Class<?>>();
|
||||
@@ -507,7 +514,14 @@ public class GenericConversionService implements ConversionService, ConverterReg
|
||||
public GenericConverter matchConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
for (MatchableConverter matchable : this.matchableConverters) {
|
||||
if (matchable.matches(sourceType, targetType)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Converter Lookup [MATCHED] " + matchable);
|
||||
}
|
||||
return matchable.getConverter();
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Converter Lookup [DID NOT MATCH] " + matchable);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user