org.springframework.context.support.ReloadableResourceBundleMessageSource Java Examples

The following examples show how to use org.springframework.context.support.ReloadableResourceBundleMessageSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebMvcConfig.java    From konker-platform with Apache License 2.0 7 votes vote down vote up
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.addBasenames("classpath:/messages/alert-triggers");
    messageSource.addBasenames("classpath:/messages/applications");
    messageSource.addBasenames("classpath:/messages/device-model");
    messageSource.addBasenames("classpath:/messages/devices");
    messageSource.addBasenames("classpath:/messages/devices-config");
    messageSource.addBasenames("classpath:/messages/gateways");
    messageSource.addBasenames("classpath:/messages/locations");
    messageSource.addBasenames("classpath:/messages/rest-destination");
    messageSource.addBasenames("classpath:/messages/routes");
    messageSource.addBasenames("classpath:/messages/routes-counter");
    messageSource.addBasenames("classpath:/messages/transformations");
    messageSource.addBasenames("classpath:/messages/users");
    messageSource.addBasenames("classpath:/messages/tenants");
    messageSource.addBasenames("classpath:/messages/health-alert");
    messageSource.addBasenames("classpath:/mail/MailMessages");
    messageSource.addBasenames("classpath:/messages/private-storage");
    messageSource.addBasenames("classpath:/messages/global");
    messageSource.setDefaultEncoding("UTF-8");

    return messageSource;
}
 
Example #2
Source File: AsqatasunOrchestratorFactory.java    From Asqatasun with GNU Affero General Public License v3.0 6 votes vote down vote up
public static AsqatasunOrchestrator create(
    AuditService auditService,
    ActDataService actDataService,
    AuditDataService auditDataService,
    ActFactory actFactory,
    ScenarioDataService scenarioDataService,
    ScopeDataService scopeDataService,
    ThreadPoolTaskExecutor threadPoolTaskExecutor,
    EmailSender emailSender,
    ReloadableResourceBundleMessageSource messageSource
) {
    return new AsqatasunOrchestratorImpl(
        auditService,
        auditDataService,
        actDataService,
        actFactory,
        scopeDataService,
        scenarioDataService,
        threadPoolTaskExecutor,
        emailSender,
        messageSource
    );
}
 
Example #3
Source File: AsqatasunOrchestratorImpl.java    From Asqatasun with GNU Affero General Public License v3.0 6 votes vote down vote up
@Autowired
public AsqatasunOrchestratorImpl(
    AuditService auditService,
    AuditDataService auditDataService,
    ActDataService actDataService,
    ActFactory actFactory,
    ScopeDataService scopeDataService,
    ScenarioDataService scenarioDataService,
    ThreadPoolTaskExecutor threadPoolTaskExecutor,
    EmailSender emailSender,
    @Qualifier(value = "emailMessageSource") ReloadableResourceBundleMessageSource messageSource
) {
    this.auditService = auditService;
    this.actDataService = actDataService;
    this.auditDataService = auditDataService;
    this.actFactory = actFactory;
    this.scenarioDataService = scenarioDataService;
    initializeScopeMap(scopeDataService);
    this.threadPoolTaskExecutor = threadPoolTaskExecutor;
    this.emailSender = emailSender;
    this.messageSource = messageSource;
}
 
Example #4
Source File: MessageSouceTestConfiguration.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.addBasenames("classpath:/messages/alert-triggers");
    messageSource.addBasenames("classpath:/messages/applications");
    messageSource.addBasenames("classpath:/messages/device-model");
    messageSource.addBasenames("classpath:/messages/devices");
    messageSource.addBasenames("classpath:/messages/devices-config");
    messageSource.addBasenames("classpath:/messages/gateways");
    messageSource.addBasenames("classpath:/messages/locations");
    messageSource.addBasenames("classpath:/messages/rest-destination");
    messageSource.addBasenames("classpath:/messages/routes");
    messageSource.addBasenames("classpath:/messages/transformations");
    messageSource.addBasenames("classpath:/messages/users");
    messageSource.addBasenames("classpath:/messages/tenants");
    messageSource.addBasenames("classpath:/messages/health-alert");
    messageSource.addBasenames("classpath:/mail/MailMessages");
    messageSource.setDefaultEncoding("UTF-8");

    return messageSource;
}
 
Example #5
Source File: ThymeleafConfiguration.java    From ServiceCutter with Apache License 2.0 5 votes vote down vote up
@Bean
@Description("Spring mail message resolver")
public MessageSource emailMessageSource() {
    log.info("loading non-reloadable mail messages resources");
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasename("classpath:/mails/messages/messages");
    messageSource.setDefaultEncoding(CharEncoding.UTF_8);
    return messageSource;
}
 
