polishing

This commit is contained in:
Juergen Hoeller 2009-09-24 10:21:40 +00:00
parent 501a1ea9af
commit 38110d35d2
3 changed files with 14 additions and 7 deletions

View File

@ -24,8 +24,8 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* A {@link ScopeMetadataResolver} implementation that (by default) checks for * A {@link ScopeMetadataResolver} implementation that by default checks for
* the presence of the {@link Scope} annotation on the bean class. * the presence of Spring's {@link Scope} annotation on the bean class.
* *
* <p>The exact type of annotation that is checked for is configurable via the * <p>The exact type of annotation that is checked for is configurable via the
* {@link #setScopeAnnotationType(Class)} property. * {@link #setScopeAnnotationType(Class)} property.

View File

@ -40,6 +40,7 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
private final FormatterRegistry formatterRegistry; private final FormatterRegistry formatterRegistry;
/** /**
* Create a new FormattingConversionServiceAdapter for the given FormatterRegistry. * Create a new FormattingConversionServiceAdapter for the given FormatterRegistry.
* @param formatterRegistry the FormatterRegistry to wrap * @param formatterRegistry the FormatterRegistry to wrap
@ -49,11 +50,13 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
this.formatterRegistry = formatterRegistry; this.formatterRegistry = formatterRegistry;
if (formatterRegistry instanceof GenericFormatterRegistry) { if (formatterRegistry instanceof GenericFormatterRegistry) {
setParent(((GenericFormatterRegistry) formatterRegistry).getConversionService()); setParent(((GenericFormatterRegistry) formatterRegistry).getConversionService());
} else { }
else {
setParent(new DefaultConversionService()); setParent(new DefaultConversionService());
} }
} }
@Override @Override
protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) { protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (String.class.equals(sourceType.getType())) { if (String.class.equals(sourceType.getType())) {
@ -65,6 +68,7 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
return super.getConverter(sourceType, targetType); return super.getConverter(sourceType, targetType);
} }
/** /**
* Adapter that exposes the Converter interface on top of a given Formatter. * Adapter that exposes the Converter interface on top of a given Formatter.
*/ */
@ -79,7 +83,8 @@ public class FormattingConversionServiceAdapter extends GenericConversionService
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
try { try {
return this.formatter.parse((String) source, LocaleContextHolder.getLocale()); return this.formatter.parse((String) source, LocaleContextHolder.getLocale());
} catch (ParseException ex) { }
catch (ParseException ex) {
throw new IllegalArgumentException("Could not convert formatted value '" + source + "'", ex); throw new IllegalArgumentException("Could not convert formatted value '" + source + "'", ex);
} }
} }

View File

@ -245,10 +245,12 @@ public class GenericFormatterRegistry implements FormatterRegistry, ApplicationC
if (arg instanceof Class) { if (arg instanceof Class) {
return (Class) arg; return (Class) arg;
} }
} else if (Formatter.class.isAssignableFrom((Class) rawType)) { }
else if (Formatter.class.isAssignableFrom((Class) rawType)) {
return getFormattedObjectType((Class) rawType); return getFormattedObjectType((Class) rawType);
} }
} else if (Formatter.class.isAssignableFrom((Class) ifc)) { }
else if (Formatter.class.isAssignableFrom((Class) ifc)) {
return getFormattedObjectType((Class) ifc); return getFormattedObjectType((Class) ifc);
} }
} }