org.springframework.context.annotation.Description#org.springframework.context.support.ResourceBundleMessageSource源码实例Demo

下面列出了org.springframework.context.annotation.Description#org.springframework.context.support.ResourceBundleMessageSource 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-analysis-note   文件: JstlUtils.java
/**
 * Checks JSTL's "javax.servlet.jsp.jstl.fmt.localizationContext"
 * context-param and creates a corresponding child message source,
 * with the provided Spring-defined MessageSource as parent.
 * @param servletContext the ServletContext we're running in
 * (to check JSTL-related context-params in {@code web.xml})
 * @param messageSource the MessageSource to expose, typically
 * the ApplicationContext of the current DispatcherServlet
 * @return the MessageSource to expose to JSTL; first checking the
 * JSTL-defined bundle, then the Spring-defined MessageSource
 * @see org.springframework.context.ApplicationContext
 */
public static MessageSource getJstlAwareMessageSource(
		@Nullable ServletContext servletContext, MessageSource messageSource) {

	if (servletContext != null) {
		String jstlInitParam = servletContext.getInitParameter(Config.FMT_LOCALIZATION_CONTEXT);
		if (jstlInitParam != null) {
			// Create a ResourceBundleMessageSource for the specified resource bundle
			// basename in the JSTL context-param in web.xml, wiring it with the given
			// Spring-defined MessageSource as parent.
			ResourceBundleMessageSource jstlBundleWrapper = new ResourceBundleMessageSource();
			jstlBundleWrapper.setBasename(jstlInitParam);
			jstlBundleWrapper.setParentMessageSource(messageSource);
			return jstlBundleWrapper;
		}
	}
	return messageSource;
}
 
源代码2 项目: java-technology-stack   文件: JstlUtils.java
/**
 * Checks JSTL's "javax.servlet.jsp.jstl.fmt.localizationContext"
 * context-param and creates a corresponding child message source,
 * with the provided Spring-defined MessageSource as parent.
 * @param servletContext the ServletContext we're running in
 * (to check JSTL-related context-params in {@code web.xml})
 * @param messageSource the MessageSource to expose, typically
 * the ApplicationContext of the current DispatcherServlet
 * @return the MessageSource to expose to JSTL; first checking the
 * JSTL-defined bundle, then the Spring-defined MessageSource
 * @see org.springframework.context.ApplicationContext
 */
public static MessageSource getJstlAwareMessageSource(
		@Nullable ServletContext servletContext, MessageSource messageSource) {

	if (servletContext != null) {
		String jstlInitParam = servletContext.getInitParameter(Config.FMT_LOCALIZATION_CONTEXT);
		if (jstlInitParam != null) {
			// Create a ResourceBundleMessageSource for the specified resource bundle
			// basename in the JSTL context-param in web.xml, wiring it with the given
			// Spring-defined MessageSource as parent.
			ResourceBundleMessageSource jstlBundleWrapper = new ResourceBundleMessageSource();
			jstlBundleWrapper.setBasename(jstlInitParam);
			jstlBundleWrapper.setParentMessageSource(messageSource);
			return jstlBundleWrapper;
		}
	}
	return messageSource;
}
 
@Before
public void setUp() {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("n2o_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    properties.put("n2o.engine.mapper", "spel");
    environment.setSystemProperties(new SimplePropertyResolver(properties));
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
 
源代码4 项目: n2o-framework   文件: CopyValuesControllerTest.java
@Before
public void setUp() {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("n2o_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    properties.put("n2o.engine.mapper", "spel");
    environment.setSystemProperties(new SimplePropertyResolver(properties));
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
 
源代码5 项目: n2o-framework   文件: DataControllerTestBase.java
@Before
public void setUp() {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("n2o_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    properties.put("n2o.engine.mapper", "spel");
    SimplePropertyResolver propertyResolver = new SimplePropertyResolver(properties);
    setUpStaticProperties(propertyResolver);
    environment.setSystemProperties(propertyResolver);
    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
 
源代码6 项目: n2o-framework   文件: N2oEnvironment.java
public N2oEnvironment() {
    this.metadataRegister = new N2oMetadataRegister();
    this.routeRegister = new N2oRouteRegister();
    this.sourceTypeRegister = new N2oSourceTypeRegister();

    this.messageSource = new MessageSourceAccessor(new ResourceBundleMessageSource());
    this.systemProperties = new N2oWebAppEnvironment();
    this.domainProcessor = new DomainProcessor(new ObjectMapper());
    this.contextProcessor = new ContextProcessor(new TestContextEngine());

    this.namespaceReaderFactory = new ReaderFactoryByMap();
    this.namespacePersisterFactory = new PersisterFactoryByMap();
    this.dynamicMetadataProviderFactory = new N2oDynamicMetadataProviderFactory();
    this.metadataScannerFactory = new N2oMetadataScannerFactory();
    this.sourceLoaderFactory = new N2oSourceLoaderFactory();
    this.sourceValidatorFactory = new N2oSourceValidatorFactory();
    this.sourceCompilerFactory = new N2oSourceCompilerFactory();
    this.compileTransformerFactory = new N2oCompileTransformerFactory();
    this.sourceTransformerFactory = new N2oSourceTransformerFactory();
    this.extensionAttributeMapperFactory = new N2oExtensionAttributeMapperFactory();
    this.sourceMergerFactory = new N2oSourceMergerFactory();
    this.metadataBinderFactory = new N2oMetadataBinderFactory();
    this.pipelineOperationFactory = new N2oPipelineOperationFactory();
    this.buttonGeneratorFactory = new N2oButtonGeneratorFactory();
}
 
@PostConstruct
public void init() {
    logger.info("init MessageResourceExtension...");
    if (!StringUtils.isEmpty(baseFolder)) {
        try {
            this.setBasenames(getAllBaseNames(baseFolder));
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
    }
    //设置父MessageSource
    ResourceBundleMessageSource parent = new ResourceBundleMessageSource();
    //是否是多个目录
    if (basename.indexOf(",") > 0) {
        parent.setBasenames(basename.split(","));
    } else {
        parent.setBasename(basename);
    }
    //设置文件编码
    parent.setDefaultEncoding("UTF-8");
    this.setParentMessageSource(parent);
}
 
源代码8 项目: lams   文件: JstlUtils.java
/**
 * Checks JSTL's "javax.servlet.jsp.jstl.fmt.localizationContext"
 * context-param and creates a corresponding child message source,
 * with the provided Spring-defined MessageSource as parent.
 * @param servletContext the ServletContext we're running in
 * (to check JSTL-related context-params in {@code web.xml})
 * @param messageSource the MessageSource to expose, typically
 * the ApplicationContext of the current DispatcherServlet
 * @return the MessageSource to expose to JSTL; first checking the
 * JSTL-defined bundle, then the Spring-defined MessageSource
 * @see org.springframework.context.ApplicationContext
 */
public static MessageSource getJstlAwareMessageSource(
		ServletContext servletContext, MessageSource messageSource) {

	if (servletContext != null) {
		String jstlInitParam = servletContext.getInitParameter(Config.FMT_LOCALIZATION_CONTEXT);
		if (jstlInitParam != null) {
			// Create a ResourceBundleMessageSource for the specified resource bundle
			// basename in the JSTL context-param in web.xml, wiring it with the given
			// Spring-defined MessageSource as parent.
			ResourceBundleMessageSource jstlBundleWrapper = new ResourceBundleMessageSource();
			jstlBundleWrapper.setBasename(jstlInitParam);
			jstlBundleWrapper.setParentMessageSource(messageSource);
			return jstlBundleWrapper;
		}
	}
	return messageSource;
}
 
源代码9 项目: lams   文件: LoadedMessageSourceService.java
@Override
   public MessageSource getMessageService(String messageFilename) {
if (messageFilename != null) {
    MessageSource ms = messageServices.get(messageFilename);
    if (ms == null) {
	ResourceBundleMessageSource rbms = (ResourceBundleMessageSource) beanFactory
		.getBean(LOADED_MESSAGE_SOURCE_BEAN);
	rbms.setBasename(messageFilename);
	messageServices.put(messageFilename, rbms);
	ms = rbms;
    }
    return ms;
} else {
    return null;
}
   }
 
源代码10 项目: tephra   文件: MessageImpl.java
@Override
public void onContextRefreshed() {
    Set<String> messages = new HashSet<>();
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    for (String beanName : BeanFactory.getBeanNames()) {
        Package beanPackage = BeanFactory.getBeanClass(beanName).getPackage();
        if (beanPackage == null) {
            logger.warn(null, "无法获得Bean[{}]包。", beanName);

            continue;
        }

        String packageName = beanPackage.getName();
        if (resolver.getResource(packageName.replace('.', File.separatorChar) + "/message.properties").exists())
            messages.add(packageName);
    }

    String[] names = new String[messages.size()];
    int i = 0;
    for (String name : messages)
        names[i++] = name + ".message";
    messageSource = new ResourceBundleMessageSource();
    messageSource.setDefaultEncoding(context.getCharset(null));
    messageSource.setBasenames(names);
}
 
源代码11 项目: spring4-understanding   文件: JstlUtils.java
/**
 * Checks JSTL's "javax.servlet.jsp.jstl.fmt.localizationContext"
 * context-param and creates a corresponding child message source,
 * with the provided Spring-defined MessageSource as parent.
 * @param servletContext the ServletContext we're running in
 * (to check JSTL-related context-params in {@code web.xml})
 * @param messageSource the MessageSource to expose, typically
 * the ApplicationContext of the current DispatcherServlet
 * @return the MessageSource to expose to JSTL; first checking the
 * JSTL-defined bundle, then the Spring-defined MessageSource
 * @see org.springframework.context.ApplicationContext
 */
public static MessageSource getJstlAwareMessageSource(
		ServletContext servletContext, MessageSource messageSource) {

	if (servletContext != null) {
		String jstlInitParam = servletContext.getInitParameter(Config.FMT_LOCALIZATION_CONTEXT);
		if (jstlInitParam != null) {
			// Create a ResourceBundleMessageSource for the specified resource bundle
			// basename in the JSTL context-param in web.xml, wiring it with the given
			// Spring-defined MessageSource as parent.
			ResourceBundleMessageSource jstlBundleWrapper = new ResourceBundleMessageSource();
			jstlBundleWrapper.setBasename(jstlInitParam);
			jstlBundleWrapper.setParentMessageSource(messageSource);
			return jstlBundleWrapper;
		}
	}
	return messageSource;
}
 
源代码12 项目: entando-core   文件: AbstractControllerTest.java
protected ExceptionHandlerExceptionResolver createExceptionResolver() {

        final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        messageSource.setBasename("rest/messages");
        messageSource.setUseCodeAsDefaultMessage(true);

        ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver() {

            @Override
            protected ServletInvocableHandlerMethod getExceptionHandlerMethod(HandlerMethod handlerMethod, Exception exception) {
                Method method = new ExceptionHandlerMethodResolver(RestExceptionHandler.class).resolveMethod(exception);
                RestExceptionHandler validationHandler = new RestExceptionHandler();
                validationHandler.setMessageSource(messageSource);
                return new ServletInvocableHandlerMethod(validationHandler, method);
            }
        };

        exceptionResolver.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
        exceptionResolver.afterPropertiesSet();
        return exceptionResolver;
    }
 
源代码13 项目: airsonic-advanced   文件: CustomThemeSource.java
@Override
protected MessageSource createMessageSource(String basename) {
    ResourceBundleMessageSource messageSource = (ResourceBundleMessageSource) super.createMessageSource(basename);

    // Create parent theme recursively.
    for (Theme theme : settingsService.getAvailableThemes()) {
        if ((basenamePrefix + theme.getId()).equals(basename) && theme.getParent() != null) {
            String parent = basenamePrefix + theme.getParent();
            messageSource.setParentMessageSource(createMessageSource(parent));
            break;
        }
    }
    return messageSource;
}
 
/**
 * Create a MessageSource for the given basename,
 * to be used as MessageSource for the corresponding theme.
 * <p>Default implementation creates a ResourceBundleMessageSource.
 * for the given basename. A subclass could create a specifically
 * configured ReloadableResourceBundleMessageSource, for example.
 * @param basename the basename to create a MessageSource for
 * @return the MessageSource
 * @see org.springframework.context.support.ResourceBundleMessageSource
 * @see org.springframework.context.support.ReloadableResourceBundleMessageSource
 */
protected MessageSource createMessageSource(String basename) {
	ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
	messageSource.setBasename(basename);
	if (this.defaultEncoding != null) {
		messageSource.setDefaultEncoding(this.defaultEncoding);
	}
	if (this.fallbackToSystemLocale != null) {
		messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
	}
	if (this.beanClassLoader != null) {
		messageSource.setBeanClassLoader(this.beanClassLoader);
	}
	return messageSource;
}
 
源代码15 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
/**
 * 国际化
 *
 * @return
 */
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
源代码16 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
源代码17 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
/**
 * 此处有很多坑,不一一叙述,如无必要,不要更改
 *
 * @return
 */
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
源代码18 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
/**
 * 国际化
 *
 * @return
 */
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
public static void main(String[] args) throws InterruptedException {
	ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
	messageSource.setBasename("messages/messages");
	System.err.println(messageSource.getMessage("welcome", new Object[0], Locale.UK));
	ClassPathResource resource = new ClassPathResource("META-INF/resources/webjars/jquery/2.2.4/jquery.js");
	System.err.println(resource.exists());
	Thread.currentThread().join(); // To be able to measure memory consumption
}
 
源代码20 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
/**
 * 国际化
 *
 * @return
 */
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
源代码21 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
源代码22 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
/**
 * 此处有很多坑,不一一叙述,如无必要,不要更改
 *
 * @return
 */
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
源代码23 项目: ZTuoExchange_framework   文件: ApplicationConfig.java
/**
 * 国际化
 *
 * @return
 */
@Bean(name = "messageSource")
public ResourceBundleMessageSource getMessageSource() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setDefaultEncoding("UTF-8");
    resourceBundleMessageSource.setBasenames("i18n/messages", "i18n/ValidationMessages");
    resourceBundleMessageSource.setCacheSeconds(3600);
    return resourceBundleMessageSource;
}
 
/**
 * Create a MessageSource for the given basename,
 * to be used as MessageSource for the corresponding theme.
 * <p>Default implementation creates a ResourceBundleMessageSource.
 * for the given basename. A subclass could create a specifically
 * configured ReloadableResourceBundleMessageSource, for example.
 * @param basename the basename to create a MessageSource for
 * @return the MessageSource
 * @see org.springframework.context.support.ResourceBundleMessageSource
 * @see org.springframework.context.support.ReloadableResourceBundleMessageSource
 */
protected MessageSource createMessageSource(String basename) {
	ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
	messageSource.setBasename(basename);
	if (this.defaultEncoding != null) {
		messageSource.setDefaultEncoding(this.defaultEncoding);
	}
	if (this.fallbackToSystemLocale != null) {
		messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
	}
	if (this.beanClassLoader != null) {
		messageSource.setBeanClassLoader(this.beanClassLoader);
	}
	return messageSource;
}
 
源代码25 项目: n2o-framework   文件: N2oMessagesConfiguration.java
@Bean("n2oMessageSource")
@ConditionalOnMissingBean(name = "n2oMessageSource")
public MessageSource n2oMessageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setDefaultEncoding(encoding.name());
    messageSource.setCacheSeconds(cacheSeconds);
    messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
            StringUtils.trimAllWhitespace(basename)));
    messageSource.addBasenames("n2o_messages", "n2o_content");
    return messageSource;
}
 
源代码26 项目: n2o-framework   文件: N2oTestBase.java
public void setUp() throws Exception {
    N2oEnvironment environment = new N2oEnvironment();
    environment.setNamespacePersisterFactory(new PersisterFactoryByMap());
    environment.setNamespaceReaderFactory(new ReaderFactoryByMap());
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("n2o_messages", "messages");
    messageSource.setDefaultEncoding("UTF-8");
    environment.setMessageSource(new MessageSourceAccessor(messageSource));
    OverrideProperties properties = PropertiesReader.getPropertiesFromClasspath("META-INF/n2o.properties");
    environment.setSystemProperties(new SimplePropertyResolver(properties));

    builder = new N2oApplicationBuilder(environment);
    configure(builder);
    CompileInfo.setSourceTypes(builder.getEnvironment().getSourceTypeRegister());
}
 
源代码27 项目: SA47   文件: WebAppConfig.java
@Bean
public ResourceBundleMessageSource messageSource() {
	ResourceBundleMessageSource source = new ResourceBundleMessageSource();
	source.setBasename(env.getRequiredProperty("message.source.basename"));
	source.setUseCodeAsDefaultMessage(true);
	source.setDefaultEncoding("UTF-8");
	// # -1 : never reload, 0 always reload
	source.setCacheSeconds(0);
	return source;
}
 
源代码28 项目: SA47   文件: WebAppConfig.java
@Bean
public ResourceBundleMessageSource messageSource() {
	ResourceBundleMessageSource source = new ResourceBundleMessageSource();
	source.setBasename(env.getRequiredProperty("message.source.basename"));
	source.setUseCodeAsDefaultMessage(true);
	source.setDefaultEncoding("UTF-8");
	// # -1 : never reload, 0 always reload
	source.setCacheSeconds(0);
	return source;
}
 
/**
 * Set the source of i18n messages under "resources/i18n/messages_[locale].properties"
 *
 * @return instance of {@link ResourceBundleMessageSource}
 */
@Bean
public ResourceBundleMessageSource messageSource() {
  ResourceBundleMessageSource source = new ResourceBundleMessageSource();
  source.setBasenames("i18n/messages");
  source.setUseCodeAsDefaultMessage(true);
  return source;
}
 
/**
 * Set the source of i18n messages under "resources/i18n/messages_[locale].properties"
 *
 * @return instance of {@link ResourceBundleMessageSource}
 */
@Bean
public ResourceBundleMessageSource messageSource() {
  ResourceBundleMessageSource source = new ResourceBundleMessageSource();
  source.setBasenames("i18n/messages");
  source.setUseCodeAsDefaultMessage(true);
  return source;
}