public FileTransactionLoggerWrapper(ServerConfig serverConfig) { String evalDir = serverConfig.getLoggingDirectoryWithEval(); this.dir = evalDir != null ? evalDir : "logs"; this.maxFileSize = GlobalProperties.getInt("ebean.logging.maxFileSize", 100 * 1024 * 1024); this.serverName = serverConfig.getName(); }
public FileTransactionLoggerWrapper(ServerConfig serverConfig) { String evalDir = serverConfig.getLoggingDirectoryWithEval(); this.dir = evalDir != null ? evalDir : "logs"; this.maxFileSize = GlobalProperties.getInt("ebean.logging.maxFileSize", 100 * 1024 * 1024); this.serverName = serverConfig.getName(); }
/** * Construct with the ClassLoader used to load Ebean.class. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public SubClassManager(ServerConfig serverConfig) { String s = serverConfig.getProperty("subClassManager.preferContextClassloader", "true"); final boolean preferContext = "true".equalsIgnoreCase(s); this.serverName = serverConfig.getName(); this.logLevel = serverConfig.getEnhanceLogLevel(); this.clzMap = new ConcurrentHashMap<String, Class<?>>(); try { subclassFactory = (SubClassFactory) AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() { ClassLoader cl = ClassUtil.getClassLoader(this.getClass(), preferContext); logger.info("SubClassFactory parent ClassLoader ["+cl.getClass().getName()+"]"); return new SubClassFactory(cl, logLevel); } }); } catch (PrivilegedActionException e) { throw new PersistenceException(e); } }
/** * Construct with the ClassLoader used to load Ebean.class. */ @SuppressWarnings({ "unchecked", "rawtypes" }) public SubClassManager(ServerConfig serverConfig) { String s = serverConfig.getProperty("subClassManager.preferContextClassloader", "true"); final boolean preferContext = "true".equalsIgnoreCase(s); this.serverName = serverConfig.getName(); this.logLevel = serverConfig.getEnhanceLogLevel(); this.clzMap = new ConcurrentHashMap<String, Class<?>>(); try { subclassFactory = (SubClassFactory) AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() { ClassLoader cl = ClassUtil.getClassLoader(this.getClass(), preferContext); logger.info("SubClassFactory parent ClassLoader ["+cl.getClass().getName()+"]"); return new SubClassFactory(cl, logLevel); } }); } catch (PrivilegedActionException e) { throw new PersistenceException(e); } }
private SpiBackgroundExecutor createBackgroundExecutor(ServerConfig serverConfig) { String namePrefix = "ebean-" + serverConfig.getName(); int schedulePoolSize = serverConfig.getBackgroundExecutorSchedulePoolSize(); int shutdownSecs = serverConfig.getBackgroundExecutorShutdownSecs(); return new DefaultBackgroundExecutor(schedulePoolSize, shutdownSecs, namePrefix); }
/** * Set the DatabasePlatform if it has not already been set. */ private void setDatabasePlatform(ServerConfig config) { DatabasePlatform dbPlatform = config.getDatabasePlatform(); if (dbPlatform == null) { DatabasePlatformFactory factory = new DatabasePlatformFactory(); DatabasePlatform db = factory.create(config); config.setDatabasePlatform(db); logger.info("DatabasePlatform name:" + config.getName() + " platform:" + db.getName()); } }
/** * Set the DatabasePlatform if it has not already been set. */ private void setDatabasePlatform(ServerConfig config) { DatabasePlatform dbPlatform = config.getDatabasePlatform(); if (dbPlatform == null) { DatabasePlatformFactory factory = new DatabasePlatformFactory(); DatabasePlatform db = factory.create(config); config.setDatabasePlatform(db); logger.info("DatabasePlatform name:" + config.getName() + " platform:" + db.getName()); } }
/** * Set the DatabasePlatform if it has not already been set. */ private void setDatabasePlatform(ServerConfig config) { DatabasePlatform dbPlatform = config.getDatabasePlatform(); if (dbPlatform == null) { if (config.getTenantMode().isDynamicDataSource()) { throw new IllegalStateException("DatabasePlatform must be explicitly set on ServerConfig for TenantMode "+config.getTenantMode()); } DatabasePlatformFactory factory = new DatabasePlatformFactory(); DatabasePlatform db = factory.create(config); db.configure(config.getDbTypeConfig()); config.setDatabasePlatform(db); logger.info("DatabasePlatform name:{} platform:{}", config.getName(), db.getName()); } }
this.serverName = config.getName();
this.serverName = config.getName();
/** * Create using the ServerConfig object to configure the server. */ public static synchronized EbeanServer create(ServerConfig config) { if (config.getName() == null) { throw new PersistenceException("The name is null (it is required)"); } EbeanServer server = createInternal(config); if (config.isDefaultServer()) { PrimaryServer.setSkip(true); } if (config.isRegister()) { Ebean.register(server, config.isDefaultServer()); } return server; }
/** * Create using the ServerConfig object to configure the server. */ public static EbeanServer create(ServerConfig config) { if (config.getName() == null) { throw new PersistenceException("The name is null (it is required)"); } EbeanServer server = serverFactory.createServer(config); if (config.isDefaultServer()) { GlobalProperties.setSkipPrimaryServer(true); } if (config.isRegister()) { Ebean.register(server, config.isDefaultServer()); } return server; }
/** * Create using the ServerConfig object to configure the server. */ public static EbeanServer create(ServerConfig config) { if (config.getName() == null) { throw new PersistenceException("The name is null (it is required)"); } EbeanServer server = serverFactory.createServer(config); if (config.isDefaultServer()) { GlobalProperties.setSkipPrimaryServer(true); } if (config.isRegister()) { Ebean.register(server, config.isDefaultServer()); } return server; }
@Override public DataSource createDataSource(DataSourceConfig conf) { ServerConfig ebeanConfig = new EbeanConfigAdaptor().adaptFrom(actConfig, conf, svc); DataSourceFactory factory = ebeanConfig.service(DataSourceFactory.class); if (factory == null) { throw new IllegalStateException("No DataSourceFactory service implementation found in class path." + " Probably missing dependency to avaje-datasource?"); } DataSourceAlertFactory alertFactory = ebeanConfig.service(DataSourceAlertFactory.class); org.avaje.datasource.DataSourceConfig dsConfig = ebeanConfig.getDataSourceConfig(); if (alertFactory != null) { dsConfig.setAlert(alertFactory.createAlert()); } if (conf.readOnly) { // setup to use AutoCommit such that we skip explicit commit dsConfig.setAutoCommit(true); } String poolName = ebeanConfig.getName() + (conf.readOnly ? "-ro" : ""); return new EbeanDataSourceWrapper(ebeanConfig, factory.createPool(poolName, dsConfig)); }
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); }
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); }
private SpiBackgroundExecutor createBackgroundExecutor(ServerConfig serverConfig, int uniqueServerId) { String namePrefix = "Ebean-" + serverConfig.getName(); // the size of the pool for executing periodic tasks (such as cache // flushing) int schedulePoolSize = GlobalProperties.getInt("backgroundExecutor.schedulePoolsize", 1); // the side of the main pool for immediate background task execution int minPoolSize = GlobalProperties.getInt("backgroundExecutor.minPoolSize", 1); int poolSize = GlobalProperties.getInt("backgroundExecutor.poolsize", 20); int maxPoolSize = GlobalProperties.getInt("backgroundExecutor.maxPoolSize", poolSize); int idleSecs = GlobalProperties.getInt("backgroundExecutor.idlesecs", 60); int shutdownSecs = GlobalProperties.getInt("backgroundExecutor.shutdownSecs", 30); boolean useTrad = GlobalProperties.getBoolean("backgroundExecutor.traditional", true); if (useTrad) { // this pool will use Idle seconds between min and max so I think it is // better // as it will let the thread count float between the min and max ThreadPool pool = ThreadPoolManager.getThreadPool(namePrefix); pool.setMinSize(minPoolSize); pool.setMaxSize(maxPoolSize); pool.setMaxIdleTime(idleSecs * 1000); return new TraditionalBackgroundExecutor(pool, schedulePoolSize, shutdownSecs, namePrefix); } else { return new DefaultBackgroundExecutor(poolSize, schedulePoolSize, idleSecs, shutdownSecs, namePrefix); } }
private SpiBackgroundExecutor createBackgroundExecutor(ServerConfig serverConfig, int uniqueServerId) { String namePrefix = "Ebean-" + serverConfig.getName(); // the size of the pool for executing periodic tasks (such as cache // flushing) int schedulePoolSize = GlobalProperties.getInt("backgroundExecutor.schedulePoolsize", 1); // the side of the main pool for immediate background task execution int minPoolSize = GlobalProperties.getInt("backgroundExecutor.minPoolSize", 1); int poolSize = GlobalProperties.getInt("backgroundExecutor.poolsize", 20); int maxPoolSize = GlobalProperties.getInt("backgroundExecutor.maxPoolSize", poolSize); int idleSecs = GlobalProperties.getInt("backgroundExecutor.idlesecs", 60); int shutdownSecs = GlobalProperties.getInt("backgroundExecutor.shutdownSecs", 30); boolean useTrad = GlobalProperties.getBoolean("backgroundExecutor.traditional", true); if (useTrad) { // this pool will use Idle seconds between min and max so I think it is // better // as it will let the thread count float between the min and max ThreadPool pool = ThreadPoolManager.getThreadPool(namePrefix); pool.setMinSize(minPoolSize); pool.setMaxSize(maxPoolSize); pool.setMaxIdleTime(idleSecs * 1000); return new TraditionalBackgroundExecutor(pool, schedulePoolSize, shutdownSecs, namePrefix); } else { return new DefaultBackgroundExecutor(poolSize, schedulePoolSize, idleSecs, shutdownSecs, namePrefix); } }
/** * Create the TransactionManager */ public TransactionManager(TransactionManagerOptions options) { this.skipCacheAfterWrite = options.config.isSkipCacheAfterWrite(); this.localL2Caching = options.localL2Caching; this.persistBatch = options.config.getPersistBatch(); this.persistBatchOnCascade = options.config.appliedPersistBatchOnCascade(); this.beanDescriptorManager = options.descMgr; this.viewInvalidation = options.descMgr.requiresViewEntityCacheInvalidation(); this.changeLogPrepare = options.descMgr.getChangeLogPrepare(); this.changeLogListener = options.descMgr.getChangeLogListener(); this.clusterManager = options.clusterManager; this.serverName = options.config.getName(); this.backgroundExecutor = options.backgroundExecutor; this.dataSourceSupplier = options.dataSourceSupplier; this.docStoreActive = options.config.getDocStoreConfig().isActive(); this.docStoreUpdateProcessor = options.docStoreUpdateProcessor; this.bulkEventListenerMap = new BulkEventListenerMap(options.config.getBulkTableEventListeners()); this.prefix = ""; this.externalTransPrefix = "e"; this.onQueryOnly = initOnQueryOnly(options.config.getDatabasePlatform().getOnQueryOnly()); CurrentTenantProvider tenantProvider = options.config.getCurrentTenantProvider(); if (tenantProvider == null) { transactionFactory = new TransactionFactoryBasic(this, dataSourceSupplier); } else { transactionFactory = new TransactionFactoryTenant(this, dataSourceSupplier, tenantProvider); } }
this.serverName = InternString.intern(config.getServerConfig().getName()); this.cacheManager = config.getCacheManager(); this.xmlConfig = config.getXmlConfig();