Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 58511 invoked from network); 22 Nov 2010 20:10:32 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Nov 2010 20:10:32 -0000 Received: (qmail 76960 invoked by uid 500); 22 Nov 2010 20:11:03 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 76913 invoked by uid 500); 22 Nov 2010 20:11:02 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 76906 invoked by uid 99); 22 Nov 2010 20:11:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Nov 2010 20:11:02 +0000 X-ASF-Spam-Status: No, hits=3.5 required=10.0 tests=FREEMAIL_FROM,HTML_IMAGE_ONLY_24,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rdebusscher@gmail.com designates 209.85.213.181 as permitted sender) Received: from [209.85.213.181] (HELO mail-yx0-f181.google.com) (209.85.213.181) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Nov 2010 20:10:57 +0000 Received: by yxd39 with SMTP id 39so1423947yxd.12 for ; Mon, 22 Nov 2010 12:10:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:x-goomoji-body :date:message-id:subject:from:to:content-type; bh=HXARrTB/Hnn89iAbPg6cdAaI1Uc8LWOIKF5w1Zue7oE=; b=S2/k2vluzlEKET/LcPbDRV1HfOpm9t+iOZJJDkGgJPQSzR8H0kZ1UJlYy91cMBzRVv s9Kh2LQNYrq9VEWY01KJ3M+f8jT/NcsJ0NkJplCk2tG5FfFVKT9HfSkDVCFnuQSAYXWn Lla0ctVtqg2TTNmkdHq0PpJitdrz1xNjeZ8ko= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:x-goomoji-body:date:message-id:subject:from:to :content-type; b=RJ3P+QGo6se/ZtGbnt5GqWNsl0AFr2UuIVL1Nk9BN6L4g0cqmfA/n13XUiKQOzvXz6 tofOYPOeZWU78ZAvEekb+VYuoKvew0q8xcuekCJtuTlYxHJ6DLkvWgd79EEpRZLkrILT u97f6T6BeMZCu42RS1z4yvivBUakCjIh4cMFM= MIME-Version: 1.0 Received: by 10.204.124.6 with SMTP id s6mr6008023bkr.117.1290456628437; Mon, 22 Nov 2010 12:10:28 -0800 (PST) Received: by 10.204.22.11 with HTTP; Mon, 22 Nov 2010 12:10:23 -0800 (PST) X-Goomoji-Body: true Date: Mon, 22 Nov 2010 21:10:23 +0100 Message-ID: Subject: [Codi] Idea for new functionality: method parameter validation From: Rudy De Busscher To: MyFaces Development Content-Type: multipart/related; boundary=0016368e3277f0e7630495a9d843 --0016368e3277f0e7630495a9d843 Content-Type: multipart/alternative; boundary=0016368e3277f0e75d0495a9d842 --0016368e3277f0e75d0495a9d842 Content-Type: text/plain; charset=ISO-8859-1 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. --0016368e3277f0e75d0495a9d842 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi all,

BeanValidation is promoted as THE validation framework in the EE environment. =A0it can already be used in JPA and JSF. =A0In th= e future they plan to have it also in other areas like JAX-RS.

Anoth= er area where we could start using it, is with CDI. =A0With the creation of= an Interceptor, it is possible to develop a mechanism that allow validatio= n of method parameter values.

Aparently Apache BVal is taking this up (thx Gerhard for the input, see= here http://carinae.net/2010/04/automatic-validatio= n-method-calls-with-jsr-303-appendix-c/ ), but a generic solution could= be made available in Codi. =A0Since there is no method forseen in the Bean= Validation spec to validate a value based on an annotation (only methods fo= r 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

= =A0 =A0@ParameterValidation
=A0 =A0public String sayHelloMinimumLength(= @Size(min =3D 3) String name) {
=A0 =A0 =A0 =A0return "Hello "= ;+name;
=A0 =A0}

=A0 =A0@ParameterValidation
=A0 =A0public String sayHello(@NotNull= @Valid Person person) {
=A0 =A0 =A0 =A0return "Hello "+perso= n.getLastName();
=A0 =A0}


And I did some small (but successf= ul) tests in the following environments
- Plain SE (JUnit tests)
- Tomcat 6
- JBoss 6 (M5)

The perform= ance is also acceptable. =A0Executing 1000 tests on the sayHelloMinimumLeng= th method as described above, adds about 300 ms (in total, so 0.3 ms per ca= ll).

So with this message I would like to have the opinion of the community = about adding such functionality to Codi. =A0I think we have 3 options:
<= br>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. <= img goomoji=3D"gtalk.330" style=3D"margin: 0pt 0.2ex; vertical-align: middl= e;" src=3D"cid:gtalk.330@goomoji.gmail">

If you like the idea, I do some further work on the code an supply a pa= tch or the add-on.

Regards
Rudy.

--0016368e3277f0e75d0495a9d842-- --0016368e3277f0e7630495a9d843 Content-Type: image/png; name="330.png" Content-Transfer-Encoding: base64 X-Attachment-Id: gtalk.330@goomoji.gmail Content-ID: iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABGdBTUEAANbY1E9YMgAAAhpJREFU KFNdUt9Lk2EU/q6l9VXbnP1Qu4i6yD8gXKOLwCySQZi5EMQI06gGdiku6K7UvvzRMMLWZXUZYfZD WHURXVQQ5pqrdIaUa6hlQ8bZ9z6d835sq154+M573vO85znP9xoAjCLI2uyhftd5/j6kG74URX2f OJ7gXA9/fX/XlkmD5uG+xopcoM6FtqYaIN2u0dZUi0DdRkSOVKzTgHnsHyKTGunm9vUGvw93xw8h k+yAWurSkFhyDf4qFG5VE9cGNZEluGnIvahmjgOrEeDXPWDtAfC904HEklvtg0q2goa9WeZsNVj/ BXtyH7B8DlA5xGIxWJYFZC9rlPZ8JjX2Uz+Y0ysdH6kPzVx0FrJM02QdhtOFUdrL+tHtdB1yPzfY vc/aiEyXPguHwwgGeYyfMY3SXtbSGeBrB2hs27xB0aoycXkAyCeB3LPyjBJLTs408ZQQ0yL1sTYm 242Fyf1lwn/QZyJ1Vkt9Keb02E/q9eDvxnZi+s5ufIsfxNp0s4bEknsbrXbMmQqIOZeko5dGPGnp mp9vR3qiHu/Hd+FVvwevByt1LLn8Av/b1EnQiHeFrm3a4TyAKxsuFu7vBVb4Rp6VFk/j90yLhsS2 SEyFULhdq/j1tApHOu6hYU9CvTkKlWiBHT8A9fGEdk+gZkOOvFFvhkkhIRWJnTRameDb0nR9ywu6 6rJ4+Cl27gtjjuM4zxRheTVFkuAPpRIkcs7CiskAAAAASUVORK5CYII= --0016368e3277f0e7630495a9d843--