提交 5a873341 编写于 作者: K Keith Donald

made conversion service pluggable

上级 1d22b9fb
......@@ -18,12 +18,14 @@ package org.springframework.expression.spel.support;
import org.springframework.core.convert.ConversionException;
import org.springframework.core.convert.ConversionExecutorNotFoundException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.service.DefaultConversionService;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.spel.SpelException;
import org.springframework.expression.spel.SpelMessages;
import org.springframework.util.Assert;
/**
* @author Juergen Hoeller
......@@ -32,12 +34,17 @@ import org.springframework.expression.spel.SpelMessages;
*/
public class StandardTypeConverter implements TypeConverter {
DefaultConversionService conversionService;
private ConversionService conversionService;
StandardTypeConverter() {
public StandardTypeConverter() {
conversionService = new DefaultConversionService();
}
public StandardTypeConverter(ConversionService conversionService) {
Assert.notNull(conversionService, "The conversionService must not be null");
this.conversionService = conversionService;
}
@SuppressWarnings("unchecked")
public <T> T convertValue(Object value, Class<T> targetType) throws EvaluationException {
return (T) convertValue(value,TypeDescriptor.valueOf(targetType));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册