tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Soto <asot...@gmail.com>
Subject CDI and Produces
Date Wed, 09 Apr 2014 13:23:44 GMT
Hello,

Currently I am developing a demo application I have start playing with
@Produces method and Entity Manager. Let me show the code:

@ApplicationScoped

public class DataSourceProducer {

    @PersistenceContext(unitName = "bank")

    EntityManager em;

    @Produces @BankEntityManager EntityManager entityManager() {

        return this.em;

    }

}


As you can see I have annotated the produced method with a qualifier.


Then I have two Stateless "DAOs":

One that inject entitymanager as:

 @Inject

 @BankEntityManager

 EntityManager em;

and another one that injects as:

@Inject

@MyEnum

 EntityManager em;

Notice that the qualifier is different, but when I run the test the entity
manager is injected inside DAO in both cases. I don't understand why this
happens if @MyEnum annotation is not used as qualifier in any other place
nor in conjunction with @Produces.

Any idea why this happens?

Thank you so much.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message