1 package info.ejava.examples.ejb.cdisales.dao;
2
3 import javax.enterprise.context.Dependent;
4 import javax.enterprise.inject.Produces;
5 import javax.persistence.EntityManager;
6 import javax.persistence.PersistenceContext;
7 import javax.validation.Validator;
8
9 public class DAOFactory {
10 @PersistenceContext(unitName="ejbcdi-sales")
11 @Produces
12 public EntityManager em;
13
14 @Produces
15 @Dependent
16 public UserMgmtDAO getUserMgmtDAO(EntityManager em, Validator validator) {
17 UserMgmtDAO dao = new UserMgmtDAO();
18 dao.setEntityManager(em);
19 dao.setValidator(validator);
20 return dao;
21 }
22 }