[cdi-dev] @New and producer methods/fields
Pete Muir
pmuir at redhat.com
Sun Sep 25 15:56:46 EDT 2011
Section 3.12 states "For each managed bean, and for each session bean, a second bean exists which:"
So, there are no @New beans for producers.
What is the use case you are trying to address?
On 24 Sep 2011, at 11:35, Mark Struberg wrote:
> Hi folks!
>
> We recently talked about ways to properly destroy beans which got created via Instance or @New.
> I just realized that only having
> @Inject @New MyClass dings;
> might not be enough.
>
> Imagine you have 2 producer methods which create EntityManagers
>
> public class EntityManagerProducer {
> @Produces @RequestScoped @UserDb
> public void createUserDbEm() {
> return entityManagerFactory.createEntityManager("userdb");
> }
>
> @Produces @RequestScoped @AdminDb
> public void createAdminDbEm() {
> return entityManagerFactory.createEntityManager("admindb");
> }
> }
>
> If I need a 'temporarily self managed' userdb EntityManager, I cannot just
> type
> @Inject @New @UserDb EntityManager userDbEm;
> because according to the spec there is only 1 Bean with exactly @New (and none with additional @UserDb)
> The @New is basically useless for producer methods, isn't?
>
> Do we like to address this somehow?
>
> LieGrie,
> strub
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
More information about the cdi-dev
mailing list