@AstTransformer public class ControllerActionTransformer extends Object implements AnnotatedClassInjector, GrailsArtefactClassInjector, CompilationUnitAware
Enhances controller classes by converting closures actions to method actions and binding request parameters to action arguments.
Modifiers | Name | Description |
---|---|---|
static AnnotationNode |
ACTION_ANNOTATION_NODE |
|
static Pattern |
CONTROLLER_PATTERN |
|
static String |
CONVERT_CLOSURES_KEY |
|
static AnnotationNode |
DELEGATING_METHOD_ANNOTATION |
|
static String |
EXCEPTION_HANDLER_META_DATA_FIELD_NAME |
|
static String |
VOID_TYPE |
Constructor and description |
---|
ControllerActionTransformer() |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
addMethodToInvokeClosure(ClassNode controllerClassNode, PropertyNode closureProperty, SourceUnit source, GeneratorContext context) |
|
protected void |
annotateActionMethod(ClassNode controllerClassNode, Parameter[] parameters, MethodNode methodNode) |
|
public Object |
call(Object object) |
|
public String[] |
getArtefactTypes() |
|
protected BlockStatement |
getCodeToHandleAllowedMethods(ClassNode controllerClass, String methodName) |
|
protected Collection<MethodNode> |
getExceptionHandlerMethods(ClassNode classNode, SourceUnit sourceUnit) |
|
protected Expression |
getRejectValueExpression(ClassNode classNode, String methodParamName) |
|
protected BlockStatement |
initializeActionParameters(ClassNode classNode, ASTNode actionNode, String actionName, Parameter[] actionParameters, SourceUnit source, GeneratorContext context) |
|
protected void |
initializeAndValidateCommandObjectParameter(BlockStatement wrapper, ClassNode controllerNode, ClassNode commandObjectNode, ASTNode actionNode, String actionName, String paramName, SourceUnit source, GeneratorContext context) |
|
protected void |
initializeCommandObjectParameter(BlockStatement wrapper, ClassNode commandObjectNode, String paramName, SourceUnit source) |
|
protected void |
initializeMethodParameter(ClassNode classNode, BlockStatement wrapper, ASTNode actionNode, String actionName, Parameter param, SourceUnit source, GeneratorContext context) |
|
protected void |
initializePrimitiveOrTypeWrapperParameter(ClassNode classNode, BlockStatement wrapper, Parameter param, String requestParameterName) |
|
protected void |
initializeStringParameter(ClassNode classNode, BlockStatement wrapper, Parameter param, String requestParameterName) |
|
protected boolean |
methodShouldBeConfiguredAsControllerAction(MethodNode method)
|
|
public void |
performInjection(SourceUnit source, GeneratorContext context, ClassNode classNode) |
|
public void |
performInjection(SourceUnit source, ClassNode classNode) |
|
public void |
performInjectionOnAnnotatedClass(SourceUnit source, GeneratorContext context, ClassNode classNode) |
|
public void |
performInjectionOnAnnotatedClass(SourceUnit source, ClassNode classNode) |
|
public void |
setCompilationUnit(CompilationUnit compilationUnit) |
|
public boolean |
shouldInject(URL url) |
|
protected void |
transformClosureToMethod(ClassNode classNode, ClosureExpression closureAction, PropertyNode property, SourceUnit source, GeneratorContext context) |
|
protected void |
wrapMethodBodyWithExceptionHandling(ClassNode controllerClassNode, 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 } } |
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