Supporting @ValidateOnExecution(type = ExecutableType.NONE) on resource methods

21 views
Skip to first unread message

Neil Griffin

unread,
Jan 25, 2019, 5:21:00 PM1/25/19
to MVC 1.0 Users Mailing List
Considering the following resource method:

@Controller
@GET
@View("foo.jsp")
public void prepareView() {
    models.put("greeting", "hello");
}

The KrazoCdiExtension.processAnnotatedType(ProcessAnnotatedType<T> pat) method will automatically add the ValidationInterceptorBinding annotation in order to have the ValidationInterceptor.validateMethodInvocation(InvocationContext) method invoked for controller property validation and controller method parameter validation.

The Bean Validation API has an annotation called javax.validation.executable.ValidateOnExecution which makes it possible to control validation behavior by annotating classes, constructors, and methods. For more information, see:

I would like to propose adding support for @ValidateOnExecution(type = ExecutableType.NONE) on resource methods. For example:

@Controller
@GET
@View("foo.jsp")
@ValidateOnExecution(type = ExecutableType.NONE)
public void prepareView() {
    models.put("greeting", "hello");
}

When present, Krazo would not add the ValidationInterceptorBinding annotation to the method. This would improve performance for execution of resource methods that do not need validation.

Thoughts?

Thanks,

-- Neil

Christian Kaltepoth

unread,
Jan 26, 2019, 12:18:12 AM1/26/19
to MVC 1.0 Users
Hey Neil,

I agree that in case of @ValidateOnExecution(NONE) Krazo doesn't really need to add the ValidationInterceptorBinding annotation. However, AFAIK Bean Validation will still consider it when we use the Bean Validation API to validate the parameters, so the annotation will have the desired effect. I'm not really sure if not adding the binding annotation will have any significant effect on performance. And to be honest, I don't see any real world situation where a developer would use this annotation to disable validation. However, feel free to file a corresponding issue in the Krazo issue tracker. I guess this is the best place to discuss such performance improvements for the RI.

Thanks a lot

Christian

--
You received this message because you are subscribed to the Google Groups "MVC 1.0 Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsr371-users...@googlegroups.com.
To post to this group, send email to jsr371...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsr371-users/f8252db7-420a-48b1-bb24-68f70df255f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Message has been deleted

Neil Griffin

unread,
Feb 1, 2019, 7:17:25 PM2/1/19
to MVC 1.0 Users Mailing List
Hi Christian,

Would the code-snippet I originally posted be considered a typical use-case?

@Controller
@GET
@View("foo.jsp")
public void prepareView() {
    models.put("greeting", "hello");
}

I don't see any benefit to adding the ValidationInterceptorBinding annotation for this type of resource method. If @ValidateOnExecution(NONE) were supported then the application would not suffer any performance impact of invoking bean validation on every GET request that corresponds to the resource method.

Thanks,

Neil

Christian Kaltepoth

unread,
Feb 2, 2019, 5:17:14 AM2/2/19
to MVC 1.0 Users
Hi Neil,

I agree that the current implementation could be optimized for performance. Actually we are in the process of getting Krazo passing the TCK and therefore performance wasn't our top priority. I'm planning to refactor some core parts of Krazo in the next days. One aspect of this refactoring is that there will be a single controller interceptor which will perform various actions (one of them being the validation). Of course, it would make sense to run the bean validation only if required. I'll try to include this improvement in the refactoring.

So stay tuned. :-)

Christian


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages