public class ProxyGenerator
extends Object
Generates 'Proxy' objects which implement interfaces, maps of closures and/or extend classes/delegates.
| Modifiers | Name | Description |
|---|---|---|
static ProxyGenerator |
INSTANCE |
Shared proxy generator instance used by Groovy's coercion helpers. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
getDebug()Reports whether generated source is echoed for debugging. |
|
public boolean |
getEmptyMethods()Reports whether unimplemented generated methods use empty bodies. |
|
public ClassLoader |
getOverride()Returns the override class loader used for proxy generation. |
|
public GroovyObject |
instantiateAggregate(List<Class> interfaces)Creates an aggregate proxy implementing the supplied interfaces. |
|
public GroovyObject |
instantiateAggregate(Map closureMap, List<Class> interfaces)Creates an aggregate proxy implementing the supplied interfaces. |
|
public GroovyObject |
instantiateAggregate(Map closureMap, List<Class> interfaces, Class clazz)Creates an aggregate proxy with optional interfaces and base class. |
|
public GroovyObject |
instantiateAggregate(Map closureMap, List<Class> interfaces, Class clazz, Object[] constructorArgs)Creates an aggregate proxy with optional interfaces, base class and constructor arguments. |
|
public GroovyObject |
instantiateAggregateFromBaseClass(Class clazz)Creates an aggregate proxy that extends the supplied base class. |
|
public GroovyObject |
instantiateAggregateFromBaseClass(Map map, Class clazz)Creates an aggregate proxy that extends the supplied base class. |
|
public GroovyObject |
instantiateAggregateFromBaseClass(Closure cl, Class clazz)Creates an aggregate proxy that routes all unresolved methods through one closure. |
|
public GroovyObject |
instantiateAggregateFromBaseClass(Class clazz, Object[] constructorArgs)Creates an aggregate proxy with constructor arguments. |
|
public GroovyObject |
instantiateAggregateFromBaseClass(Map map, Class clazz, Object[] constructorArgs)Creates an aggregate proxy with closures and constructor arguments. |
|
public GroovyObject |
instantiateAggregateFromInterface(Class clazz)Creates an aggregate proxy that implements a single interface. |
|
public GroovyObject |
instantiateAggregateFromInterface(Map map, Class clazz)Creates an aggregate proxy that implements a single interface. |
|
public GroovyObject |
instantiateDelegate(Object delegate)Creates a delegating proxy around the supplied object. |
|
public GroovyObject |
instantiateDelegate(List<Class> interfaces, Object delegate)Creates a delegating proxy with additional implemented interfaces. |
|
public GroovyObject |
instantiateDelegate(Map closureMap, List<Class> interfaces, Object delegate)Creates a delegating proxy with supplemental closure implementations. |
|
public GroovyObject |
instantiateDelegateWithBaseClass(Map closureMap, List<Class> interfaces, Object delegate)Creates a delegating proxy whose base class is the delegate type. |
|
public GroovyObject |
instantiateDelegateWithBaseClass(Map closureMap, List<Class> interfaces, Object delegate, Class baseClass)Creates a delegating proxy with an explicit base class. |
|
public GroovyObject |
instantiateDelegateWithBaseClass(Map closureMap, List<Class> interfaces, Object delegate, Class baseClass, String name)Creates a proxy with a delegate object. |
|
public void |
setDebug(boolean debug)Instructs ProxyGenerator to dump generated Groovy
source code to standard output during construction. |
|
public void |
setEmptyMethods(boolean emptyMethods)Changes generated methods to have empty implementations. |
|
public void |
setOverride(ClassLoader override)Sets the override class loader used for proxy generation. |
Shared proxy generator instance used by Groovy's coercion helpers.
Reports whether generated source is echoed for debugging.
true when debug output is enabledReports whether unimplemented generated methods use empty bodies.
true when empty method bodies are generatedReturns the override class loader used for proxy generation.
nullCreates an aggregate proxy implementing the supplied interfaces.
interfaces - interfaces to implementCreates an aggregate proxy implementing the supplied interfaces.
closureMap - closures implementing selected methodsinterfaces - interfaces to implementCreates an aggregate proxy with optional interfaces and base class.
closureMap - closures implementing selected methodsinterfaces - interfaces to implementclazz - the base class to extendCreates an aggregate proxy with optional interfaces, base class and constructor arguments.
closureMap - closures implementing selected methodsinterfaces - interfaces to implementclazz - the base class to extendconstructorArgs - constructor arguments for the proxy instanceCreates an aggregate proxy that extends the supplied base class.
clazz - the base class to extendCreates an aggregate proxy that extends the supplied base class.
map - closures implementing selected methodsclazz - the base class to extendCreates an aggregate proxy that routes all unresolved methods through one closure.
cl - fallback closure for method callsclazz - the base class to extendCreates an aggregate proxy with constructor arguments.
clazz - the base class to extendconstructorArgs - constructor arguments for the proxy instanceCreates an aggregate proxy with closures and constructor arguments.
map - closures implementing selected methodsclazz - the base class to extendconstructorArgs - constructor arguments for the proxy instanceCreates an aggregate proxy that implements a single interface.
clazz - the interface to implementCreates an aggregate proxy that implements a single interface.
map - closures implementing selected methodsclazz - the interface to implementCreates a delegating proxy around the supplied object.
delegate - the delegate objectCreates a delegating proxy with additional implemented interfaces.
interfaces - interfaces to implementdelegate - the delegate objectCreates a delegating proxy with supplemental closure implementations.
closureMap - closures implementing selected methodsinterfaces - interfaces to implementdelegate - the delegate objectCreates a delegating proxy whose base class is the delegate type.
closureMap - closures implementing selected methodsinterfaces - interfaces to implementdelegate - the delegate objectCreates a delegating proxy with an explicit base class.
closureMap - closures implementing selected methodsinterfaces - interfaces to implementdelegate - the delegate objectbaseClass - the base class to extendCreates a proxy with a delegate object.
closureMap - the closure for methods not handled by the delegateinterfaces - interfaces to be implementeddelegate - the delegate objectbaseClass - the base classname - the name of the proxy, unused, but kept for compatibility with previous versions of Groovy. Instructs ProxyGenerator to dump generated Groovy
source code to standard output during construction. This is useful
for debugging purposes but should be turned off in production.
debug - true if you want generated source to be printedChanges generated methods to have empty implementations.
Methods in generated aggregates not supplied in a closures map or
base class are given 'default' implementations. The implementation
will normally throw an UnsupportedOperationException
but setting this boolean will leave it empty.
emptyMethods - true if you want generated methods to be emptySets the override class loader used for proxy generation.
override - the override class loader