cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: svn commit: r730139 - /cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java
Date Mon, 05 Jan 2009 15:18:31 GMT

Sergey, 

The problem isn't with DOMUtils, it was with how it was called:
        Element elem = DOMUtils.getFirstElement(e);
        while (elem != null) {
            if ("Policy".equals(elem.getLocalName())) {
                ps.add(elem);
            } else if ("PolicyReference".equals(elem.getLocalName())) {
                prs.add(elem);
            }
            elem = DOMUtils.getNextElement(e);

That last line SHOULD have been:
elem = DOMUtils.getNextElement(elem);

I'm going to revert this as using NodeLists is really bad.  (not thread safe 
and performs poorly)

Dan




On Tuesday 30 December 2008 9:56:51 am sergeyb@apache.org wrote:
> Author: sergeyb
> Date: Tue Dec 30 06:56:51 2008
> New Revision: 730139
>
> URL: http://svn.apache.org/viewvc?rev=730139&view=rev
> Log:
> Avoiding DomUtils in PolicyFeatureBeanDefinitionParser to avoid recursive
> lock in OSGI env
>
> Modified:
>    
> cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/Policy
>FeatureBeanDefinitionParser.java
>
> Modified:
> cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/Policy
>FeatureBeanDefinitionParser.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apach
>e/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java?rev=730139&r1=
>730138&r2=730139&view=diff
> ===========================================================================
>=== ---
> cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/Policy
>FeatureBeanDefinitionParser.java (original) +++
> cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/Policy
>FeatureBeanDefinitionParser.java Tue Dec 30 06:56:51 2008 @@ -22,9 +22,10 @@
>  import java.util.List;
>
>  import org.w3c.dom.Element;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
>
>  import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
> -import org.apache.cxf.helpers.DOMUtils;
>  import org.apache.cxf.ws.policy.WSPolicyFeature;
>  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
>  import org.springframework.beans.factory.xml.ParserContext;
> @@ -38,14 +39,19 @@
>          List<Element> ps = new ArrayList<Element>();
>          List<Element> prs = new ArrayList<Element>();
>
> -        Element elem = DOMUtils.getFirstElement(e);
> -        while (elem != null) {
> -            if ("Policy".equals(elem.getLocalName())) {
> -                ps.add(elem);
> -            } else if ("PolicyReference".equals(elem.getLocalName())) {
> -                prs.add(elem);
> -            }
> -            elem = DOMUtils.getNextElement(e);
> +        NodeList children = e.getChildNodes();
> +        if (children != null) {
> +            for (int i = 0; i < children.getLength(); i++) {
> +                Node nd = children.item(i);
> +                if (nd.getNodeType() == Node.ELEMENT_NODE) {
> +                    Element elem = (Element)nd;
> +                    if ("Policy".equals(elem.getLocalName())) {
> +                        ps.add(elem);
> +                    } else if
> ("PolicyReference".equals(elem.getLocalName())) { +                       
> prs.add(elem);
> +                    }
> +                }
> +            }
>          }
>
>          bean.addPropertyValue("policyElements", ps);



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message