[cdi-dev] [JBoss JIRA] (CDI-328) SPI for creating producers broken

Pete Muir (JIRA) jira-events at lists.jboss.org
Fri Mar 1 11:22:56 EST 2013

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

Pete Muir commented on CDI-328:

[~arnelim] I thought about this when I did the initial work, and decided I prefer get to create here, but it isn't a strong preference!

To me, create suggests that the container *will always* create a new factory when you call the method, whereas get implies that the container may well return a cached version if it wants to. 
> SPI for creating producers broken
> ---------------------------------
>                 Key: CDI-328
>                 URL: https://issues.jboss.org/browse/CDI-328
>             Project: CDI Specification Issues
>          Issue Type: Bug
>          Components: Portable Extensions
>    Affects Versions: 1.1.PFD
>            Reporter: Jozef Hartinger
>            Priority: Blocker
>             Fix For: 1.1.FD
> CDI-268 introduces a set of factories to deal with the chicken-egg problem when creating Beans and Producers/InjectionTargets.
> Unlike InjectionTargetFactory, the ProducerFactory interface does not address the problem properly.
> In order to create a Producer implementation for a producer field/method, the following ingredients are needed:
> * an AnnotatedField / AnnotatedMethod
> * a declaring bean (bean for the class the producer field/method is declared on - the field/method is invoked on instances of the declaring bean) . Declaring bean does not need to be specified if the field/method is static
> * bean for which the producer is created - this is needed in order for Producer.getInjectionPoints.getBean() to return the right thing. The bean is optional an may not be specified if the Producer is created for a non-contextual object
> The following (slightly modified) SPI should handle all the requirements:
> {noformat}
> public interface ProducerFactory<X> {
>     public <T> Producer<T> createProducer(Bean<T> bean);
> }
> {noformat}
> {noformat}
> public interface BeanManager {
>     public <X> ProducerFactory<X> getProducerFactory(AnnotatedField<? super X> field, Bean<X> declaringBean);
>     public <X> ProducerFactory<X> getProducerFactory(AnnotatedMethod<? super X> method, Bean<X> declaringBean);
>     public <T, X> Bean<T> createBean(BeanAttributes<T> attributes, Class<X> beanClass, ProducerFactory<X> producerFactory);
> }
> {noformat}
> Notice the additional *declaringBean* parameter for getProducerFactory() and modified type parameters in createBean() and ProducerFactory.

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

More information about the cdi-dev mailing list