001 /******************************************************************************* 002 * Copyright (C) PicoContainer Organization. All rights reserved. 003 * --------------------------------------------------------------------------- 004 * The software in this package is published under the terms of the BSD style 005 * license a copy of which has been included with this distribution in the 006 * LICENSE.txt file. 007 ******************************************************************************/ 008 package org.picocontainer.script.groovy; 009 010 import java.util.Map; 011 import java.util.Set; 012 013 import org.picocontainer.script.ScriptedPicoContainerMarkupException; 014 015 /** 016 * In a node builder environment, there is often one class per node that is 017 * possible in a builder. This interface provides the necessary validation and 018 * interaction methods for the mediator node builder to figure out who should 019 * handle what. 020 * 021 * @author Michael Rimov 022 */ 023 public interface BuilderNode { 024 025 /** 026 * Returns the name of the node, eg 'container' or 'component'. 027 * 028 * @return The node name 029 */ 030 String getNodeName(); 031 032 /** 033 * Returns the supported attribute names. 034 * 035 * @return The Set of supported attribute names. 036 */ 037 Set<String> getSupportedAttributeNames(); 038 039 /** 040 * Validates a the attributes as supplied by the node builder against the 041 * node's supported attributes. 042 * 043 * @param attributes the Map of scripted attributes 044 * @throws ScriptedPicoContainerMarkupException 045 */ 046 void validateScriptedAttributes(Map<String, Object> attributes) throws ScriptedPicoContainerMarkupException; 047 048 /** 049 * Creates a new node . 050 * 051 * @param current the current Object - may be <code>null</code> for no 052 * parent container. 053 * @param attributes the Map of scripted attributes for the builder node - 054 * may be <code>null</code> 055 * @return The newly created node 056 * @throws ScriptedPicoContainerMarkupException upon script failure to 057 * create new node. 058 */ 059 Object createNewNode(Object current, Map<String, Object> attributes) throws ScriptedPicoContainerMarkupException; 060 061 }