[
https://issues.jboss.org/browse/SEAMVALIDATE-7?page=com.atlassian.jira.pl...
]
Gunnar Morling commented on SEAMVALIDATE-7:
-------------------------------------------
Jozef,
thanks for your clear explanation, that definitly makes sense. I tried out your approach
and saw that it only works for constraint validator types defined in a BDA (which is to be
expected of course as types not defined in a BDA won't be processed by the CDI
container).
So for other constraint validators (for example the ones defined by Hibernate Validator
itself which does not come in form of a BDA) I'll fall back to the standard factory.
That means that for validators not defined in a BDA injection won't work (opposed to
the current implementation where this is possible as the meta data is retrieved locally in
the factory), but this just seems logical to me. WDYT?
ConstraintValidator instances created incorrectly
-------------------------------------------------
Key: SEAMVALIDATE-7
URL:
https://issues.jboss.org/browse/SEAMVALIDATE-7
Project: Seam Validation
Issue Type: Bug
Affects Versions: 3.0.0.CR1
Reporter: Jozef Hartinger
Assignee: Gunnar Morling
Priority: Critical
Fix For: 3.0.0.Final
The current way of creating a ConstraintValidator instance is not correct:
{code}
AnnotatedType<T> type = beanManager.createAnnotatedType(key);
InjectionTarget<T> it = beanManager.createInjectionTarget(type);
CreationalContext<T> ctx = beanManager.createCreationalContext(null);
T instance = it.produce(ctx);
it.inject(instance, ctx);
it.postConstruct(instance);
return instance;
{code}
Since an AnnotatedType and InjectionTarget are created for every ConstraintValidator
creation, it is not possible for a thirdparty extension to wrap these metadata during
container startup. The correct way of creating a ConstraintValidator instance would be:
{code}
Set<Bean<?>> beans = beanManager.getBeans(key);
Bean<?> bean = beanManager.resolve(beans);
CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
return (T) beanManager.getReference(bean, key, ctx);
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira