Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.nanocontainer.script.groovy
Class GroovyNodeBuilder

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          groovy.util.BuilderSupport
              org.nanocontainer.script.groovy.GroovyNodeBuilder

All Implemented Interfaces:
  groovy.lang.GroovyObject

Direct Known Subclasses:
  DynaopGroovyNodeBuilder

    public class GroovyNodeBuilder

extends groovy.util.BuilderSupport

Builds node trees of PicoContainers and Pico components using GroovyMarkup.

Simple example usage in your groovy script: ``

     builder = new org.nanocontainer.script.groovy.GroovyNodeBuilder()
     pico = builder.container(parent:parent) {
       component(class:org.nanocontainer.testmodel.DefaultWebServerConfig)
       component(class:org.nanocontainer.testmodel.WebServerImpl)
     }

#### Extending/Enhancing GroovyNodeBuilder

Often-times people need there own assembly commands that are needed for extending/enhancing the node builder tree. The perfect example of this is `DynaopGroovyNodeBuilder` which provides a new vocabulary for the groovy node builder with terms such as 'aspect', 'pointcut', etc.

GroovyNodeBuilder provides two primary ways of enhancing the nodes supported by the groovy builder: `NodeBuilderDecorationDelegate` and special node handlers `BuilderNode`. Using NodeBuilderDecorationDelegate is often a preferred method because it is ultimately script independent. However, replacing an existing GroovyNodeBuilder's behavior is currently the only way to replace the behavior of an existing groovy node handler.

Version:
  $Revision: 2695 $
Author:
  James Strachan, Paul Hammant, Aslak Hellesøy, Michael Rimov, Mauro Talevi

Field Summary
`static boolean` | `PERFORM_ATTRIBUTE_VALIDATION` Flag indicating that the attribute validation should be performed.
`static boolean` | `SKIP_ATTRIBUTE_VALIDATION` Flag indicating that attribute validation should be skipped.

Constructor Summary
`GroovyNodeBuilder()` Default constructor.
`GroovyNodeBuilder(org.nanocontainer.script.NodeBuilderDecorationDelegate decorationDelegate, boolean performAttributeValidation)` Allows the composition of a ``NodeBuilderDecorationDelegate`` -- an object that extends the capabilities of the `GroovyNodeBuilder` with new tags, new capabilities, etc.

Method Summary
`protected Object` | `createNode(Object name)`
`protected Object` | `createNode(Object name, Map attributes)`
`protected Object` | `createNode(Object name, Map attributes, Object value)` Override of create node.
`protected Object` | `createNode(Object name, Object value)`
`protected Object` | `doInvokeMethod(String s, Object name, Object args)`
`org.nanocontainer.script.NodeBuilderDecorationDelegate` | `getDecorationDelegate()` Retrieve the current decoration delegate.
`BuilderNode` | `getNode(String tagName)` Returns an appropriate node handler for a given node and
`GroovyNodeBuilder` | `setNode(BuilderNode newGroovyNode)` Add's a groovy node handler to the table of possible handlers.
`protected void` | `setParent(Object parent, Object child)`

Methods inherited from class groovy.util.BuilderSupport
`getCurrent, getName, invokeMethod, invokeMethod, nodeCompleted, setClosureDelegate, setCurrent`

Methods inherited from class groovy.lang.GroovyObjectSupport
`getMetaClass, getProperty, setMetaClass, setProperty`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PERFORM_ATTRIBUTE_VALIDATION

    public static boolean PERFORM_ATTRIBUTE_VALIDATION

  Flag indicating that the attribute validation should be performed.

### SKIP_ATTRIBUTE_VALIDATION

    public static boolean SKIP_ATTRIBUTE_VALIDATION

  Flag indicating that attribute validation should be skipped.

Constructor Detail

### GroovyNodeBuilder

    public GroovyNodeBuilder(org.nanocontainer.script.NodeBuilderDecorationDelegate decorationDelegate,
                             boolean performAttributeValidation)

  Allows the composition of a ``NodeBuilderDecorationDelegate`` -- an object that extends the capabilities of the `GroovyNodeBuilder` with new tags, new capabilities, etc.

  Parameters:
    `decorationDelegate` - NodeBuilderDecorationDelegate
    `performAttributeValidation` - should be set to PERFORM_ATTRIBUTE_VALIDATION or SKIP_ATTRIBUTE_VALIDATION
  See Also:
    `AopNodeBuilderDecorationDelegate`

### GroovyNodeBuilder

    public GroovyNodeBuilder()

  Default constructor.

Method Detail

### setParent

    protected void setParent(Object parent,
                             Object child)

  Specified by:
    `setParent` in class `groovy.util.BuilderSupport`

### doInvokeMethod

    protected Object doInvokeMethod(String s,
                                    Object name,
                                    Object args)

  Overrides:
    `doInvokeMethod` in class `groovy.util.BuilderSupport`

### createNode

    protected Object createNode(Object name)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

### createNode

    protected Object createNode(Object name,
                                Object value)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

### createNode

    protected Object createNode(Object name,
                                Map attributes,
                                Object value)

  Override of create node. Called by BuilderSupport. It examines the current state of the builder and the given parameters and dispatches the code to one of the create private functions in this object.

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`
  Parameters:
    `name` - The name of the groovy node we're building. Examples are 'container', and 'grant',
    `attributes` - Map attributes of the current invocation.
    `value` - A closure passed into the node. Currently unused.
  Returns:
    Object the created object.

### getDecorationDelegate

    public org.nanocontainer.script.NodeBuilderDecorationDelegate getDecorationDelegate()

  Retrieve the current decoration delegate.

  Returns:
    NodeBuilderDecorationDelegate, should never be null.

### getNode

    public BuilderNode getNode(String tagName)

  Returns an appropriate node handler for a given node and

  Parameters:
    `tagName` - String
  Returns:
    CustomGroovyNode the appropriate node builder for the given tag name, or null if no handler exists. (In which case, the Delegate receives the createChildContainer() call)

### setNode

    public GroovyNodeBuilder setNode(BuilderNode newGroovyNode)

  Add's a groovy node handler to the table of possible handlers. If a node handler with the same node name already exists in the map of handlers, then the `GroovyNode` replaces the existing node handler.

  Parameters:
    `newGroovyNode` - CustomGroovyNode
  Returns:
    GroovyNodeBuilder to allow for method chaining.

### createNode

    protected Object createNode(Object name,
                                Map attributes)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Codehaus. All Rights Reserved.