1 package ejava.examples.asyncmarket.ejb;
2
3 import javax.enterprise.inject.Produces;
4 import javax.persistence.EntityManager;
5 import javax.persistence.PersistenceContext;
6
7 import ejava.examples.asyncmarket.dao.AuctionItemDAO;
8 import ejava.examples.asyncmarket.dao.OrderDAO;
9 import ejava.examples.asyncmarket.dao.PersonDAO;
10 import ejava.examples.asyncmarket.jpa.JPAAuctionItemDAO;
11 import ejava.examples.asyncmarket.jpa.JPAOrderDAO;
12 import ejava.examples.asyncmarket.jpa.JPAPersonDAO;
13
14 public class AuctionConfig {
15 @Produces
16 @PersistenceContext(unitName="asyncMarket")
17 public EntityManager em;
18
19 @Produces
20 public AuctionItemDAO auctionItemDao(EntityManager em) {
21 JPAAuctionItemDAO impl = new JPAAuctionItemDAO();
22 impl.setEntityManager(em);
23 return impl;
24 }
25
26 @Produces
27 public PersonDAO userDao(EntityManager em) {
28 JPAPersonDAO impl = new JPAPersonDAO();
29 impl.setEntityManager(em);
30 return impl;
31 }
32
33 @Produces
34 public OrderDAO orderDao(EntityManager em) {
35 JPAOrderDAO impl = new JPAOrderDAO();
36 impl.setEntityManager(em);
37 return impl;
38 }
39 }