cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Mazza <glen.ma...@verizon.net>
Subject Re: svn commit: r550965 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/configuration/spring/ rt/core/src/main/java/org/apache/cxf/bus/ rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/core/src/main/resources/META-INF/ rt/core/src/...
Date Tue, 26 Jun 2007 22:26:15 GMT
Am Dienstag, den 26.06.2007, 21:50 +0000 schrieb dandiep@apache.org:

> Added:
> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?view=auto&rev=550965
> ==============================================================================
> --- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(added)
> +++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Tue Jun 26 14:50:27 2007

> +    protected Element getFirstChild(Element element) {
> +        Element first = null;
> +        NodeList children = element.getChildNodes();
> +        for (int i = 0; i < children.getLength(); i++) {
> +            Node n = children.item(i);
> +            if (n.getNodeType() == Node.ELEMENT_NODE) {
> +                first = (Element) n;
> +            }
> +        }
> +        return first;
> +    }
> +

Hmmm.  I may be as blind as a bat here, but AFAICT this is returning the *last* child, not
the first, because it never breaks out of the for loop once an element node is found.


> +    protected String getIdOrName(Element elem) {
> +        String id = elem.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
> +        
> +        if (null == id || "".equals(id)) {
> +            String names = elem.getAttribute(BeanConstants.NAME_ATTR);
> +            if (null != names) {
> +                StringTokenizer st = 
> +                    new StringTokenizer(names, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
> +                if (st.countTokens() > 0) {
> +                    id = st.nextToken();
> +                }
> +            }
> +        }
> +        return id;
> +    }
> +
> +}

Since an id="" is invalid here (it causes one to search for the names
instead), you might wish for this method to return null for an id=""
with no names found (presently it will return an empty string).  This
way the caller of this method needs only to check for 'null' (not both
'null' or an 'empty string').

Also, I don't know enough about the business logic, but, just to
confirm, are you certain you would want to return the last name in the
set if there are multiple names--instead of the first name available,
or, actually, to raise an exception if more than one name is present?  

Glen



Mime
View raw message