Ejemplo n.º 1
0
  public DatastoreImpl(
      Morphia morphia, Mongo mongo, String dbName, String username, char[] password) {
    //		this.morphia = morphia;
    this.mapr = morphia.getMapper();
    this.mongo = mongo;
    this.db = mongo.getDB(dbName);
    if (username != null)
      if (!this.db.authenticate(username, password))
        throw new AuthenticationException(
            "User '"
                + username
                + "' cannot be authenticated with the given password for database '"
                + dbName
                + "'");

    // VERY discussable
    DatastoreHolder.getInstance().set(this);
  }
Ejemplo n.º 2
0
 static {
   mor = new Morphia();
   ds = mor.createDatastore("test");
 }
Ejemplo n.º 3
0
 @SuppressWarnings("unchecked")
 public static void mapClass(Class c) {
   mor.map(c);
 }
Ejemplo n.º 4
0
 public static void mapPackage(String pkg) {
   mor.mapPackage(pkg, true);
 }
Ejemplo n.º 5
0
 public static void setDatabase(String dbName) {
   if (!((DatastoreImpl) ds).getDB().getName().equals(dbName)) ds = mor.createDatastore(dbName);
 }