81 lines
2.2 KiB
Java
81 lines
2.2 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;
|
|
|
|
import eu.univento.commons.configuration.ConfigurationHandler;
|
|
import eu.univento.commons.database.DatabaseManager;
|
|
import eu.univento.commons.messaging.MessagingManager;
|
|
import eu.univento.commons.player.party.PartyManager;
|
|
import eu.univento.commons.player.statistics.GameStatistics;
|
|
import io.sentry.Sentry;
|
|
import io.sentry.SentryClient;
|
|
import io.sentry.jul.SentryHandler;
|
|
import io.vertx.core.Vertx;
|
|
import lombok.Getter;
|
|
|
|
import java.net.InetAddress;
|
|
import java.net.UnknownHostException;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.1
|
|
*/
|
|
|
|
@Getter
|
|
public class Commons {
|
|
|
|
private static Commons commons;
|
|
|
|
private Logger logger;
|
|
|
|
private DatabaseManager databaseManager;
|
|
private MessagingManager messagingManager;
|
|
private ConfigurationHandler configurationHandler;
|
|
private Vertx vertx;
|
|
private GameStatistics gameStatistics;
|
|
private PartyManager partyManager;
|
|
|
|
public Commons() {
|
|
commons = this;
|
|
configurationHandler = new ConfigurationHandler();
|
|
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();
|
|
messagingManager = new MessagingManager();
|
|
databaseManager = new DatabaseManager();
|
|
gameStatistics = new GameStatistics();
|
|
partyManager = new PartyManager();
|
|
|
|
}
|
|
|
|
public void shutdown() {
|
|
databaseManager.close();
|
|
messagingManager.close();
|
|
vertx.close();
|
|
Sentry.close();
|
|
}
|
|
|
|
public static Commons getCommons() {
|
|
return commons;
|
|
}
|
|
|
|
} |