001    /* 
002     * Copyright 2008-2009 the original author or authors.
003     * The contents of this file are subject to the Mozilla Public License
004     * Version 1.1 (the "License"); you may not use this file except in
005     * compliance with the License. You may obtain a copy of the License at
006     * http://www.mozilla.org/MPL/
007     *
008     * Software distributed under the License is distributed on an "AS IS"
009     * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
010     * License for the specific language governing rights and limitations
011     * under the License.
012     */
013     
014    package com.mtgi.analytics.aop.config.v11;
015    
016    import org.springframework.beans.factory.config.BeanDefinition;
017    import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
018    import org.springframework.beans.factory.xml.BeanDefinitionParser;
019    import org.springframework.beans.factory.xml.ParserContext;
020    import org.w3c.dom.Element;
021    import org.w3c.dom.Node;
022    import org.w3c.dom.NodeList;
023    
024    /**
025     * Parses the <code>bt:config</code> tag.  This tag does not export a bean definition by itself, but is rather just
026     * a container for multiple <code>bt:manager</code> tags (in the rare cases where such a thing is desired).
027     */
028    public class BtConfigBeanDefinitionParser implements BeanDefinitionParser {
029    
030            public BeanDefinition parse(Element element, ParserContext parserContext) {
031                    CompositeComponentDefinition component = new CompositeComponentDefinition(element.getNodeName(), parserContext.extractSource(element));
032                    parserContext.pushContainingComponent(component);
033                    try {
034                            NodeList children = element.getChildNodes();
035                            for (int i = 0; i < children.getLength(); i++) {
036                                    Node node = children.item(i);
037                                    if (node.getNodeType() == Node.ELEMENT_NODE)
038                                            parserContext.getDelegate().parseCustomElement((Element)node, null);
039                            }
040                            //no actual bean generated for bt:config.
041                            return null;
042                    } finally {
043                            parserContext.popAndRegisterContainingComponent();
044                    }
045            }
046    
047    }