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); } }
this.poolListener = createPoolListener(params.getPoolListener()); this.transactionIsolation = params.getIsolationLevel(); this.maxInactiveTimeSecs = params.getMaxInactiveTimeSecs(); this.leakTimeMinutes = params.getLeakTimeMinutes(); this.captureStackTrace = params.isCaptureStackTrace(); this.maxStackTraceSize = params.getMaxStackTraceSize(); this.databaseDriver = params.getDriver(); this.databaseUrl = params.getUrl(); this.pstmtCacheSize = params.getPstmtCacheSize(); this.minConnections = params.getMinConnections(); this.maxConnections = params.getMaxConnections(); this.waitTimeoutMillis = params.getWaitTimeoutMillis(); this.heartbeatsql = params.getHeartbeatSql(); String un = params.getUsername(); String pw = params.getPassword(); if (un == null) { throw new RuntimeException("DataSource user is null?"); this.connectionProps.setProperty("password", pw); Map<String, String> customProperties = params.getCustomProperties(); if (customProperties != null){ Set<Entry<String,String>> entrySet = customProperties.entrySet();
public void configureDbConfig(ServerConfig config) { Validate.notNull(config, "Config cannot be null"); DataSourceConfig ds = new DataSourceConfig(); ds.setDriver("org.sqlite.JDBC"); ds.setUrl("jdbc:sqlite:{DIR}{NAME}.db"); ds.setUsername("bukkit"); ds.setPassword("walrus"); ds.setIsolationLevel(TransactionIsolation.getLevel("SERIALIZABLE")); if (ds.getDriver().contains("sqlite")) { config.setDatabasePlatform(new SQLitePlatform()); config.getDatabasePlatform().getDbDdlSyntax().setIdentity(""); } config.setDataSourceConfig(ds); }
public DataSourcePool getDataSource(String name, DataSourceConfig dsConfig){ if (name == null){ throw new IllegalArgumentException("name not defined"); } synchronized(monitor){ DataSourcePool pool = dsMap.get(name); if (pool == null){ if (dsConfig == null){ dsConfig = new DataSourceConfig(); dsConfig.loadSettings(name); } pool = new DataSourcePool(this, name, dsConfig); dsMap.put(name, pool); } return pool; } }
final DataSourceConfig dataSourceConfig = new DataSourceConfig(); dataSourceConfig.setDriver(Application.getConfiguration().getParameter("ebean.driver")); dataSourceConfig.setUsername(Application.getConfiguration().getParameter("ebean.username")); dataSourceConfig.setPassword(Application.getConfiguration().getParameter("ebean.password")); final String url = Application.getConfiguration().getParameter("ebean.url"); if (null != url) { dataSourceConfig.setUrl(url); } else { throw new Exception("ebean.url must be specified");
private DataSource getDataSourceFromConfig(ServerConfig config) { DataSource ds = null; if (config.getDataSourceJndiName() != null) { ds = jndiDataSourceFactory.lookup(config.getDataSourceJndiName()); if (ds == null) { String m = "JNDI lookup for DataSource " + config.getDataSourceJndiName() + " returned null."; throw new PersistenceException(m); } else { return ds; } } DataSourceConfig dsConfig = config.getDataSourceConfig(); if (dsConfig == null) { String m = "No DataSourceConfig definded for " + config.getName(); throw new PersistenceException(m); } if (dsConfig.isOffline()) { if (config.getDatabasePlatformName() == null) { String m = "You MUST specify a DatabasePlatformName on ServerConfig when offline"; throw new PersistenceException(m); } return null; } if (dsConfig.getHeartbeatSql() == null) { // use default heartbeatSql from the DatabasePlatform String heartbeatSql = getHeartbeatSql(dsConfig.getDriver()); dsConfig.setHeartbeatSql(heartbeatSql); } return DataSourceGlobalManager.getDataSource(config.getName(), dsConfig); }
this.poolListener = createPoolListener(params.getPoolListener()); this.transactionIsolation = params.getIsolationLevel(); this.maxInactiveTimeSecs = params.getMaxInactiveTimeSecs(); this.leakTimeMinutes = params.getLeakTimeMinutes(); this.captureStackTrace = params.isCaptureStackTrace(); this.maxStackTraceSize = params.getMaxStackTraceSize(); this.databaseDriver = params.getDriver(); this.databaseUrl = params.getUrl(); this.pstmtCacheSize = params.getPstmtCacheSize(); this.minConnections = params.getMinConnections(); this.maxConnections = params.getMaxConnections(); this.waitTimeoutMillis = params.getWaitTimeoutMillis(); this.heartbeatsql = params.getHeartbeatSql(); String un = params.getUsername(); String pw = params.getPassword(); if (un == null) { throw new RuntimeException("DataSource user is null?"); this.connectionProps.setProperty("password", pw); Map<String, String> customProperties = params.getCustomProperties(); if (customProperties != null){ Set<Entry<String,String>> entrySet = customProperties.entrySet();
public DataSourcePool getDataSource(String name, DataSourceConfig dsConfig){ if (name == null){ throw new IllegalArgumentException("name not defined"); } synchronized(monitor){ DataSourcePool pool = dsMap.get(name); if (pool == null){ if (dsConfig == null){ dsConfig = new DataSourceConfig(); dsConfig.loadSettings(name); } pool = new DataSourcePool(this, name, dsConfig); dsMap.put(name, pool); } return pool; } }
private DataSource getDataSourceFromConfig(ServerConfig config) { DataSource ds = null; if (config.getDataSourceJndiName() != null) { ds = jndiDataSourceFactory.lookup(config.getDataSourceJndiName()); if (ds == null) { String m = "JNDI lookup for DataSource " + config.getDataSourceJndiName() + " returned null."; throw new PersistenceException(m); } else { return ds; } } DataSourceConfig dsConfig = config.getDataSourceConfig(); if (dsConfig == null) { String m = "No DataSourceConfig definded for " + config.getName(); throw new PersistenceException(m); } if (dsConfig.isOffline()) { if (config.getDatabasePlatformName() == null) { String m = "You MUST specify a DatabasePlatformName on ServerConfig when offline"; throw new PersistenceException(m); } return null; } if (dsConfig.getHeartbeatSql() == null) { // use default heartbeatSql from the DatabasePlatform String heartbeatSql = getHeartbeatSql(dsConfig.getDriver()); dsConfig.setHeartbeatSql(heartbeatSql); } return DataSourceGlobalManager.getDataSource(config.getName(), dsConfig); }
config.setName("iris"); DataSourceConfig ds = new DataSourceConfig(); ds.loadSettings("iris");
public Gringotts() { ServerConfig dbConfig = new ServerConfig(); dbConfig.setDefaultServer(false); dbConfig.setRegister(false); dbConfig.setClasses(getDatabaseClasses()); dbConfig.setName(getDescription().getName()); configureDbConfig(dbConfig); DataSourceConfig dsConfig = dbConfig.getDataSourceConfig(); dsConfig.setUrl(replaceDatabaseString(dsConfig.getUrl())); getDataFolder().mkdirs(); ClassLoader previous = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClassLoader()); ebean = EbeanServerFactory.create(dbConfig); Thread.currentThread().setContextClassLoader(previous); }
dataSourceConfig = new DataSourceConfig(); dataSourceConfig.loadSettings(p.getServerName());
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); } }
dataSourceConfig = new DataSourceConfig(); dataSourceConfig.loadSettings(p.getServerName());