Example #6
Source File: SpringMessageSourceHelperTest.java    From trimou with Apache License 2.0 5 votes vote down vote up
private static MessageSource initMessageSource() {
    final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setCacheSeconds(5);
    messageSource.setDefaultEncoding("UTF-8");
    messageSource.setFallbackToSystemLocale(true);
    messageSource.setUseCodeAsDefaultMessage(false);
    messageSource.setBasename("classpath:messages");
    return messageSource;
}
 
Example #7
Source File: RestHandlerExceptionResolverBuilder.java    From spring-rest-exception-handler with Apache License 2.0 5 votes vote down vote up
private MessageSource createDefaultMessageSource() {

        ReloadableResourceBundleMessageSource messages = new ReloadableResourceBundleMessageSource();
        messages.setBasename(DEFAULT_MESSAGES_BASENAME);
        messages.setDefaultEncoding("UTF-8");
        messages.setFallbackToSystemLocale(false);

        return messages;
    }
 
Example #8
Source File: JseRsTagTest.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() {

    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasenames(new String[] {
        "classpath:/jp/co/ctc_g/jse/core/message/JseRsTagTest",
        "classpath:/jp/co/ctc_g/jse/core/message/JseRsTagTestResources"
    });
    MessageSourceLocator.set(messageSource);
}
 
Example #9
Source File: ThymeleafConfiguration.java    From expper with GNU General Public License v3.0 5 votes vote down vote up
@Bean
@Description("Spring mail message resolver")
public MessageSource emailMessageSource() {
    log.info("loading non-reloadable mail messages resources");
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasename("classpath:/mails/messages/messages");
    messageSource.setDefaultEncoding(CharEncoding.UTF_8);
    return messageSource;
}
 
Example #10
Source File: ErrorHandleConfiguration.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Bean(name=ExceptionMessageAccessor.BEAN_EXCEPTION_MESSAGE)
public MessageSource exceptionMessageSource(@Autowired BootJFishConfig bootJFishConfig){
	ReloadableResourceBundleMessageSource ms = new ReloadableResourceBundleMessageSource();
	ms.setCacheSeconds(bootJFishConfig.getMessageSource().getCacheSeconds());
	ms.setBasenames("classpath:messages/exception-messages", 
			"classpath:messages/default-exception-messages", 
			"org/hibernate/validator/ValidationMessages");
	return ms;
}
 
Example #11
Source File: ThymeleafConfiguration.java    From angularjs-springboot-bookstore with MIT License 5 votes vote down vote up
@Bean
@Description("Spring mail message resolver")
public MessageSource emailMessageSource() {
    log.info("loading non-reloadable mail messages resources");
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasename("classpath:/mails/messages/messages");
    messageSource.setDefaultEncoding(CharEncoding.UTF_8);
    return messageSource;
}
 
Example #12
Source File: MvcAutoConfiguration.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * 消息处理,可以直接使用properties的key值,返回的是对应的value值
 * messageSource .
 * @return messageSource
 */
@Bean (name = "messageSource")
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource(
        @Value("${spring.messages.basename:classpath:messages/message}")
        String messagesBasename)  {
    _logger.debug("Basename " + messagesBasename);
    
    ReloadableResourceBundleMessageSource messageSource = 
            new ReloadableResourceBundleMessageSource();
    messageSource.setBasename(messagesBasename);
    messageSource.setUseCodeAsDefaultMessage(false);
    return messageSource;
}
 
Example #13
Source File: AppConfiguration.java    From SMSC with Apache License 2.0 5 votes vote down vote up
@Primary
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource messageSource() { // @todo not working
    ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource();
    messageBundle.setBasename("classpath:messages");
    messageBundle.addBasenames("classpath:messages", "classpath:validation");
    messageBundle.setUseCodeAsDefaultMessage(true);
    messageBundle.setDefaultEncoding("UTF-8");
    messageBundle.setFallbackToSystemLocale(true);

    return messageBundle;
}
 
Example #14
Source File: DeviceRegisterService.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
public DeviceDataURLs(Device device, Locale locale) {
	ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
       messageSource.setBasename("classpath:/messages/devices");
       messageSource.setDefaultEncoding("UTF-8");

       httpHostName = pubServerConfig.getHttpHostname();
       httpPort = pubServerConfig.getHttpPort();
       httpsPort = pubServerConfig.getHttpsPort();
       mqttHostName = pubServerConfig.getMqttHostName();
       mqttPort = pubServerConfig.getMqttPort();
       mqttTlsPort = pubServerConfig.getMqttTlsPort();
       context = pubServerConfig.getHttpCtx();
       channel = messageSource.getMessage("model.device.channel", null, locale);
       username = device.getApiKey();

       if (httpHostName.equalsIgnoreCase("localhost")) {
           this.httpHostName = "<ip>";
       }
       if (mqttHostName.equalsIgnoreCase("localhost")) {
       	mqttHostName = "<ip>";
       }
       if (StringUtils.hasText(device.getApplication().getDataApiDomain())) {
       	httpHostName = device.getApplication().getDataApiDomain();
       }        
       if (StringUtils.hasText(device.getApplication().getDataMqttDomain())) {
       	mqttHostName = device.getApplication().getDataMqttDomain();
       }
}
 
