    001    package org.nanocontainer.script.groovy.buildernodes;
    002
    003    import java.util.Map;
    004
    005    import org.nanocontainer.NanoContainer;
    006    import org.nanocontainer.script.NanoContainerMarkupException;
    007
    008    public class DecoratingPicoContainerNode extends AbstractBuilderNode {
    009
    010        public static final String NODE_NAME = "decoratingPicoContainer";
    011
    012        public DecoratingPicoContainerNode() {
    013            super(NODE_NAME);
    014        }
    015
    016        public Object createNewNode(Object current, Map attributes) {
    017
    018            if (!(current instanceof NanoContainer)) {
    019                throw new NanoContainerMarkupException("Don't know how to create a 'decoratingPicoContainer' child of a '" + current.getClass() + "' parent");
    020            }
    021
    022            Class clazz = (Class) attributes.remove("class");
    023            NanoContainer container = (NanoContainer) current;
    024
    025            return container.addDecoratingPicoContainer(clazz);
    026        }
    027
    028    }