use of org.springframework.context.support.ResourceBundleMessageSource in project Protocol-Adapter-OSLP by OSGP.
the class ApplicationContext method messageSource.
/**
* Method for creating the Message Source.
*
* @return MessageSource
*/
@Bean
public MessageSource messageSource() {
final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(this.environment.getRequiredProperty(PROPERTY_NAME_MESSAGESOURCE_BASENAME));
messageSource.setUseCodeAsDefaultMessage(Boolean.parseBoolean(this.environment.getRequiredProperty(PROPERTY_NAME_MESSAGESOURCE_USE_CODE_AS_DEFAULT_MESSAGE)));
return messageSource;
}
use of org.springframework.context.support.ResourceBundleMessageSource in project tutorials by eugenp.
the class ClientWebConfigJava method messageSource.
@Bean
public MessageSource messageSource() {
final ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
ms.setBasenames("messages");
return ms;
}
use of org.springframework.context.support.ResourceBundleMessageSource in project tutorials by eugenp.
the class WebMVCConfig method messageSource.
@Bean
@Description("Spring Message Resolver")
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
return messageSource;
}
use of org.springframework.context.support.ResourceBundleMessageSource in project tephra by heisedebaise.
the class MessageImpl method onContextRefreshed.
@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);
}
use of org.springframework.context.support.ResourceBundleMessageSource in project irida by phac-nml.
the class ProjectTest method setUp.
@Before
public void setUp() {
Configuration<?> configuration = Validation.byDefaultProvider().configure();
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename(MESSAGES_BASENAME);
configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(MESSAGES_BASENAME)));
ValidatorFactory factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
}
Aggregations