本文整理汇总了Java中com.avaje.ebean.config.ServerConfig.setDefaultServer方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConfig.setDefaultServer方法的具体用法?Java ServerConfig.setDefaultServer怎么用?Java ServerConfig.setDefaultServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.avaje.ebean.config.ServerConfig
的用法示例。
在下文中一共展示了ServerConfig.setDefaultServer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InMemoryEbeanServer
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public InMemoryEbeanServer() {
// Create in-memory database configuration.
DataSourceConfig dbConfig = new DataSourceConfig();
dbConfig.setUsername("sa");
dbConfig.setPassword("");
dbConfig.setUrl("jdbc:h2:mem:tests2;DB_CLOSE_DELAY=-1");
dbConfig.setDriver("org.h2.Driver");
ServerConfig config = new ServerConfig();
config.setName("h2");
config.setDataSourceConfig(dbConfig);
config.setDefaultServer(true);
for (Class<?> entity : EbeanEntities.getEntities()) {
config.addClass(entity);
}
config.setDdlGenerate(true);
config.setDdlRun(true);
server = EbeanServerFactory.create(config);
ddl = ((SpiEbeanServer) server).getDdlGenerator();
}
示例2: createEbeanServerInstance
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public EbeanServer createEbeanServerInstance(PluginDataResolver pluginDataResolver) {
File myDataDir;
try {
myDataDir = new File(pluginDataResolver.getPluginDatabaseDirectory());
} catch (IOException e) {
Loggers.SERVER.error("tcDebRepository EbeanServerProvider : Failed to get database directory location");
Loggers.SERVER.debug(e);
return null;
}
if (myDataDir.exists() && myDataDir.isDirectory() && myDataDir.canWrite()) {
ServerConfig config = new ServerConfig();
config.setName("db");
config.loadFromProperties();
DataSourceConfig dsConfig = config.getDataSourceConfig();
dsConfig.setUrl(
"jdbc:h2:file:" + myDataDir.getAbsolutePath() + File.separator + "tcDebRepositoryDB;DB_CLOSE_ON_EXIT=FALSE");
config.setDataSourceConfig(dsConfig);
Loggers.SERVER.debug(config.getDataSourceConfig().getUsername());
// set as default and register so that Model can be
// used if desired for save() and update() etc
config.setDefaultServer(true);
config.setRegister(true);
config.addPackage("debrepo.teamcity.ebean");
Loggers.SERVER.debug("EbeanServerProvider :: ebean Properties are: " + config.getProperties().toString());
return EbeanServerFactory.create(config);
}
return null;
}
示例3: ebeanServerConfig
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
@SuppressWarnings("SpringJavaAutowiringInspection")
@Bean
public ServerConfig ebeanServerConfig(DataSource dataSource) {
ServerConfig config = new ServerConfig();
config.setName("ebeanServer");
config.setDefaultServer(true);
config.setDataSource(dataSource);
config.addPackage("com.clevergang.dbtests.repository.impl.ebean.entities");
config.setExternalTransactionManager(new SpringAwareJdbcTransactionManager());
config.setAutoCommitMode(false);
config.setExpressionNativeIlike(true);
return config;
}
示例4: init
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
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);
}
}
示例5: initialize
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
/**
* Initializes this plugin with the given variables.
* <p>
* This method should never be called manually.
*
* @param loader PluginLoader that is responsible for this plugin
* @param server Server instance that is running this plugin
* @param description PluginDescriptionFile containing metadata on this plugin
* @param dataFolder Folder containing the plugin's data
* @param file File containing this plugin
* @param classLoader ClassLoader which holds this plugin
*/
protected final void initialize(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
if (!initialized) {
this.initialized = true;
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);
}
}
}
示例6: findAsOf_given_intersectionWithNoHistory_then_joinNormalAndNoEffectiveDatePredicate
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
@Test
public void findAsOf_given_intersectionWithNoHistory_then_joinNormalAndNoEffectiveDatePredicate() {
ServerConfig serverConfig = new ServerConfig();
serverConfig.setName("pg");
serverConfig.setDefaultServer(true);
serverConfig.loadFromProperties();
serverConfig.addClass(CustomerExcludeM2M.class);
serverConfig.addClass(FeatureExcludeM2M.class);
serverConfig.addClass(ContactExcludeM2M.class);
serverConfig.addClass(Address.class);
serverConfig.addClass(Country.class);
EbeanServer localServer = EbeanServerFactory.create(serverConfig);
long epochMilli = OffsetDateTime.now().minusHours(3).toInstant().toEpochMilli();
Timestamp asOf = new Timestamp(epochMilli);
LoggedSql.start();
localServer.find(CustomerExcludeM2M.class)
.asOf(asOf)
.fetch("features")
.where().eq("name", "jack")
.findUnique();
List<String> loggedSql = LoggedSql.stop();
assertThat(loggedSql).hasSize(1);
String sqlSelect = loggedSql.get(0);
assertThat(sqlSelect.contains(" --bind(jack asOf ")).isTrue();
assertThat(sqlSelect.contains(" from customer_with_history t0 ")).isTrue();
assertThat(sqlSelect.contains(" join customer_feature t1z_ ")).isTrue();
assertThat(sqlSelect.contains(" t0.sys_period @> ?::timestamptz")).isTrue();
assertThat(!sqlSelect.contains(" t1z_.sys_period @> ?::timestamptz")).isTrue();
}
示例7: createServerConfig
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public static ServerConfig createServerConfig(DataSourceFactory dbConfig) {
ServerConfig config = new ServerConfig();
config.setName("main");
config.setDataSourceConfig(createDataSourceConfig(dbConfig));
config.setDefaultServer(true);
EbeanEntities.getEntities().forEach(config::addClass);
return config;
}