Example #15
Source File: WebMvcConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.addBasenames(
            "classpath:/messages/devices",
            "classpath:/messages/routes",
            "classpath:/messages/routes-counter",
            "classpath:/messages/integration",
            "classpath:/messages/transformations",
            "classpath:/messages/devices-config",
            "classpath:/messages/applications");
    
    messageSource.setDefaultEncoding("UTF-8");
    return messageSource;
}
 
Example #16
Source File: WebMvcConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.addBasenames(
            "classpath:/messages/devices",
            "classpath:/messages/routes",
            "classpath:/messages/routes-counter",
            "classpath:/messages/integration",
            "classpath:/messages/transformations",
            "classpath:/messages/devices-config",
            "classpath:/messages/applications");
    
    messageSource.setDefaultEncoding("UTF-8");
    return messageSource;
}
 
Example #17
Source File: WebMvcConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.addBasenames(
            "classpath:/messages/devices",
            "classpath:/messages/routes",
            "classpath:/messages/routes-counter",
            "classpath:/messages/integration",
            "classpath:/messages/transformations",
            "classpath:/messages/devices-config",
            "classpath:/messages/applications");
    
    messageSource.setDefaultEncoding("UTF-8");
    return messageSource;
}
 
Example #18
Source File: InternationalizationConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Bean
public MessageSource bundleMessageSource() {
    final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasename("messages");
    return messageSource;
}
 
Example #19
Source File: OauthServerApplication.java    From oauth-server with Apache License 2.0 5 votes vote down vote up
/**
 * messageBean配置文件
 *
 * @return Bean
 */
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource messageBundle =
            new ReloadableResourceBundleMessageSource();
    messageBundle.setBasename("classpath:messages/messages");
    messageBundle.setDefaultEncoding("UTF-8");
    return messageBundle;
}
 
Example #20
Source File: HibernateValidateConfig.java    From spring-boot-api-project-seed with Apache License 2.0 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource = new ReloadableResourceBundleMessageSource();
    reloadableResourceBundleMessageSource.setBasenames("classpath:message/ValidationMessages");
    reloadableResourceBundleMessageSource.setUseCodeAsDefaultMessage(true);
    reloadableResourceBundleMessageSource.setDefaultEncoding("UTF-8");
    reloadableResourceBundleMessageSource.setCacheSeconds(60);
    return reloadableResourceBundleMessageSource;
}
 
Example #21
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #22
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #23
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #24
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #25
Source File: MessageSourceConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean(name = "messageSource")
public MessageSource getMessageSource() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.addBasenames(
            "/WEB-INF/i18n/dateformats",
            "/WEB-INF/i18n/destinations",
            "/WEB-INF/i18n/devices",
            "/WEB-INF/i18n/email",
            "/WEB-INF/i18n/error",
            "/WEB-INF/i18n/global",
            "/WEB-INF/i18n/languages",
            "/WEB-INF/i18n/loglevels",
            "/WEB-INF/i18n/menu",
            "/WEB-INF/i18n/routes",
            "/WEB-INF/i18n/timezones",
            "/WEB-INF/i18n/tokens",
            "/WEB-INF/i18n/transformations",
            "/WEB-INF/i18n/usernotifications",
            "/WEB-INF/i18n/users",
            "/WEB-INF/i18n/visualization",
            "classpath:/messages/alert-triggers",
            "classpath:/messages/applications",
            "classpath:/messages/device-model",
            "classpath:/messages/devices",
            "classpath:/messages/rest-destination",
            "classpath:/messages/routes",
            "classpath:/messages/transformations",
            "classpath:/messages/rest-destination",
            "classpath:/messages/users",
            "classpath:/messages/tenants",
            "classpath:/messages/applications",
            "classpath:/messages/device-model",
            "classpath:/messages/health-alert",
            "classpath:/messages/routes-counter",
            "classpath:/messages/iugu",
            "classpath:/mail/MailMessages");
    messageSource.setDefaultEncoding("UTF-8");
    return messageSource;
}
 
Example #26
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #27
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #28
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #29
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
    ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
    resource.setBasenames("/WEB-INF/locales/messages");
    resource.setDefaultEncoding("UTF-8");
    resource.setFallbackToSystemLocale(Boolean.TRUE);
    return resource;
}
 
Example #30
Source File: ApplicationRecoverableExceptionTest.java    From sinavi-jfw with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasename("classpath:/jp/co/ctc_g/jfw/core/exception/error");
    MessageSourceLocator.set(messageSource);
}