MessageBeanProcessor.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:kuali_rice 作者:
/**
 * Retrieves external messages whose namespace and component matches the bean definition and applies
 * the message text to the bean property values
 *
 * @param beanName name of the bean to process
 * @param beanDefinition bean definition to process
 * @param nestedBeanStack stack of beans that contain the given bean, used for finding a namespace
 */
protected void processBeanMessages(String beanName, BeanDefinition beanDefinition,
        Stack<BeanDefinitionHolder> nestedBeanStack) {
    Class<?> beanClass = getBeanClass(beanDefinition, beanFactory);
    if ((beanClass == null) || !(DictionaryBean.class.isAssignableFrom(beanClass) || ListFactoryBean.class
            .isAssignableFrom(beanClass))) {
        return;
    }

    String namespace = getNamespaceForBean(beanName, beanDefinition);
    if (StringUtils.isBlank(namespace)) {
        namespace = getNamespaceForBeanInStack(nestedBeanStack);
    }

    String componentCode = getComponentForBean(beanName, beanDefinition);
    if (StringUtils.equals(componentCode, beanName)) {
        // check if there is a parent bean in the factory using the standard suffix, if so we will skip this
        // bean as messages will be picked up by that parent bean definition. Note this is not for all parents,
        // just where the convention has been setup for extension (ex. 'bean' and 'bean-parentName')
        String extensionParentBeanName = beanName + KRADConstants.DICTIONARY_BEAN_PARENT_SUFFIX;
        if (beanFactory.containsBean(extensionParentBeanName)) {
            return;
        }
    }

    // if a namespace and component was found retrieve all messages associated with them
    if (StringUtils.isNotBlank(namespace) && StringUtils.isNotBlank(componentCode)) {
        Collection<Message> beanMessages = getMessageService().getAllMessagesForComponent(namespace, componentCode);
        for (Message beanMessage : beanMessages) {
            applyMessageToBean(beanMessage, beanDefinition, beanClass);
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号