View Javadoc
1   package org.myorg.encconfig.ejb;
2   
3   import javax.annotation.PostConstruct;
4   import javax.annotation.Resource;
5   import javax.ejb.Stateless;
6   import javax.jms.ConnectionFactory;
7   import javax.jms.Topic;
8   import javax.persistence.EntityManager;
9   import javax.persistence.PersistenceContext;
10  
11  import org.slf4j.Logger;
12  import org.slf4j.LoggerFactory;
13  
14  @Stateless
15  public class ENCAuditorEJB extends AuditorBase 
16  		implements AuditorRemote {
17  	private static final Logger log = LoggerFactory.getLogger(ENCAuditorEJB.class);
18  	//TODO: enc-config 12: define a resource value ENC injection
19  	//@Resource(name="val/publishJMS")
20  	private Boolean publishJMS;
21  	
22  	//TODO: enc-config 13: define a persistence context ENC injection
23  	//@PersistenceContext(name="jpa/em")
24  	private EntityManager em;
25  	
26  	//TODO: enc-config 14: define a resource-env ENC injection
27  	//@Resource(name="jms/topic")
28  	private Topic topic;
29  
30  	//TODO: enc-config 15: define a resource ENC injection
31  	//@Resource(name="jms/cf")
32  	private ConnectionFactory cf;
33  	
34  	//TODO: enc-config 16: activate this method after injection
35  	//@PostConstruct
36  	public void init() {
37  		super.setLog(log);
38  		super.setConnectionFactory(cf);
39  		super.setEntityManager(em);
40  		super.setTopic(topic);
41  		super.setPublishJMS(isPublishJMS());
42  	}	
43  	
44  	@Override
45  	public boolean isPublishJMS() {
46  		return publishJMS!=null && publishJMS;
47  	}
48  	@Override
49  	public boolean havePersistenceContext() {
50  		return em!=null;
51  	}
52  	@Override
53  	public boolean haveTopic() {
54  		return topic!=null;
55  	}
56  	@Override
57  	public boolean haveConnectionFactory() {
58  		return cf!=null;
59  	}
60  	
61  	@Override
62  	public int audit(String message) {
63  		return super.audit(message);
64  	}
65  }