this.messageSource = messageSource;
}
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
if (bean instanceof TitleConfigurable) {
TitleConfigurable configurable = (TitleConfigurable) bean;
try {
String title = messageSource.getMessage(new DefaultMessageSourceResolvable(name + "." + TITLE_KEY),
Locale.getDefault());
if (StringUtils.hasText(title)) {
configurable.setTitle(title);
}
}
catch (NoSuchMessageException e) {
throw new BeanInitializationException("Unable to initialize bean " + name, e);
}