⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managedbeandefinitiondocumentreader.java

📁 Please read your package and describe it at least 40 bytes in English. System will automatically de
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     */    private MutablePropertyValues parseManagedBeanPropertyDefinitions(            final NodeList propertyElements, final String beanName) {        MutablePropertyValues propertyValues = new MutablePropertyValues();        for (int i = 0; i < propertyElements.getLength(); i++) {            parseManagedBeanPropertyDefinition(propertyValues,                    (Element) propertyElements.item(i), beanName);        }        return propertyValues;    }    /**     * Parses the type of a property value.     *      * @param element     *            the property definition     * @param elementName     *            the tagname of the element     * @param beanName     *            the name of the bean represented by the delivered     *            BeanDefinition     * @return the type of the property value     */    private Class createPropertyValueClass(final Element element,            final String elementName, final String beanName) {        Class propertyClass = null;        if (element.getElementsByTagName(elementName).getLength() > 0) {            String propertyClassName = getTextValue((Element) element                    .getElementsByTagName(elementName).item(0));            try {                this.parseState.push(new BeanEntry(propertyClassName));                propertyClass = ClassUtils.forName(propertyClassName,                        getReaderContext().getReader().getBeanClassLoader());            } catch (ClassNotFoundException ex) {                error("Property class [" + propertyClassName + "] not found",                        element, ex);            } catch (NoClassDefFoundError err) {                error("Class that property class [" + propertyClassName                        + "] depends on not found", element, err);            } finally {                this.parseState.pop();            }        }        return propertyClass;    }    /**     * Parses a managed-property.     *      * @param propertyValues     *            MutablePropertyValues representing the properties defined for     *            this managed bean definition     * @param element     *            the managed property definition     * @param beanName     *            the name of the bean represented by the delivered     *            BeanDefinition     */    protected void parseManagedBeanPropertyDefinition(            final MutablePropertyValues propertyValues, final Element element,            final String beanName) {        String propertyName = getTextValue((Element) element                .getElementsByTagName(PROPERTY_NAME_ELEMENT).item(0));        Class propertyClass = createPropertyValueClass(element,                PROPERTY_CLASS_ELEMENT, beanName);        Object propertyValue = null;        NodeList propertyValueElements = null;        if ((propertyValueElements = element                .getElementsByTagName(VALUE_ELEMENT)).getLength() != 0) {            propertyValue = createPropertyValue((Element) propertyValueElements                    .item(0), propertyClass);        } else if ((propertyValueElements = element                .getElementsByTagName(MAP_ENTRIES_ELEMENT)).getLength() != 0) {            propertyValue = createPropertyMapEntries(                    (Element) propertyValueElements.item(0), beanName);        } else if ((propertyValueElements = element                .getElementsByTagName(LIST_ENTRIES_ELEMENT)).getLength() != 0) {            propertyValue = createPropertyListEntries(                    (Element) propertyValueElements.item(0), beanName);        }        propertyValues.addPropertyValue(new PropertyValue(propertyName,                propertyValue));    }    /**     * Parses the value of a manged property.     *      * @param element     *            the DOM element representing the property value     * @param propertyClass     *            the type of the property value     * @return the value of the DOM element representing the property value     */    private Object createPropertyValue(final Element element,            final Class propertyClass) {        Object propertyValue = getTextValue(element);        if (propertyClass != null) {            propertyValue = new TypedStringValue((String) propertyValue,                    propertyClass);        }        return propertyValue;    }    /**     * Parses a map-entries element.     *      * @param element     *            the DOM element representing a map     * @param beanName     *            the name of the bean represented by the delivered     *            BeanDefinition     * @return the map representing the the map-entries element     * @see ManagedMap     */    private ManagedMap createPropertyMapEntries(final Element element,            final String beanName) {        ManagedMap map = new ManagedMap();        Class keyClass = createPropertyValueClass(element, KEY_CLASS_ELEMENT,                beanName);        Class valueClass = createPropertyValueClass(element,                VALUE_CLASS_ELEMENT, beanName);        NodeList mapEntryElements = element                .getElementsByTagName(MAP_ENTRY_ELEMENT);        for (int i = 0; i < mapEntryElements.getLength(); i++) {            Object key = createPropertyValue((Element) element                    .getElementsByTagName(KEY_ELEMENT).item(0), keyClass);            Object value = null;            NodeList propertyValueElements = element                    .getElementsByTagName(VALUE_ELEMENT);            if (propertyValueElements.getLength() != 0) {                value = createPropertyValue((Element) propertyValueElements                        .item(0), valueClass);            }            map.put(key, value);        }        return map;    }    /**     * Parses a list-entries element.     *      * @param element     *            the DOM element representing a list     * @param beanName     *            the name of the bean represented by the delivered     *            BeanDefinition     * @return the list representing the the list-entries element     * @see ManagedList     */    private ManagedList createPropertyListEntries(final Element element,            final String beanName) {        ManagedList list = new ManagedList();        Class valueClass = createPropertyValueClass(element,                VALUE_CLASS_ELEMENT, beanName);        NodeList listEntryElements = element.getChildNodes();        Element listEntryElement = null;        for (int i = 0; i < listEntryElements.getLength(); i++) {            if (listEntryElements.item(i) instanceof Element) {                listEntryElement = (Element) listEntryElements.item(i);                if (VALUE_ELEMENT.equals(listEntryElement.getTagName())) {                    list.add(createPropertyValue(listEntryElement, valueClass));                } else if (NULL_VALUE_ELEMENT.equals(listEntryElement                        .getTagName())) {                    list.add(null);                }            }        }        return list;    }    /**     * Loads the <code>MessageSource</code> definition as a     * {@link org.springframework.beans.factory.support.RootBeanDefinition}     * defined in the "faces-config.xml" as a "message-bundle" tag.     *      * @param messageBundleElements     *            the DOM nodelist representing message bundle definitions     * @param localeConfigElements     *            the DOM nodelist representing locale config definitions     */    protected void registerMessageBeanDefinitions(            final NodeList messageBundleElements,            final NodeList localeConfigElements) {        String messageSourceBeanName = AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME;        ManagedList baseNames = new ManagedList(messageBundleElements                .getLength());        String defaultLocale = null;        ManagedList supportedLocales = new ManagedList();        for (int i = 0; i < messageBundleElements.getLength(); i++) {            baseNames                    .add(getTextValue((Element) messageBundleElements.item(i)));        }        for (int i = 0; i < localeConfigElements.getLength(); i++) {            Element localeConfigElement = (Element) localeConfigElements                    .item(i);            addSupportedLocales(supportedLocales, localeConfigElement,                    messageSourceBeanName);            String extractedDefaultLocale = getDefaultLocale(                    localeConfigElement, messageSourceBeanName);            if (extractedDefaultLocale != null) {                defaultLocale = extractedDefaultLocale;            }        }        if (baseNames.size() != 0) {            BeanDefinitionBuilder builder = BeanDefinitionBuilder                    .rootBeanDefinition(FacesHierarchicalMessageSource.class);            builder.addConstructorArg(baseNames).addConstructorArg(                    defaultLocale).addConstructorArg(supportedLocales);            builder.setSingleton(true);            builder.setResourceDescription(getReaderContext().getResource()                    .getDescription());            BeanDefinitionHolder bd = new BeanDefinitionHolder(builder                    .getBeanDefinition(), messageSourceBeanName);            BeanDefinitionReaderUtils.registerBeanDefinition(bd,                    getReaderContext().getRegistry());            getReaderContext().fireComponentRegistered(                    new BeanComponentDefinition(bd));        }    }    /**     * Adds the supported locales to the <code>MessageResource</code>     * definition defined as a "locale-config" tag in the "faces-config.xml".     *      * @param supportedLocales     *            the locale definitions to support     * @param localeConfigElement     *            the DOM element representing a locale config definition     * @param beanName     *            the name of the bean represented by the delivered     *            BeanDefinition     */    protected void addSupportedLocales(final ManagedList supportedLocales,            final Element localeConfigElement, final String beanName) {        final NodeList supportedLocaleElements = localeConfigElement                .getElementsByTagName(SUPPORTED_LOCALE_ELEMENT);        for (int i = 0; i < supportedLocaleElements.getLength(); i++) {            supportedLocales.add(getTextValue((Element) supportedLocaleElements                    .item(i)));        }    }    /**     * Parses and returns the default locale from the given locale config DOM     * element.     *      * @param localeConfigElement     *            the DOM element representing the locale config definition     * @param beanName     *            the name of the bean represented by the delivered     *            BeanDefinition     * @return the locale represented as string     */    protected String getDefaultLocale(final Element localeConfigElement,            final String beanName) {        String defaultLocale = null;        final NodeList defaultLocaleElements = localeConfigElement                .getElementsByTagName(DEFAULT_LOCALE_ELEMENT);        if (defaultLocaleElements.getLength() != 0) {            defaultLocale = getTextValue((Element) defaultLocaleElements                    .item(0));        }        return defaultLocale;    }    /**     * @return The {@link XmlReaderContext}     */    protected final XmlReaderContext getReaderContext() {        return readerContext;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -