[seam-issues] [JBoss JIRA] Commented: (SEAMVALIDATE-7) ConstraintValidator instances created incorrectly

Gunnar Morling (JIRA) jira-events at lists.jboss.org
Tue Mar 8 18:39:46 EST 2011


    [ https://issues.jboss.org/browse/SEAMVALIDATE-7?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586706#comment-12586706 ] 

Gunnar Morling commented on SEAMVALIDATE-7:
-------------------------------------------

I'm not sure I understand what you mean by "it is not possible for a thirdparty extension to wrap these metadata during container startup". Could you give an example/scenario for this? Would the current approach make certain use cases impossible, or is this more a performance related issue (repeated retrieval of meta data etc.)?

I already tested the suggested version and it works as expected, I just want to make sure I know what's going on :-)

> 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