1 package org.myorg.jpatickets.ejb;
2
3 import javax.annotation.PostConstruct;
4 import javax.annotation.PreDestroy;
5 import javax.ejb.EJBException;
6 import javax.ejb.Stateless;
7 import javax.persistence.EntityManager;
8 import javax.persistence.PersistenceContext;
9
10 import org.myorg.jpatickets.bl.VenueMgmt;
11 import org.myorg.jpatickets.bl.VenueMgmtImpl;
12 import org.myorg.jpatickets.bo.Venue;
13 import org.myorg.jpatickets.dao.VenueDAOImpl;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 @Stateless
18 public class VenueMgmtEJB implements VenueMgmtRemote {
19 private static final Logger logger = LoggerFactory.getLogger(VenueMgmtEJB.class);
20
21
22 private EntityManager em;
23
24 private VenueMgmt venueMgmt;
25
26 @PostConstruct
27 public void init() {
28 logger.debug("*** VenueMgmtEJB:init({}) ***", super.hashCode());
29
30 VenueDAOImpl vdao = new VenueDAOImpl();
31 vdao.setEntityManager(em);
32 venueMgmt=new VenueMgmtImpl();
33 ((VenueMgmtImpl)venueMgmt).setDao(vdao);
34 }
35
36 @PreDestroy
37 public void destroy() {
38 logger.debug("*** VenueMgmtEJB:destroy({}) ***", super.hashCode());
39 }
40
41 @Override
42 public Venue createVenue(Venue venue, int sections, int positions, int rows) {
43 try {
44 return venueMgmt.createVenue(venue, sections, positions, rows);
45 } catch (Exception ex) {
46 logger.error("error creating venue", ex);
47 throw new EJBException("error creating venue:" + ex);
48 }
49 }
50
51 @Override
52 public Venue getVenue(String venueId) {
53 try {
54 return venueMgmt.getVenue(venueId);
55 } catch (Exception ex) {
56 logger.error("error getting venue", ex);
57 throw new EJBException("error getting venue:" + ex);
58 }
59 }
60 }