Browse Source

polishing

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1983 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 17 years ago
parent
commit
732f682877
  1. 6
      org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java
  2. 9
      org.springframework.context/src/main/java/org/springframework/ui/format/support/FormattingConversionServiceAdapter.java
  3. 6
      org.springframework.context/src/main/java/org/springframework/ui/format/support/GenericFormatterRegistry.java

6
org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java

@ -24,8 +24,8 @@ import org.springframework.beans.factory.config.BeanDefinition; @@ -24,8 +24,8 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.util.Assert;
/**
* A {@link ScopeMetadataResolver} implementation that (by default) checks for
* the presence of the {@link Scope} annotation on the bean class.
* A {@link ScopeMetadataResolver} implementation that by default checks for
* 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
* {@link #setScopeAnnotationType(Class)} property.
@ -70,7 +70,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { @@ -70,7 +70,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
Assert.notNull(scopeAnnotationType, "'scopeAnnotationType' must not be null");
this.scopeAnnotationType = scopeAnnotationType;
}
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
ScopeMetadata metadata = new ScopeMetadata();

9
org.springframework.context/src/main/java/org/springframework/ui/format/support/FormattingConversionServiceAdapter.java

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

6
org.springframework.context/src/main/java/org/springframework/ui/format/support/GenericFormatterRegistry.java

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

Loading…
Cancel
Save