@AstTransformer public class ControllerActionTransformer extends java.lang.Object
Enhances controller classes by converting closures actions to method actions and binding request parameters to action arguments.
Modifiers | Name | Description |
---|---|---|
static org.codehaus.groovy.ast.AnnotationNode |
ACTION_ANNOTATION_NODE |
|
static java.lang.String |
EXCEPTION_HANDLER_META_DATA_FIELD_NAME |
|
static java.lang.String |
VOID_TYPE |
Constructor and description |
---|
ControllerActionTransformer
() |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
addMethodToInvokeClosure(org.codehaus.groovy.ast.ClassNode controllerClassNode, org.codehaus.groovy.ast.PropertyNode closureProperty, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
protected void |
annotateActionMethod(org.codehaus.groovy.ast.ClassNode controllerClassNode, org.codehaus.groovy.ast.Parameter[] parameters, org.codehaus.groovy.ast.MethodNode methodNode) |
|
java.lang.String[] |
getArtefactTypes() |
|
protected org.codehaus.groovy.ast.stmt.BlockStatement |
getCodeToHandleAllowedMethods(org.codehaus.groovy.ast.ClassNode controllerClass, java.lang.String methodName) |
|
protected org.codehaus.groovy.ast.stmt.BlockStatement |
getCodeToInitializeCommandObjects(org.codehaus.groovy.ast.ASTNode actionNode, java.lang.String actionName, org.codehaus.groovy.ast.Parameter[] parameters, org.codehaus.groovy.ast.ClassNode controllerNode, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
protected java.util.Collection<org.codehaus.groovy.ast.MethodNode> |
getExceptionHandlerMethods(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit sourceUnit) |
|
protected org.codehaus.groovy.ast.MethodNode |
getMethodToIncludeCommandObjectInitializationCode(org.codehaus.groovy.ast.MethodNode methodNode) |
|
protected org.codehaus.groovy.ast.expr.Expression |
getRejectValueExpression(org.codehaus.groovy.ast.ClassNode classNode, java.lang.String methodParamName) |
|
protected org.codehaus.groovy.ast.stmt.BlockStatement |
initializeActionParameters(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.ASTNode actionNode, java.lang.String actionName, org.codehaus.groovy.ast.Parameter[] actionParameters, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
protected void |
initializeAndValidateCommandObjectParameter(org.codehaus.groovy.ast.stmt.BlockStatement wrapper, org.codehaus.groovy.ast.ClassNode controllerNode, org.codehaus.groovy.ast.ClassNode commandObjectNode, org.codehaus.groovy.ast.ASTNode actionNode, java.lang.String actionName, java.lang.String paramName, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
protected void |
initializeCommandObjectParameter(org.codehaus.groovy.ast.stmt.BlockStatement wrapper, org.codehaus.groovy.ast.ClassNode commandObjectNode, java.lang.String paramName, org.codehaus.groovy.control.SourceUnit source) |
|
protected void |
initializeMethodParameter(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.stmt.BlockStatement wrapper, org.codehaus.groovy.ast.ASTNode actionNode, java.lang.String actionName, org.codehaus.groovy.ast.Parameter param, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
protected void |
initializePrimitiveOrTypeWrapperParameter(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.stmt.BlockStatement wrapper, org.codehaus.groovy.ast.Parameter param, java.lang.String requestParameterName) |
|
protected void |
initializeStringParameter(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.stmt.BlockStatement wrapper, org.codehaus.groovy.ast.Parameter param, java.lang.String requestParameterName) |
|
protected boolean |
isCommandObjectType(org.codehaus.groovy.ast.ClassNode paramTypeClassNode) |
|
protected boolean |
methodShouldBeConfiguredAsControllerAction(org.codehaus.groovy.ast.MethodNode method) @param method a potential controller action method |
|
void |
performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode) |
|
void |
performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode) |
|
void |
performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode) |
|
void |
performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode) |
|
protected void |
populateMethodWithCommandObjectInitializationCode(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
boolean |
shouldInject(java.net.URL url) |
|
protected void |
transformClosureToMethod(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.expr.ClosureExpression closureAction, org.codehaus.groovy.ast.PropertyNode property, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
protected void |
wrapMethodBodyWithExceptionHandling(org.codehaus.groovy.ast.ClassNode controllerClassNode, org.codehaus.groovy.ast.MethodNode methodNode) This will wrap the method body in a try catch block which does something like this: try { // original method body here } catch (Exception $caughtException) { Method $method = getExceptionHandlerMethod($caughtException.getClass()) if($method) { return $method.invoke(this, $caughtException) } else { throw $caughtException } } |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
method
- a potential controller action methodThis will wrap the method body in a try catch block which does something like this:
try { // original method body here } catch (Exception $caughtException) { Method $method = getExceptionHandlerMethod($caughtException.getClass()) if($method) { return $method.invoke(this, $caughtException) } else { throw $caughtException } }
methodNode
- the method to add the try catch block to