Use enum for MessageCodesResolver format

Fixes gh-670
pull/755/head
Dave Syer 11 years ago
parent 1cbef02236
commit 537b0c3ff3

@ -31,6 +31,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@ -137,7 +138,7 @@ public class WebMvcAutoConfiguration {
private Integer cachePeriod;
@Value("${spring.mvc.message-codes-resolver.format:}")
private String messageCodesResolverFormat = "";
private DefaultMessageCodesResolver.Format messageCodesResolverFormat = null;
@Value("${spring.mvc.locale:}")
private String locale = "";
@ -204,10 +205,10 @@ public class WebMvcAutoConfiguration {
@ConditionalOnExpression("'${spring.mvc.message-codes-resolver.format:}' != ''")
public MessageCodesResolver messageCodesResolver() {
DefaultMessageCodesResolver resolver = new DefaultMessageCodesResolver();
resolver.setMessageCodeFormatter(DefaultMessageCodesResolver.Format.valueOf(messageCodesResolverFormat));
resolver.setMessageCodeFormatter(this.messageCodesResolverFormat);
return resolver;
}
@Override
public void addFormatters(FormatterRegistry registry) {
for (Converter<?, ?> converter : getBeansOfType(Converter.class)) {

Loading…
Cancel
Save