39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
/*
|
|
* Copyright (c) 2017 univento.eu - All rights reserved
|
|
* You are not allowed to use, distribute or modify this code
|
|
*/
|
|
|
|
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 {
|
|
|
|
private MongoDB mongoDB;
|
|
private MySQL mySQL;
|
|
private Redis redis;
|
|
|
|
public DatabaseManager() {
|
|
ConfigurationHandler config = Commons.getCommons().getConfigurationHandler();
|
|
mongoDB = new MongoDB(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.getInteger("MySQL.Port"), config.getString("MySQL.Database"), config.getString("MySQL.Username"), config.getString("MySQL.Password"));
|
|
redis = new Redis(config.getString("Redis.Hostname"), config.getInteger("Redis.Port"), config.getString("Redis.Password"));
|
|
}
|
|
|
|
public void close() {
|
|
mongoDB.getClient().close();
|
|
mySQL.getClient().close();
|
|
redis.getClient().close(voidAsyncResult -> {
|
|
if(voidAsyncResult.failed()) voidAsyncResult.cause().printStackTrace();
|
|
});
|
|
}
|
|
|
|
} |