AbstractClosureProxy (Griffon 0.9.5-rc2)
Date: 2012-03-09

Overview | Package | Class | Deprecated | Index | Help
| Griffon 0.9.5-rc2
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## griffon.test
[Java] Class AbstractClosureProxy

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          groovy.lang.Closure
              griffon.test.AbstractClosureProxy

    @SuppressWarnings("serial")
    public abstract class AbstractClosureProxy
    extends Closure

Skeleton implementation of a wrapper class for closures that allows you to intercept invocations of the closure. The wrapper can be used anywhere that the target closure can be used.

Field Summary
`private Closure` | `target`

Fields inherited from class Closure
OWNER_FIRST, DELEGATE_FIRST, OWNER_ONLY, DELEGATE_ONLY, TO_SELF, DONE, SKIP, IDENTITY

Constructor Summary
`AbstractClosureProxy(Closure closure)` Creates a new instance that wraps the target closure and sends profiling events to the given profiler log.

Method Summary
`Closure` | `asWritable()`
`Object` | `call(Object[] objects)` This is the important one: logs entry and exit of the closure call.
`protected Closure` | `createWrapper(Closure c)` Called when a new instance of the proxy needs to be created for the given closure.
`Closure` | `curry(Object[] objects)`
`protected void` | `doAfterCall(Object[] args)` This method is called after the target closure is invoked.
`protected void` | `doBeforeCall(Object[] args)` This method is called before the target closure is invoked.
`boolean` | `equals(Object obj)` Compares based on identities, but unlike the standard implementation this one will return `true` if the given object is the target closure for this wrapper as well.
`Object` | `getDelegate()`
`int` | `getDirective()`
`int` | `getMaximumNumberOfParameters()`
`Class[]` | `getParameterTypes()`
`Object` | `getProperty(String property)`
`int` | `getResolveStrategy()`
`int` | `hashCode()`
`boolean` | `isCase(Object o)`
`void` | `setDelegate(Object o)`
`void` | `setDirective(int i)`
`void` | `setProperty(String s, Object o)`
`void` | `setResolveStrategy(int i)`

Methods inherited from class Closure
run, setProperty, getProperty, clone, getParameterTypes, setDelegate, getOwner, leftShift, leftShift, rightShift, call, call, call, getDelegate, getMaximumNumberOfParameters, setResolveStrategy, getResolveStrategy, getThisObject, getDirective, setDirective, isCase, asWritable, curry, rcurry, rcurry, ncurry, ncurry, memoize, memoizeAtMost, memoizeAtLeast, memoizeBetween, trampoline, trampoline, getMetaClass, setMetaClass, invokeMethod, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Methods inherited from class GroovyObjectSupport
setProperty, getProperty, getMetaClass, setMetaClass, invokeMethod, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Field Detail

### target

    private Closure target

Constructor Detail

### AbstractClosureProxy

    public AbstractClosureProxy(Closure closure)

  Creates a new instance that wraps the target closure and sends profiling events to the given profiler log.
  Parameters:
    `closure` - The target closure to wrap.

Method Detail

### asWritable

    @Override
    public Closure asWritable()

### call

    @Override
    public Object call(Object[] objects)

  This is the important one: logs entry and exit of the closure call.

### createWrapper

    protected Closure createWrapper(Closure c)

  Called when a new instance of the proxy needs to be created for the given closure. Usually the implementation simply creates a new instance of the current class, copying over the existing proxy properties:

          return new MyClosureProxy(c, this.field1, ...)

  Parameters:
    `c` - The closure to wrap/proxy.

### curry

    @Override
    public Closure curry(Object[] objects)

### doAfterCall

    protected void doAfterCall(Object[] args)

  This method is called after the target closure is invoked. It will be triggered whether or not an exception is thrown by the target closure.
  Parameters:
    `args` - The arguments passed to the closure.

### doBeforeCall

    protected void doBeforeCall(Object[] args)

  This method is called before the target closure is invoked. This is a passive interceptor, so you cannot prevent the call to the target closure. You can modify the arguments, though, but it's not recommended unless you really know what you're doing.
  Parameters:
    `args` - The arguments passed to the closure.

### equals

    @Override
    public boolean equals(Object obj)

  Compares based on identities, but unlike the standard implementation this one will return `true` if the given object is the target closure for this wrapper as well.

### getDelegate

    @Override
    public Object getDelegate()

### getDirective

    @Override
    public int getDirective()

### getMaximumNumberOfParameters

    @Override
    public int getMaximumNumberOfParameters()

### getParameterTypes

    @Override
    public Class[] getParameterTypes()

### getProperty

    @Override
    public Object getProperty(String property)

### getResolveStrategy

    @Override
    public int getResolveStrategy()

### hashCode

    @Override
    public int hashCode()

### isCase

    @Override
    public boolean isCase(Object o)

### setDelegate

    @Override
    public void setDelegate(Object o)

### setDirective

    @Override
    public void setDirective(int i)

### setProperty

    @Override
    public void setProperty(String s, Object o)

### setResolveStrategy

    @Override
    public void setResolveStrategy(int i)

Groovy Documentation