@AstTransformer public class ControllerActionTransformer extends java.lang.Object implements AnnotatedClassInjector, GrailsArtefactClassInjector, groovy.transform.CompilationUnitAware
Modifiers | Name | Description |
---|---|---|
static org.codehaus.groovy.ast.AnnotationNode |
ACTION_ANNOTATION_NODE |
|
private static java.lang.String |
ACTION_MEMBER_TARGET |
|
private static java.lang.String |
ALLOWED_METHODS_HANDLED_ATTRIBUTE_NAME |
|
static java.util.regex.Pattern |
CONTROLLER_PATTERN |
|
static java.lang.String |
CONVERT_CLOSURES_KEY |
|
static org.codehaus.groovy.ast.AnnotationNode |
DELEGATING_METHOD_ANNOATION |
|
private static org.codehaus.groovy.ast.expr.TupleExpression |
EMPTY_TUPLE |
|
static java.lang.String |
EXCEPTION_HANDLER_META_DATA_FIELD_NAME |
|
private static org.codehaus.groovy.ast.ClassNode |
OBJECT_CLASS |
|
private static java.util.List<org.codehaus.groovy.ast.ClassNode> |
PRIMITIVE_CLASS_NODES |
|
private static java.util.Map<org.codehaus.groovy.ast.ClassNode, java.lang.String> |
TYPE_WRAPPER_CLASS_TO_CONVERSION_METHOD_NAME |
|
static java.lang.String |
VOID_TYPE |
|
private org.codehaus.groovy.control.CompilationUnit |
compilationUnit |
|
private java.lang.Boolean |
converterEnabled |
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) |
|
private org.codehaus.groovy.ast.stmt.Statement |
addOriginalMethodCall(org.codehaus.groovy.ast.MethodNode methodNode, org.codehaus.groovy.ast.stmt.BlockStatement blockStatement) |
|
protected void |
annotateActionMethod(org.codehaus.groovy.ast.ClassNode controllerClassNode, org.codehaus.groovy.ast.Parameter[] parameters, org.codehaus.groovy.ast.MethodNode methodNode) |
|
public java.lang.Object |
call(java.lang.Object object) |
|
private org.codehaus.groovy.ast.MethodNode |
convertToMethodAction(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.ast.MethodNode methodNode, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) Converts a method into a controller action. |
|
private boolean |
doesModulePathIncludeSubstring(org.codehaus.groovy.ast.ModuleNode moduleNode, java.lang.String substring) Checks to see if a Module is defined at a path which includes the specified substring |
|
public java.lang.String[] |
getArtefactTypes() |
|
protected org.codehaus.groovy.ast.stmt.BlockStatement |
getCodeToHandleAllowedMethods(org.codehaus.groovy.ast.ClassNode controllerClass, java.lang.String methodName) |
|
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.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) |
|
private boolean |
isCommandObjectAction(org.codehaus.groovy.ast.Parameter[] params) |
|
private boolean |
isExceptionHandlingMethod(org.codehaus.groovy.ast.MethodNode methodNode) |
|
protected boolean |
methodShouldBeConfiguredAsControllerAction(org.codehaus.groovy.ast.MethodNode method)
|
|
public void |
performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode) |
|
public void |
performInjection(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode) |
|
public void |
performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode) |
|
public void |
performInjectionOnAnnotatedClass(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.ast.ClassNode classNode) |
|
private void |
processClosures(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
private void |
processMethods(org.codehaus.groovy.ast.ClassNode classNode, org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context) |
|
public void |
setCompilationUnit(org.codehaus.groovy.control.CompilationUnit compilationUnit) |
|
public 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(), java.lang.Object#wait(long), 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() |
Converts a method into a controller action. If the method accepts parameters, a no-arg counterpart is created which delegates to the original.
classNode
- The controller classmethodNode
- The method to be convertedChecks to see if a Module is defined at a path which includes the specified substring
moduleNode
- a ModuleNodesubstring
- The substring to search for
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