public class GantMetaClass
extends groovy.lang.DelegatingMetaClass
Closure
s, and any enclosed Closures
.
This metaclass deals with depends
method calls and redirects unknown method calls to the
instance of GantBuilder
. To process the depends
all closures from the
binding called during execution of the Gant specification must be logged so that when a depends happens
the full closure call history is available.
Modifier and Type | Field and Description |
---|---|
private org.codehaus.gant.GantBinding |
binding
The binding (aka global shared state) that is being used.
|
private static java.util.Set<groovy.lang.Closure<?>> |
methodsInvoked
The set of all targets that have been called.
|
Constructor and Description |
---|
GantMetaClass(groovy.lang.MetaClass metaClass,
org.codehaus.gant.GantBinding binding) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
invokeMethod(java.lang.Class sender,
java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object[] arguments,
boolean isCallToSuper,
boolean fromInsideClass)
Invoke a method on the given receiver for the specified arguments.
|
java.lang.Object |
invokeMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object arguments)
Invokes a method on the given object, with the given name and single argument.
|
java.lang.Object |
invokeMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments)
Invokes a method on the given object with the given name and arguments.
|
java.lang.Object |
invokeMethod(java.lang.String name,
java.lang.Object args)
Invoke the given method.
|
private java.lang.Object |
processArgument(java.lang.Object argument)
Process the argument to a
depends call. |
private java.lang.Object |
processClosure(groovy.lang.Closure<?> closure)
Execute a
Closure only if it hasn't been executed previously. |
addMetaBeanProperty, addMetaMethod, addNewInstanceMethod, addNewStaticMethod, equals, getAdaptee, getAttribute, getAttribute, getClassNode, getMetaClass, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getProperties, getProperty, getProperty, getProperty, getStaticMetaMethod, getStaticMetaMethod, getTheClass, hashCode, hasProperty, initialize, invokeConstructor, invokeMissingMethod, invokeMissingProperty, invokeStaticMethod, isGroovyObject, isModified, pickMethod, respondsTo, respondsTo, selectConstructorAndTransformArguments, setAdaptee, setAttribute, setAttribute, setMetaClass, setProperty, setProperty, setProperty, toString
private static final java.util.Set<groovy.lang.Closure<?>> methodsInvoked
GantMetaClass
.
TODO : This code is a long way from thread safe, and so it needs fixing. Should this variable be moved to the GantState class, which is the class that holds other bits of the internal shared state? Should a different data structure be used, one that is a bit more thread safe? Arguably it is reasonable for this to be a synchronized object.
private final org.codehaus.gant.GantBinding binding
public GantMetaClass(groovy.lang.MetaClass metaClass, org.codehaus.gant.GantBinding binding)
private java.lang.Object processClosure(groovy.lang.Closure<?> closure)
Closure
only if it hasn't been executed previously. If it is executed, record
the execution. Only used for processing a depends
call.closure
- The Closure
to potentially call.Closure
call, or null
if the closure was not
called.private java.lang.Object processArgument(java.lang.Object argument)
depends
call. If the parameter is a Closure
just
process it. If it is a String
then do a lookup for the Closure
in the
binding, and if found process it.argument
- The argument.Closure
.public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
MetaClass
will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a
MissingMethodException
will be thrown.invokeMethod
in interface groovy.lang.MetaObjectProtocol
invokeMethod
in class groovy.lang.DelegatingMetaClass
object
- The instance on which the method is invoked.methodName
- The name of the method.arguments
- The arguments to the method.null
if the return type is
void
.MissingMethodException
public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)
invokeMethod
in interface groovy.lang.MetaObjectProtocol
invokeMethod
in class groovy.lang.DelegatingMetaClass
object
- The Object to invoke the method onmethodName
- The name of the methodarguments
- The argument to the methodinvokeMethod(Object, String, Object[])
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
invokeMethod
in interface groovy.lang.GroovyObject
invokeMethod
in class groovy.lang.DelegatingMetaClass
name
- the name of the method to callargs
- the arguments to use for the method callpublic java.lang.Object invokeMethod(java.lang.Class sender, java.lang.Object receiver, java.lang.String methodName, java.lang.Object[] arguments, boolean isCallToSuper, boolean fromInsideClass)
The isCallToSuper
and fromInsideClass
help the Groovy runtime perform
optimizations on the call to go directly to the superclass if necessary.
invokeMethod
in interface groovy.lang.MetaClass
invokeMethod
in class groovy.lang.DelegatingMetaClass
sender
- The java.lang.Class
instance that invoked the method.receiver
- The object which the method was invoked on.methodName
- The name of the method.arguments
- The arguments to the method.isCallToSuper
- Whether the method is a call to a superclass method.fromInsideClass
- Whether the call was invoked from the inside or the outside of the class.