42 lines
2.0 KiB
Java
42 lines
2.0 KiB
Java
package eu.univento.commons.database;
|
|
|
|
import eu.univento.commons.Commons;
|
|
import eu.univento.commons.configuration.ConfigurationHandler;
|
|
import lombok.Data;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
|
|
@Data
|
|
public class DatabaseManager {
|
|
|
|
//TODO: add board sql back, when forum is online.
|
|
|
|
private MongoDB mongoDB;
|
|
private AsyncMongoDB asyncMongoDB;
|
|
private MySQL mySQL;
|
|
private AsyncMySQL asyncMySQL;
|
|
private AsyncMySQL boardSQL;
|
|
private Redis redis;
|
|
|
|
public DatabaseManager(Commons commons) {
|
|
ConfigurationHandler config = commons.getConfigurationHandler();
|
|
mongoDB = new MongoDB(config.getString("MongoDB.Host"), config.getInteger("MongoDB.Port"), config.getString("MongoDB.Username"), config.getString("MongoDB.Password"), config.getString("MongoDB.Database"));
|
|
asyncMongoDB = new AsyncMongoDB(config.getString("MongoDB.Host"), config.getInteger("MongoDB.Port"), config.getString("MongoDB.Username"), config.getString("MongoDB.Password"), config.getString("MongoDB.Database"));
|
|
mySQL = new MySQL(config.getString("MySQL.Host"), config.getString("MySQL.Port"), config.getString("MySQL.Database"), config.getString("MySQL.Username"), config.getString("MySQL.Password"));
|
|
asyncMySQL = new AsyncMySQL(config.getString("MySQL.Host"), config.getString("MySQL.Port"), config.getString("MySQL.Database"), config.getString("MySQL.Username"), config.getString("MySQL.Password"));
|
|
//boardSQL = new AsyncMySQL(config.getString("BoardSQL.Host"), config.getString("BoardSQL.Port"), config.getString("BoardSQL.Database"), config.getString("BoardSQL.Username"), config.getString("BoardSQL.Password"));
|
|
redis = new Redis(config.getString("Redis.Hostname"), config.getInteger("Redis.Port"), config.getString("Redis.Password"));
|
|
}
|
|
|
|
public void closeConnections() {
|
|
mongoDB.closeConnection();
|
|
asyncMongoDB.getMongoDB().closeConnection();
|
|
mySQL.close();
|
|
asyncMySQL.getMySQL().close();
|
|
//boardSQL.getMySQL().close();
|
|
redis.close();
|
|
}
|
|
} |