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(...)".
|
Object |
onSuperCall(GroovyInterceptor.Invoker invoker,
Class senderType,
Object receiver,
String method,
Object... args)
Intercepts an super method call, like "super.foo(...)"
|
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
Throwablepublic 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)Throwablepublic Object onNewInstance(GroovyInterceptor.Invoker invoker, Class receiver, Object... args) throws Throwable
Throwablepublic Object onSuperCall(GroovyInterceptor.Invoker invoker, Class senderType, Object receiver, String method, Object... args) throws Throwable
Throwablepublic 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 propertyThrowablepublic 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.Throwablepublic 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 attributeThrowablepublic 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.Throwablepublic 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.Throwablepublic 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.Throwablepublic void register()
public void unregister()
register()public static List<GroovyInterceptor> getApplicableInterceptors()
Copyright © 2016. All Rights Reserved.