Revision 672:163de098320c src/gr/ebs/gss/server/ejb/GSSDAOBean.java

b/src/gr/ebs/gss/server/ejb/GSSDAOBean.java
31 31
import gr.ebs.gss.server.domain.User;
32 32
import gr.ebs.gss.server.domain.UserClass;
33 33

  
34
import java.net.UnknownHostException;
34 35
import java.util.ArrayList;
35 36
import java.util.Calendar;
36 37
import java.util.Date;
......
39 40
import java.util.List;
40 41
import java.util.Set;
41 42

  
42
import javax.ejb.Stateless;
43
import javax.persistence.EntityManager;
44 43
import javax.persistence.NoResultException;
45
import javax.persistence.PersistenceContext;
46 44

  
47 45
import org.apache.commons.lang.StringUtils;
48 46

  
47
import com.mongodb.DB;
48
import com.mongodb.Mongo;
49
import com.mongodb.MongoException;
50

  
49 51
/**
50 52
 * The implementation of the GSSDAO interface.
51 53
 */
52
@Stateless
53 54
public class GSSDAOBean implements GSSDAO {
54 55

  
55 56
	private static final int BANDWIDTH_TIME_PERIOD_FIELD = Calendar.MONTH;
56 57
	private static final int BANDWIDTH_TIME_PERIOD_AMOUNT = 1;
57 58

  
58 59
	/**
59
	 * The entity manager for the persistence unit
60
	 * A reference to the MongoDB.
60 61
	 */
61
	@PersistenceContext(unitName = "gss")
62
	private EntityManager manager;
62
	private DB db;
63

  
64
	/**
65
	 *
66
	 */
67
	public GSSDAOBean() {
68
		// TODO we only need a single Mongo object, since it contains the connection pool.
69
		Mongo m;
70
		try {
71
			m = new Mongo("127.0.0.1");
72
		} catch (UnknownHostException e) {
73
			// TODO Hanlde these in the Guice module.
74
			throw new RuntimeException(e);
75
		} catch (MongoException e) {
76
			// TODO Hanlde these in the Guice module.
77
			throw new RuntimeException(e);
78
		}
79
		db = m.getDB("gss");
80
	}
63 81

  
64 82
	@Override
65 83
	public Folder getRootFolder(final Long userId) throws ObjectNotFoundException {

Also available in: Unified diff