public abstract class GroovyInterceptor extends Object
Once created, it needs to be registered to start receiving interceptions. List of interceptors are maintained per thread.
Modifier and Type | Class and Description |
---|---|
static interface |
GroovyInterceptor.Invoker
Represents the next interceptor in the chain.
|
Constructor and Description |
---|
GroovyInterceptor() |
Modifier and Type | Method and Description |
---|---|
static List<GroovyInterceptor> |
getApplicableInterceptors() |
Object |
onGetArray(GroovyInterceptor.Invoker invoker,
Object receiver,
Object index)
Intercepts an array access, like "z=foo[bar]"
|
Object |
onGetAttribute(GroovyInterceptor.Invoker invoker,
Object receiver,
String attribute)
Intercepts an attribute access, like "z=foo.@bar"
|
Object |
onGetProperty(GroovyInterceptor.Invoker invoker,
Object receiver,
String property)
Intercepts a property access, like "z=foo.bar"
|
Object |
onMethodCall(GroovyInterceptor.Invoker invoker,
Object receiver,
String method,
Object... args)
Intercepts an instance method call on some object of the form "foo.bar(...)"
|
Object |
onNewInstance(GroovyInterceptor.Invoker invoker,
Class receiver,
Object... args)
Intercepts an object instantiation, like "new Receiver(...)"
|
Object |
onSetArray(GroovyInterceptor.Invoker invoker,
Object receiver,
Object index,
Object value)
Intercepts an attribute assignment like "foo[bar]=z"
|
Object |
onSetAttribute(GroovyInterceptor.Invoker invoker,
Object receiver,
String attribute,
Object value)
Intercepts an attribute assignment like "foo.@bar=z"
|
Object |
onSetProperty(GroovyInterceptor.Invoker invoker,
Object receiver,
String property,
Object value)
Intercepts a property assignment like "foo.bar=z"
|
Object |
onStaticCall(GroovyInterceptor.Invoker invoker,
Class receiver,
String method,
Object... args)
Intercepts a static method call on some class, like "Class.forName(...)".
|
void |
register()
Registers this interceptor to the current thread's interceptor list.
|
void |
unregister()
Reverses the earlier effect of
register() |
public Object onMethodCall(GroovyInterceptor.Invoker invoker, Object receiver, String method, Object... args) throws Throwable
Throwable
public Object onStaticCall(GroovyInterceptor.Invoker invoker, Class receiver, String method, Object... args) throws Throwable
Class
can invoke static methods, too
(that is, x=Integer.class;x.valueOf(5)
results in onMethodCall(invoker,Integer.class,"valueOf",5)
Throwable
public Object onNewInstance(GroovyInterceptor.Invoker invoker, Class receiver, Object... args) throws Throwable
Throwable
public Object onGetProperty(GroovyInterceptor.Invoker invoker, Object receiver, String property) throws Throwable
receiver
- 'foo' in the above example, the object whose property is accessed.property
- 'bar' in the above example, the name of the propertyThrowable
public Object onSetProperty(GroovyInterceptor.Invoker invoker, Object receiver, String property, Object value) throws Throwable
receiver
- 'foo' in the above example, the object whose property is accessed.property
- 'bar' in the above example, the name of the propertyvalue
- The value to be assigned.value
.Throwable
public Object onGetAttribute(GroovyInterceptor.Invoker invoker, Object receiver, String attribute) throws Throwable
receiver
- 'foo' in the above example, the object whose attribute is accessed.attribute
- 'bar' in the above example, the name of the attributeThrowable
public Object onSetAttribute(GroovyInterceptor.Invoker invoker, Object receiver, String attribute, Object value) throws Throwable
receiver
- 'foo' in the above example, the object whose attribute is accessed.attribute
- 'bar' in the above example, the name of the attributevalue
- The value to be assigned.value
.Throwable
public Object onGetArray(GroovyInterceptor.Invoker invoker, Object receiver, Object index) throws Throwable
receiver
- 'foo' in the above example, the array-like object.index
- 'bar' in the above example, the object that acts as an index.Throwable
public Object onSetArray(GroovyInterceptor.Invoker invoker, Object receiver, Object index, Object value) throws Throwable
receiver
- 'foo' in the above example, the array-like object.index
- 'bar' in the above example, the object that acts as an index.value
- The value to be assigned.value
.Throwable
public void register()
public void unregister()
register()
public static List<GroovyInterceptor> getApplicableInterceptors()
Copyright © 2015. All rights reserved.