protected void addAttributeProperties()

in xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java [321:368]


    protected void addAttributeProperties(BeanDefinitionHolder definition, MappingMetaData metadata, String className,
            Element element) {
        NamedNodeMap attributes = element.getAttributes();
        // First pass on attributes with no namespaces
        for (int i = 0, size = attributes.getLength(); i < size; i++) {
            Attr attribute = (Attr) attributes.item(i);
            String uri = attribute.getNamespaceURI();
            String localName = attribute.getLocalName();
            // Skip namespaces
            if (localName == null || localName.equals("xmlns") || localName.startsWith("xmlns:")) {
                continue;
            }
            // Add attributes with no namespaces
            if (isEmpty(uri) && !localName.equals("class")) {
                boolean addProperty = true;
                if (reservedBeanAttributeNames.contains(localName)) {
                    // should we allow the property to shine through?
                    PropertyDescriptor descriptor = getPropertyDescriptor(className, localName);
                    addProperty = descriptor != null;
                }
                if (addProperty) {
                    addAttributeProperty(definition, metadata, element, attribute);
                }
            }
        }
        // Second pass on attributes with namespaces
        for (int i = 0, size = attributes.getLength(); i < size; i++) {
            Attr attribute = (Attr) attributes.item(i);
            String uri = attribute.getNamespaceURI();
            String localName = attribute.getLocalName();
            // Skip namespaces
            if (localName == null || localName.equals("xmlns") || localName.startsWith("xmlns:")) {
                continue;
            }
            // Add attributs with namespaces matching the element ns
            if (!isEmpty(uri) && uri.equals(element.getNamespaceURI())) {
                boolean addProperty = true;
                if (reservedBeanAttributeNames.contains(localName)) {
                    // should we allow the property to shine through?
                    PropertyDescriptor descriptor = getPropertyDescriptor(className, localName);
                    addProperty = descriptor != null;
                }
                if (addProperty) {
                    addAttributeProperty(definition, metadata, element, attribute);
                }
            }
        }
    }