Search in sources :

Example 86 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project kylo by Teradata.

the class SparkShellClientAppCommonConfig method sparkShellMessages.

@Bean
public MessageSource sparkShellMessages() {
    final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename("spark-shell");
    messageSource.setUseCodeAsDefaultMessage(true);
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 87 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project entando-core by entando.

the class AbstractControllerTest method createExceptionResolver.

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;
}
Also used : ExceptionHandlerExceptionResolver(org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver) MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) RestExceptionHandler(org.entando.entando.web.common.handlers.RestExceptionHandler) ServletInvocableHandlerMethod(org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod) ExceptionHandlerMethodResolver(org.springframework.web.method.annotation.ExceptionHandlerMethodResolver) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ServletInvocableHandlerMethod(org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) ServletInvocableHandlerMethod(org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod) HandlerMethod(org.springframework.web.method.HandlerMethod) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IOException(java.io.IOException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException)

Example 88 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project kylo by Teradata.

the class CatalogConfig method catalogMessages.

@Bean
public MessageSource catalogMessages() {
    final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename("CatalogMessages");
    messageSource.setUseCodeAsDefaultMessage(true);
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 89 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project kylo by Teradata.

the class SparkShellRestConfig method sparkShellMessages.

@Bean
public MessageSource sparkShellMessages() {
    final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("spark-shell", "spark-shell-plugin");
    messageSource.setUseCodeAsDefaultMessage(true);
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 90 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project spring-boot by spring-projects.

the class MessageSourceAutoConfiguration method messageSource.

@Bean
public MessageSource messageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    if (StringUtils.hasText(this.basename)) {
        messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(this.basename)));
    }
    if (this.encoding != null) {
        messageSource.setDefaultEncoding(this.encoding.name());
    }
    messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
    messageSource.setCacheSeconds(this.cacheSeconds);
    messageSource.setAlwaysUseMessageFormat(this.alwaysUseMessageFormat);
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)179 Bean (org.springframework.context.annotation.Bean)99 Before (org.junit.Before)16 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)13 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)9 ValidatorFactory (javax.validation.ValidatorFactory)6 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)6 PlatformResourceBundleLocator (org.hibernate.validator.resourceloading.PlatformResourceBundleLocator)6 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 IOException (java.io.IOException)5 List (java.util.List)5 Locale (java.util.Locale)5 ReaderFactoryByMap (net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap)5 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)5 MessageSource (org.springframework.context.MessageSource)5 ArrayList (java.util.ArrayList)4 N2oApplicationBuilder (net.n2oapp.framework.config.N2oApplicationBuilder)4 N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)4 PersisterFactoryByMap (net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap)4