[JBoss JIRA] (CDI-332) Broken example for obtaining unmanaged instance
by Martin Kouba (JIRA)
Martin Kouba created CDI-332:
--------------------------------
Summary: Broken example for obtaining unmanaged instance
Key: CDI-332
URL: https://issues.jboss.org/browse/CDI-332
Project: CDI Specification Issues
Issue Type: Bug
Affects Versions: 1.1.PFD
Reporter: Martin Kouba
Priority: Minor
The example in the spec text and javadoc:
{code}
Unmanaged unmanagedFoo = new Unmanaged(Foo.class);
UnmanagedInstance fooInstance = unManagedFoo.newInstance();
Foo foo = fooInstance.produce().inject().postConstruct();
// Use the foo instance
fooInstance.preDestroy().dispose();
{code}
should be replaced with something like this:
{code}
Unmanaged<Foo> unmanagedFoo = new Unmanaged<Foo>(Foo.class);
UnmanagedInstance<Foo> fooInstance = unmanagedFoo.newInstance();
Foo foo = fooInstance.produce().inject().postConstruct().get();
// Use the foo instance
fooInstance.preDestroy().dispose();
{code}
Note the generics, unManagedFoo -> unmanagedFoo and missing {{get()}}.
--
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
12 years, 9 months
[JBoss JIRA] (CDI-328) SPI for creating producers broken
by Jozef Hartinger (JIRA)
[ https://issues.jboss.org/browse/CDI-328?page=com.atlassian.jira.plugin.sy... ]
Jozef Hartinger commented on CDI-328:
-------------------------------------
The spec says:
{quote}
Create a new injection target for a bean.
and
Create a new producer for a bean.
{quote}
I find the intention to be clear for the implementation to always create a new (non-cached) Producer/InjectionTarget. What may be cached are the factory instances themselves though whether or not these factories are cached should not have any impact on the created Producer/InjectionTarget instances.
> 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
12 years, 9 months
[JBoss JIRA] (CDI-331) Clarify Instance.iterator()
by Jozef Hartinger (JIRA)
Jozef Hartinger created CDI-331:
-----------------------------------
Summary: Clarify Instance.iterator()
Key: CDI-331
URL: https://issues.jboss.org/browse/CDI-331
Project: CDI Specification Issues
Issue Type: Clarification
Components: Resolution
Affects Versions: 1.1.PRD
Reporter: Jozef Hartinger
Assignee: Pete Muir
Fix For: 1.1.FD
The specification currently says that:
{quote}
The iterator() method must:
• Identify the set of beans that have the required type and required qualifiers and are eligible for injection into the class into
which the parent Instance was injected, according to the rules of typesafe resolution, as defined in Section 5.2.1.
{quote}
The question that arises is whether the implementation should apply ambiguity resolution algorithm as defined in 5.2.2 or not.
This is explicitly required for get() but is not required for iterator(). This causes the following inconsistency:
Assume two classes Foo and Bar which both implement common interface Common. Bar is an enabled alternative.
Assume further the following
{noformat}
@Inject @Any Instance<Common> instance
{noformat}
injection point.
It is clear that instance.get() returns Bar.
It is however not clear whether instance.iterator() iterates over:
a) Bar
b) Foo, Bar
and whether instance.isAmbiguous() returns:
a) true
b) false
--
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
12 years, 9 months
[JBoss JIRA] (CDI-328) SPI for creating producers broken
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-328?page=com.atlassian.jira.plugin.sy... ]
Mark Struberg commented on CDI-328:
-----------------------------------
In fact we need to define the caching behaviour spot on for all kinds of those factory methods. Reminds me of the discussion about whether createAnnotatedType(Class<?>) shall reflect all the changes done in Extensions or not.
> 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
12 years, 9 months
[JBoss JIRA] (CDI-330) BeforeBeanDiscovery.addAnnotatedType(type) should be deprecated
by Jozef Hartinger (JIRA)
Jozef Hartinger created CDI-330:
-----------------------------------
Summary: BeforeBeanDiscovery.addAnnotatedType(type) should be deprecated
Key: CDI-330
URL: https://issues.jboss.org/browse/CDI-330
Project: CDI Specification Issues
Issue Type: Bug
Components: Portable Extensions
Affects Versions: 1.1.PFD
Reporter: Jozef Hartinger
Assignee: Pete Muir
Fix For: 1.1.FD
as BeforeBeanDiscovery.addAnnotatedType(type, id) has been added which solves the problem with multiple AnnotatedTypes per Java class.
--
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
12 years, 9 months