[seam-issues] [JBoss JIRA] Work started: (SEAMVALIDATE-7) ConstraintValidator instances created incorrectly
Gunnar Morling (JIRA)
jira-events at lists.jboss.org
Sat Mar 5 11:27:45 EST 2011
[ https://issues.jboss.org/browse/SEAMVALIDATE-7?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Work on SEAMVALIDATE-7 started by Gunnar Morling.
> 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
More information about the seam-issues
mailing list