예제 #1
0
 @Provides
 public ODatabaseDocument getDatabaseRecord() {
   ODatabaseDocument db =
       DefaultODatabaseThreadLocalFactory.castToODatabaseDocument(
           ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner());
   if (db.isClosed()) {
     ODatabaseRecordThreadLocal.INSTANCE.remove();
     db =
         DefaultODatabaseThreadLocalFactory.castToODatabaseDocument(
             ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner());
   }
   return db;
 }
예제 #2
0
파일: DB.java 프로젝트: o-nix/Kafra
  public static ODatabaseDocument getDb() {
    ODatabaseDocument db = DatabaseObjects.INSTANCE.get();
    boolean useServer = Application.getConfig().getBooleanProperty("db.server", false);

    if (db == null) {
      db = new ODatabaseDocumentTx(useServer ? "remote:localhost/main" : "local:data");

      if (!useServer && !db.exists()) db.create();

      if (db.isClosed()) db.open("admin", "admin");
    }

    ODatabaseRecordThreadLocal.INSTANCE.get().setDatabaseOwner(db);
    DatabaseObjects.INSTANCE.set(db);

    return db;
  }