Commons/src/main/java/eu/univento/commons/Commons.java

81 lines
2.2 KiB
Java
Raw Normal View History

/*
* Copyright (c) 2017 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
2016-08-02 23:53:40 +02:00
package eu.univento.commons;
import eu.univento.commons.configuration.ConfigurationHandler;
import eu.univento.commons.database.DatabaseManager;
2017-04-13 15:56:55 +02:00
import eu.univento.commons.messaging.MessagingManager;
2017-08-14 12:06:33 +02:00
import eu.univento.commons.player.party.PartyManager;
import eu.univento.commons.player.statistics.GameStatistics;
2017-08-14 12:06:33 +02:00
import io.sentry.Sentry;
import io.sentry.SentryClient;
import io.sentry.jul.SentryHandler;
2017-04-07 17:10:36 +02:00
import io.vertx.core.Vertx;
import lombok.Getter;
2016-08-02 23:53:40 +02:00
2017-08-14 12:06:33 +02:00
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
2016-08-02 23:53:40 +02:00
/**
* @author joethei
2017-04-14 11:02:35 +02:00
* @version 1.1
2016-08-02 23:53:40 +02:00
*/
@Getter
2016-08-02 23:53:40 +02:00
public class Commons {
private static Commons commons;
2016-12-06 19:17:13 +01:00
2017-08-14 12:06:33 +02:00
private Logger logger;
2016-08-02 23:53:40 +02:00
private DatabaseManager databaseManager;
2017-04-13 15:56:55 +02:00
private MessagingManager messagingManager;
2016-08-02 23:53:40 +02:00
private ConfigurationHandler configurationHandler;
2017-04-07 17:10:36 +02:00
private Vertx vertx;
private GameStatistics gameStatistics;
2017-08-14 12:06:33 +02:00
private PartyManager partyManager;
2016-08-02 23:53:40 +02:00
public Commons() {
commons = this;
2016-08-02 23:53:40 +02:00
configurationHandler = new ConfigurationHandler();
2017-08-14 12:06:33 +02:00
logger = Logger.getLogger("Commons");
SentryClient sentryClient = Sentry.init(configurationHandler.getString("Sentry.DSN.Commons"));
try {
sentryClient.setServerName(InetAddress.getLocalHost().getHostName());
sentryClient.setEnvironment("");
sentryClient.setDist("Commons");
sentryClient.setRelease("1.0.0");
} catch (UnknownHostException e) {
e.printStackTrace();
}
SentryHandler logHandler = new SentryHandler();
logHandler.setLevel(Level.INFO);
logger.addHandler(logHandler);
vertx = Vertx.vertx();
2017-04-13 15:56:55 +02:00
messagingManager = new MessagingManager();
databaseManager = new DatabaseManager();
gameStatistics = new GameStatistics();
2017-08-14 12:06:33 +02:00
partyManager = new PartyManager();
2016-08-02 23:53:40 +02:00
}
public void shutdown() {
2017-08-14 12:06:33 +02:00
databaseManager.close();
messagingManager.close();
2017-04-07 17:10:36 +02:00
vertx.close();
2017-08-14 12:06:33 +02:00
Sentry.close();
2016-08-02 23:53:40 +02:00
}
2016-12-06 19:17:13 +01:00
public static Commons getCommons() {
return commons;
}
2016-08-02 23:53:40 +02:00
}