I find the idea good if it gets applied dynamically (without having to annotate it). Otherwise I just prefer commons.lang.validate.Validate ;)
LieGrue, strub --- On Mon, 11/22/10, Jakob Korherr <[email protected]> wrote: From: Jakob Korherr <[email protected]> Subject: Re: [Codi] Idea for new functionality: method parameter validation To: "MyFaces Development" <[email protected]> Date: Monday, November 22, 2010, 9:01 PM ... sorry.. I meant "CODI and ext-val". 2010/11/22 Jakob Korherr <[email protected]> Hi Rudy, Nice idea! If we don't want to put it directly into CODI, we could create a CODI add-on for it in ext-val, because CODI and ext-cdi kinda overlap here. Regards, Jakob 2010/11/22 Gerhard <[email protected]> hi rudy, basically it's a nice idea.for further discussions we would need your implementation. regards,gerhard http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2010/11/22 Rudy De Busscher <[email protected]> Hi all, BeanValidation is promoted as THE validation framework in the EE environment. it can already be used in JPA and JSF. In the future they plan to have it also in other areas like JAX-RS. Another area where we could start using it, is with CDI. With the creation of an Interceptor, it is possible to develop a mechanism that allow validation of method parameter values. Aparently Apache BVal is taking this up (thx Gerhard for the input, see here http://carinae.net/2010/04/automatic-validation-method-calls-with-jsr-303-appendix-c/ ), but a generic solution could be made available in Codi. Since there is no method forseen in the BeanValidation spec to validate a value based on an annotation (only methods for validating a property within a class or a complete object), I was forced to create a hack with dynamically created classes. But in a POC I was able to use the following declarations �...@parametervalidation public String sayHelloMinimumLength(@Size(min = 3) String name) { return "Hello "+name; } �...@parametervalidation public String sayHello(@NotNull @Valid Person person) { return "Hello "+person.getLastName(); } And I did some small (but successful) tests in the following environments - Plain SE (JUnit tests) - Tomcat 6 - JBoss 6 (M5) The performance is also acceptable. Executing 1000 tests on the sayHelloMinimumLength method as described above, adds about 300 ms (in total, so 0.3 ms per call). So with this message I would like to have the opinion of the community about adding such functionality to Codi. I think we have 3 options: 1) Add it to Codi itself (I think the BV module is the best candidate) 2) Put the logic in an add-on because it is useful but not all projects can/will use it. 3) Spend our time to other topics because it is useless. If you like the idea, I do some further work on the code an supply a patch or the add-on. Regards Rudy. -- Jakob Korherr blog: http://www.jakobk.com twitter: http://twitter.com/jakobkorherr work: http://www.irian.at -- Jakob Korherr blog: http://www.jakobk.com twitter: http://twitter.com/jakobkorherr work: http://www.irian.at
