[
https://issues.apache.org/jira/browse/BVAL-114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jarek Gawor updated BVAL-114:
-----------------------------
Attachment: BVAL-114.patch
I attached a proposed patch to ApacheValidatorFactory.java that creates a
single ApacheFactoryContext that's used in getValidator() call. That enables
the MetaBeanFinder and its cache to be shared between getValidator() calls.
> ApacheValidatorFactory.getValidator() caching
> ---------------------------------------------
>
> Key: BVAL-114
> URL: https://issues.apache.org/jira/browse/BVAL-114
> Project: BVal
> Issue Type: Improvement
> Components: jsr303
> Affects Versions: 0.4, 0.5
> Reporter: Jarek Gawor
> Attachments: BVAL-114.patch
>
>
> We have a piece of code that's essentially doing:
> ValidatorFactory factory = ....;
> for (...) {
> Foo foo = ...;
> factory.getValidator().validate(foo);
> }
> With this pattern the Foo class is scanned for annotations on each loop
> iteration. The problem is that each getValidator() invocation on the same
> factory instance create a separate ApacheFactoryContext instance with own
> MetaBeanFinder. Therefore, the cache in MetaBeanFinder doesn't really get
> reused between loop iterations.
> One obvious solution is to use the same Validator object instance in the
> loop. However, in certain situations it might not be easy to change the code
> pattern in that way. So, I'm wondering whether getValidator() can be
> optimized in such a way that the MetaBeanFinder (and therefore its cache) can
> be reused between calls. From JavaDoc it sounds like some sort of caching
> might be allowed.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira