## org.codehaus.groovy.grails.commons.metaclass
Class ClosureInvokingDynamicMethod

    java.lang.Object
      org.codehaus.groovy.grails.commons.metaclass.ClosureInvokingDynamicMethod

All Implemented Interfaces:
  Cloneable, DynamicMethodInvocation, StaticMethodInvocation

    public class ClosureInvokingDynamicMethod

extends Object
implements DynamicMethodInvocation, StaticMethodInvocation, Cloneable

An implementation of DynamicMethodInvocation that invoces a closure

Since:
  0.4

  Created: Feb 2, 2007 Time: 6:55:57 PM
Author:
  Graeme Rocher

Constructor Summary
`ClosureInvokingDynamicMethod(String pattern, groovy.lang.Closure closure)`

Method Summary
`protected Object` `clone()` For thread safety when using a ClosureInvokingDynamicMethod it should ALWAYS be cloned first Weird behaviour will occur if a unique cloned instance is not used for each invocation
`Object` `invoke(Class clazz, String methodName, Object[] arguments)` Invokes the actual method.
`Object` `invoke(Object target, String methodName, Object[] arguments)` Invokes the actual method.
`boolean` `isMethodMatch(String methodName)` Checks if a method name matches the criteria of the implementation class.

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

Constructor Detail

### ClosureInvokingDynamicMethod

    public ClosureInvokingDynamicMethod(String pattern,
                                        groovy.lang.Closure closure)

Method Detail

### clone

    protected Object clone()
                    throws CloneNotSupportedException

  For thread safety when using a ClosureInvokingDynamicMethod it should ALWAYS be cloned first Weird behaviour will occur if a unique cloned instance is not used for each invocation

  Overrides:
    `clone` in class `Object`
  Returns:
    A cloned instance
  Throws:
    `CloneNotSupportedException`

### isMethodMatch

    public boolean isMethodMatch(String methodName)

  Description copied from interface: `DynamicMethodInvocation`

  Checks if a method name matches the criteria of the implementation class.

  Specified by:
    `isMethodMatch` in interface `DynamicMethodInvocation`
  Specified by:
    `isMethodMatch` in interface `StaticMethodInvocation`
  Parameters:
    `methodName` - the static method name
  Returns:
    result of criteria match test

### invoke

    public Object invoke(Class clazz,
                         String methodName,
                         Object[] arguments)

  Description copied from interface: `StaticMethodInvocation`

  Invokes the actual method. The class, method name and arguments are provided. If no arguments are passed the argument array is empty.

  Specified by:
    `invoke` in interface `StaticMethodInvocation`
  Parameters:
    `clazz` - the class the static method is called on
    `methodName` - the static method name
    `arguments` - the arguments supplied
  Returns:
    the return value of the static method invocation

### invoke

    public Object invoke(Object target,
                         String methodName,
                         Object[] arguments)

  Description copied from interface: `DynamicMethodInvocation`

  Invokes the actual method. The target object and arguments are supplied.

  Specified by:
    `invoke` in interface `DynamicMethodInvocation`
  Parameters:
    `target` - the target on which the method is invoked.
    `arguments` - the arguments passed in the method call @return the return value of the dynamic method invocation.

Copyright (c) 2005-2009 The Grails project