<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automatic validation of method calls with JSR-303 (Appendix-C of the specification)</title>
	<atom:link href="http://carinae.net/2010/04/automatic-validation-method-calls-with-jsr-303-appendix-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://carinae.net/2010/04/automatic-validation-method-calls-with-jsr-303-appendix-c/</link>
	<description>Carlos Vara&#039;s writings about software development</description>
	<lastBuildDate>Sat, 17 Mar 2012 14:17:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jonathan</title>
		<link>http://carinae.net/2010/04/automatic-validation-method-calls-with-jsr-303-appendix-c/comment-page-1/#comment-6690</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Fri, 17 Feb 2012 15:59:05 +0000</pubDate>
		<guid isPermaLink="false">http://carinae.net/?p=187#comment-6690</guid>
		<description>Thanks, just what I was looking for. Don&#039;t rely on the join point to get the correct method signature, here how I implemented the aspect method:

Method method = joinPoint.getTarget().getClass().getMethod(methodSignature.getMethod().getName(), methodSignature.getParameterTypes());
 
		Set&lt;? extends ConstraintViolation&gt; validationErrors = getMethodValidator().validateParameters(joinPoint.getTarget().getClass(), method, joinPoint.getArgs());

Spring will return a proxy instead of the real class, plus if you&#039;re using an interface you&#039;ll need to find out the implementation class instead.</description>
		<content:encoded><![CDATA[<p>Thanks, just what I was looking for. Don&#8217;t rely on the join point to get the correct method signature, here how I implemented the aspect method:</p>
<p>Method method = joinPoint.getTarget().getClass().getMethod(methodSignature.getMethod().getName(), methodSignature.getParameterTypes());</p>
<p>		Set&lt;? extends ConstraintViolation&gt; validationErrors = getMethodValidator().validateParameters(joinPoint.getTarget().getClass(), method, joinPoint.getArgs());</p>
<p>Spring will return a proxy instead of the real class, plus if you&#8217;re using an interface you&#8217;ll need to find out the implementation class instead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos Vara</title>
		<link>http://carinae.net/2010/04/automatic-validation-method-calls-with-jsr-303-appendix-c/comment-page-1/#comment-1130</link>
		<dc:creator>Carlos Vara</dc:creator>
		<pubDate>Wed, 17 Nov 2010 22:54:37 +0000</pubDate>
		<guid isPermaLink="false">http://carinae.net/?p=187#comment-1130</guid>
		<description>Unfortunately parameter names are not available at runtime as that information is discarded by the compiler.

As you propose, you can use an annotation to provide that information @Named(&quot;MyParameter&quot;) and then check for the presence of that annotation during the aspect execution (but at it&#039;s current state bval won&#039;t use it when creating the constraint violations).

You can also define specific error messages for each parameter, but that&#039;s probably too verbose.

You should hit apache&#039;s bval jira to see if we can work on something better, as for example knowing the cardinality of the parameter (so for example the constraint violation will indicate that the 2nd argument in your methodcall(string,int) failed) is something worth implementing. https://issues.apache.org/jira/browse/BVAL</description>
		<content:encoded><![CDATA[<p>Unfortunately parameter names are not available at runtime as that information is discarded by the compiler.</p>
<p>As you propose, you can use an annotation to provide that information @Named(&#8220;MyParameter&#8221;) and then check for the presence of that annotation during the aspect execution (but at it&#8217;s current state bval won&#8217;t use it when creating the constraint violations).</p>
<p>You can also define specific error messages for each parameter, but that&#8217;s probably too verbose.</p>
<p>You should hit apache&#8217;s bval jira to see if we can work on something better, as for example knowing the cardinality of the parameter (so for example the constraint violation will indicate that the 2nd argument in your methodcall(string,int) failed) is something worth implementing. <a href="https://issues.apache.org/jira/browse/BVAL" rel="nofollow">https://issues.apache.org/jira/browse/BVAL</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Ey</title>
		<link>http://carinae.net/2010/04/automatic-validation-method-calls-with-jsr-303-appendix-c/comment-page-1/#comment-1118</link>
		<dc:creator>Chris Ey</dc:creator>
		<pubDate>Tue, 16 Nov 2010 14:34:28 +0000</pubDate>
		<guid isPermaLink="false">http://carinae.net/?p=187#comment-1118</guid>
		<description>Hey Carlos

I am using method validation as you proposed for a current project and it is very useful.

There&#039;s just a small - but important - problem: The returned constraint violations do not contain any useful information in their property path. What can I do to identify the parameter which violated its constraint(s), or is it even possible to get its name? For example, could I add an annotation to the parameters specifying a name / property path to use for regarding violations?

Thanks
Chris</description>
		<content:encoded><![CDATA[<p>Hey Carlos</p>
<p>I am using method validation as you proposed for a current project and it is very useful.</p>
<p>There&#8217;s just a small &#8211; but important &#8211; problem: The returned constraint violations do not contain any useful information in their property path. What can I do to identify the parameter which violated its constraint(s), or is it even possible to get its name? For example, could I add an annotation to the parameters specifying a name / property path to use for regarding violations?</p>
<p>Thanks<br />
Chris</p>
]]></content:encoded>
	</item>
</channel>
</rss>

