001    /*****************************************************************************
002     * Copyright (C) NanoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the LICENSE.txt file.                                                     *
007     *                                                                           *
008     * Original code by James Strachan                                           *
009     *****************************************************************************/
010    
011    package org.nanocontainer.script.groovy.buildernodes;
012    
013    import java.util.Map;
014    
015    import org.nanocontainer.NanoContainer;
016    import org.nanocontainer.script.ClassPathElementHelper;
017    
018    import org.nanocontainer.ClassPathElement;
019    
020    /**
021     * @author James Strachan
022     * @author Paul Hammant
023     * @author Aslak Hellesøy
024     * @author Michael Rimov
025     * @author Mauro Talevi
026     * @version $Revision: 2695 $
027     */
028    public class ClasspathNode extends AbstractBuilderNode {
029    
030        public static final String NODE_NAME = "classPathElement";
031    
032    
033        private static final String PATH = "path";
034    
035    
036        public ClasspathNode() {
037            super(NODE_NAME);
038    
039            addAttribute(PATH);
040        }
041    
042    
043        public Object createNewNode(Object current, Map attributes) {
044            return createClassPathElementNode(attributes, (NanoContainer) current);
045        }
046    
047        private ClassPathElement createClassPathElementNode(Map attributes, NanoContainer nanoContainer) {
048    
049            final String path = (String) attributes.remove(PATH);
050            return ClassPathElementHelper.addClassPathElement(path, nanoContainer);
051        }
052    
053    }