1 package ejava.examples.cdiconfig;
2
3 import javax.annotation.Resource;
4 import javax.enterprise.inject.Produces;
5 import javax.persistence.EntityManager;
6 import javax.persistence.PersistenceContext;
7 import javax.sql.DataSource;
8
9 import ejava.examples.cdiconfig.dao.JobsDao;
10 import ejava.examples.cdiconfig.dao.JobsDaoImpl;
11
12
13
14
15
16
17 public class CdiDemoConfig {
18
19
20
21
22
23 @Produces
24 @CdiDemo
25 @PersistenceContext(unitName="cdi-config")
26 public EntityManager em;
27
28
29
30
31 @Produces
32 @Resource(lookup="java:jboss/datasources/ExampleDS")
33 public DataSource ds;
34
35
36
37
38
39 @Produces
40 @CdiDemo
41 public String message="Hello CDI!!!";
42
43
44 @Produces
45 @CdiDemo
46 public JobsDao jobsDao(@CdiDemo EntityManager em) {
47 JobsDaoImpl impl = new JobsDaoImpl();
48 impl.setEntityManager(em);
49 return impl;
50 }
51
52
53
54
55
56
57
58
59 }