View Javadoc
1   package ejava.examples.cdiconfig.ejb;
2   
3   import javax.annotation.PostConstruct;
4   import javax.inject.Inject;
5   import javax.persistence.EntityManager;
6   import javax.sql.DataSource;
7   
8   import ejava.examples.cdiconfig.CdiDemo;
9   
10  //@Stateless
11  public class TrainSchedulerEJB {
12  
13  //    public String getName() { return TrainSchedulerEJB.class.getSimpleName(); }
14  
15      /**
16       * This will inject a persistence context using a textual name qualifier 
17       */
18  //    @Inject @CdiDemo
19  //    private EntityManager em;
20      
21      /**
22       * This will inject a javax.sql.DataSource
23       */
24  //    @Inject @CdiDemo
25  //    private DataSource ds;
26      
27      /**
28       * This will inject a DAO by interface type
29       */
30  //    @Inject
31  //    protected SchedulerDAO schedulerDAO;
32      
33      /**
34       * This will inject a DAO by class type
35       */
36  //    @Inject
37  //    protected SchedulerDAOImpl jpaSchedulerDAOImpl;
38  
39      /**
40       * This will inject an EJB based on an Annotation qualifier
41       */
42  //    @Inject @Cook
43  //    protected Scheduler cook; 
44  
45      /**
46       * This will inject the ability to get an Scheduler when the qualifier is 
47       * known at runtime.
48       */
49  //    @Inject @Any
50  //    protected Instance<Scheduler> anyCook;
51      
52      /**
53       * This will be looked up at runtime during the @PostConstruct
54       */
55  //    protected Scheduler cook2; 
56  
57      /**
58       * This will inject a String based on an annotation qualifier
59       */
60  //    @Inject @CdiDemo
61  //    String message;
62  
63  //    @Resource
64  //    protected void setSessionContext(SessionContext ctx) {
65  //        super.ctx = ctx;
66  //    }
67  
68      @PostConstruct
69      public void init() {        
70  //        log.info("******************* TrainScheduler Created ******************");
71  //        log.debug("ctx=" + ctx);
72  //        log.debug("em=" + em);
73  //        log.debug("ds=" + ds);
74  //        log.debug("message=" + message);
75  //        log.debug("cook=" + cook);
76  //        cook2 = anyCook.select(new CookQualifier()).get();
77  //        log.debug("cook2=" + cook2);
78  //        log.debug("schedulerDAO=" + schedulerDAO);
79  //        log.debug("jpaSchedulerDAOImpl=" + jpaSchedulerDAOImpl);
80      }
81  }