Search in sources :

Example 1 with DataSourceConfig

use of com.avaje.ebean.config.DataSourceConfig in project Bukkit by Bukkit.

the class JavaPlugin method init.

final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
    this.loader = loader;
    this.server = server;
    this.file = file;
    this.description = description;
    this.dataFolder = dataFolder;
    this.classLoader = classLoader;
    this.configFile = new File(dataFolder, "config.yml");
    this.logger = new PluginLogger(this);
    if (description.isDatabaseEnabled()) {
        ServerConfig db = new ServerConfig();
        db.setDefaultServer(false);
        db.setRegister(false);
        db.setClasses(getDatabaseClasses());
        db.setName(description.getName());
        server.configureDbConfig(db);
        DataSourceConfig ds = db.getDataSourceConfig();
        ds.setUrl(replaceDatabaseString(ds.getUrl()));
        dataFolder.mkdirs();
        ClassLoader previous = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        ebean = EbeanServerFactory.create(db);
        Thread.currentThread().setContextClassLoader(previous);
    }
}
Also used : ServerConfig(com.avaje.ebean.config.ServerConfig) DataSourceConfig(com.avaje.ebean.config.DataSourceConfig) File(java.io.File) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) PluginLogger(org.bukkit.plugin.PluginLogger)

Example 2 with DataSourceConfig

use of com.avaje.ebean.config.DataSourceConfig in project Glowstone by GlowstoneMC.

the class GlowServer method configureDbConfig.

@Override
public void configureDbConfig(com.avaje.ebean.config.ServerConfig dbConfig) {
    DataSourceConfig ds = new DataSourceConfig();
    ds.setDriver(config.getString(Key.DB_DRIVER));
    ds.setUrl(config.getString(Key.DB_URL));
    ds.setUsername(config.getString(Key.DB_USERNAME));
    ds.setPassword(config.getString(Key.DB_PASSWORD));
    ds.setIsolationLevel(TransactionIsolation.getLevel(config.getString(Key.DB_ISOLATION)));
    if (ds.getDriver().contains("sqlite")) {
        dbConfig.setDatabasePlatform(new SQLitePlatform());
        dbConfig.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
    }
    dbConfig.setDataSourceConfig(ds);
}
Also used : DataSourceConfig(com.avaje.ebean.config.DataSourceConfig) SQLitePlatform(com.avaje.ebean.config.dbplatform.SQLitePlatform)

Aggregations

DataSourceConfig (com.avaje.ebean.config.DataSourceConfig)2 ServerConfig (com.avaje.ebean.config.ServerConfig)1 SQLitePlatform (com.avaje.ebean.config.dbplatform.SQLitePlatform)1 File (java.io.File)1 PluginDescriptionFile (org.bukkit.plugin.PluginDescriptionFile)1 PluginLogger (org.bukkit.plugin.PluginLogger)1