I am trying to get the arguments of a grails controller method using the annotation and Aspect that is executed before the method. The aspect handler executes correctly, but I cannot access the argument (which implements grails.validation.Validateable ), the argument list is empty.
experiment.aspect.validated
package experiment.aspect import java.lang.annotation.ElementType import java.lang.annotation.Retention import java.lang.annotation.RetentionPolicy import java.lang.annotation.Target @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @interface Validated { }
experiment.aspect.ValidatedAspect
package experiment.aspect import grails.validation.ValidationException import org.aspectj.lang.JoinPoint import org.aspectj.lang.annotation.Aspect import org.aspectj.lang.annotation.Before @Aspect class ValidatedAspect { @Before("@annotation(experiment.aspect.Validated)") public void preValidate(JoinPoint point) throws ValidationException{ println "parameters ${point.getArgs()}" } }
conf.spring.resources
import experiment.aspect.ValidatedAspect
controllers.experiment.TestController
package experiment import experiment.aspect.Validated class TestController extends BaseController { static responseFormats = ['json'] @Validated def login(LoginCommand loginCommand){ println "Validated" ... } }
experiment.LoginCommand
package experiment import grails.validation.Validateable class LoginCommand implements Validateable {
I get the following output, which means that the aspect handler method is executed before the controller method, but it does not receive arguments.
parameters [] Validated
source share