本文整理汇总了Java中org.springframework.context.support.ReloadableResourceBundleMessageSource类的典型用法代码示例。如果您正苦于以下问题:Java ReloadableResourceBundleMessageSource类的具体用法?Java ReloadableResourceBundleMessageSource怎么用?Java ReloadableResourceBundleMessageSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReloadableResourceBundleMessageSource类属于org.springframework.context.support包,在下文中一共展示了ReloadableResourceBundleMessageSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource();
messageBundle.setBasename("classpath:messages/messages");
messageBundle.setDefaultEncoding("UTF-8");
return messageBundle;
}
示例2: initMessageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@PostConstruct
protected void initMessageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:messages/conversation");
messageSource.setDefaultEncoding("utf-8");
messageSource.setCacheSeconds(3600);
if (externalResourceBundle != null) {
ReloadableResourceBundleMessageSource external = new ReloadableResourceBundleMessageSource();
external.setBasename(externalResourceBundle);
external.setDefaultEncoding("utf-8");
external.setCacheSeconds(500);
external.setParentMessageSource(messageSource);
this.messageSource = external;
} else {
this.messageSource = messageSource;
}
}
示例3: messageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean(name = "messageSource")
public MessageSource messageSource() {
// MessageSource configuration for localized messages.
final ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
source.setBasenames("classpath:/i18n/messages", "classpath:ValidationMessages");
source.setUseCodeAsDefaultMessage(true);
source.setFallbackToSystemLocale(false);
source.setDefaultEncoding(StandardCharsets.ISO_8859_1.name());
if (runtimeEnvironmentUtil.isDevelopmentEnvironment()) {
// Check for updates on every refresh, otherwise cache forever
source.setCacheSeconds(1);
}
return source;
}
示例4: messageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean(name = "messageSource")
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource reloadMessage = new ReloadableResourceBundleMessageSource();
reloadMessage.setBasename("classpath:/messages");
reloadMessage.setDefaultEncoding("UTF-8");
reloadMessage.setCacheSeconds(0);
return reloadMessage;
}
示例5: messageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
resource.setBasenames("/WEB-INF/locales/messages");
resource.setDefaultEncoding("UTF-8");
resource.setFallbackToSystemLocale(Boolean.TRUE);
return resource;
}
示例6: getMessageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@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;
}
示例7: setUp
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
messageSource = new ReloadableResourceBundleMessageSource();
((ReloadableResourceBundleMessageSource) messageSource).setBasename("swagger-messages");
swaggerGenerator.setSwaggerMessageSource(messageSource);
try (InputStream in = getClass().getClassLoader().getResourceAsStream("swagger.properties")) {
swaggerProperties = new Properties();
swaggerProperties.load(in);
swaggerGenerator.setSwaggerProperties(swaggerProperties);
swaggerGenerator.setAllEntities(allEntities);
}
when(allEntities.retrieveAll()).thenReturn(entities());
}
示例8: configureMessageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
public void configureMessageSource(ReloadableResourceBundleMessageSource messageSource)
{
ApplicationConfiguration appConfig = appConfig();
MessageSourceConfig config = new DefaultMessageSourceConfig();
config.addBaseName("WEB-INF/messages/Messages");
config.setCacheSeconds(appConfig.isOptimizeResources() ? -1 : DEFAULT_REFRESH_INTERVALL);
config.setDefaultEncoding("UTF-8");
configurer.configureMessageSource(config);
messageSource.setCacheSeconds(config.getCacheSeconds() != null ? config.getCacheSeconds() : -1);
if (!CollectionUtils.isEmpty(config.getBaseNames()))
{
messageSource.setBasenames(config.getBaseNames().toArray(new String[config.getBaseNames().size()]));
}
messageSource.setDefaultEncoding(config.getDefaultEncoding());
}
示例9: shouldReturnTheFormattedLocalizedMessage
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Test
public void shouldReturnTheFormattedLocalizedMessage() {
CurrentLocale locale = new CurrentLocale();
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
source.setBasename("test_message");
MessageSourceAccessor accessor = new MessageSourceAccessor(source);
Localizer localizer = new Localizer(accessor, locale);
assertThat(localizer.localize("hello_world"), is("Hello World"));
locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
assertThat(localizer.localize("MY_HOME", "San Francisco"), is("My home is San Francisco"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("MY_HOME", "ಬೆಂಗಳೂರು"), is("ನಮ್ಮ ಊರು ಬೆಂಗಳೂರು"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("ನನ್ನ ಹುಟ್ಟು ಹಬ್ಬ 12/23/84"));
locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("My birthday is 12/23/84"));
}
示例10: testFormattedUrl
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
/**
* Testet die Formatierung von URLs.
*/
@Test
public void testFormattedUrl() {
// Additional check that the formating will be correct.
final ReloadableResourceBundleMessageSource messageSource =
new ReloadableResourceBundleMessageSource();
final Long longValue = Long.valueOf(1100L);
testee.addUrlsAsMessagesWithPositionedParameters();
messageSource.setCommonMessages(testee.getMessages());
assertThat(
messageSource.getMessage("purl.testclass.edit",
new Object[] { longValue }, Locale.CANADA)).isEqualTo(
TestClass.EDIT.replaceAll("\\{" + TestClass.P_USERID
+ ":\\[A-Z\\]\\{1,2\\}\\}", "1100"));
assertThat(
messageSource.getMessage("purl.testclass.show", new Object[] {
longValue, longValue }, Locale.CANADA)).isEqualTo(
TestClass.SHOW.replaceAll("\\{" + TestClass.P_USERNAME + "\\}",
"1,100"));
}
示例11: messageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean
ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource bundleMessageSource = new ReloadableResourceBundleMessageSource();
bundleMessageSource.setBasename("classpath:i18n/messages");
bundleMessageSource.setCacheSeconds(1800);
bundleMessageSource.setDefaultEncoding("UTF-8");
return bundleMessageSource;
}
示例12: emailMessageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@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;
}
示例13: showAdminPage
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@RequestMapping(value = Mappings.ADMINISTRATION_ROOT, method = RequestMethod.GET)
public String showAdminPage(Model model, ReloadableResourceBundleMessageSource messageSource) throws Exception {
model.addAttribute("locales", SpringConfiguration.AVAILABLE_LOCALES);
model.addAttribute("currentLocale", LocaleContextHolder.getLocale());
Mappings.includeMappings(model);
return Templates.ADMINISTRATION;
}
示例14: messageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageResource = new ReloadableResourceBundleMessageSource();
messageResource.setBasenames("WEB-INF/i18n/messages");
messageResource.setFallbackToSystemLocale(false);
return messageResource;
}
示例15: apiErrorMessageSource
import org.springframework.context.support.ReloadableResourceBundleMessageSource; //导入依赖的package包/类
@Bean(name = "apiErrorMessageSource")
public ReloadableResourceBundleMessageSource apiErrorMessageSource() {
ReloadableResourceBundleMessageSource messageBundle = new ReloadableResourceBundleMessageSource();
messageBundle.setBasename("classpath:error_messages");
messageBundle.setDefaultEncoding("UTF-8");
messageBundle.setUseCodeAsDefaultMessage(true);
return messageBundle;
}