当前位置: 首页>>代码示例>>Java>>正文


Java ServerConfig类代码示例

本文整理汇总了Java中com.avaje.ebean.config.ServerConfig的典型用法代码示例。如果您正苦于以下问题:Java ServerConfig类的具体用法?Java ServerConfig怎么用?Java ServerConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerConfig类属于com.avaje.ebean.config包,在下文中一共展示了ServerConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureDbConfig

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
public void configureDbConfig(ServerConfig config) {
    Validate.notNull(config, "Config cannot be null");

    DataSourceConfig ds = new DataSourceConfig();
    ds.setDriver(configuration.getString("database.driver"));
    ds.setUrl(configuration.getString("database.url"));
    ds.setUsername(configuration.getString("database.username"));
    ds.setPassword(configuration.getString("database.password"));
    ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation")));

    if (ds.getDriver().contains("sqlite")) {
        config.setDatabasePlatform(new SQLitePlatform());
        config.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
    }

    config.setDataSourceConfig(ds);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:19,代码来源:CraftServer.java

示例2: SQLOfflineTeamHandler

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
public SQLOfflineTeamHandler()
{
    ServerConfig config = new ServerConfig();
    config.setDataSourceConfig(MWAPI.getConfig().getDataSourceConfig());
    config.addClass(BasicTeam.class);

    server = EbeanServerFactory.create(config);

    try
    {
        server.find(BasicTeam.class).findRowCount();
    }
    catch (Exception e)
    {
        DdlGenerator gen = ((DefaultServer) server).getDdlGenerator();
        gen.runScript(true, gen.generateCreateDdl());
    }
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:19,代码来源:SQLOfflineTeamHandler.java

示例3: SQLOfflineGameHandler

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
public SQLOfflineGameHandler()
{
    ServerConfig config = new ServerConfig();
    config.setDataSourceConfig(MWAPI.getConfig().getDataSourceConfig());
    config.addClass(BasicGame.class);
    config.addClass(MapScalarTypeConverter.class);

    server = EbeanServerFactory.create(config);

    try
    {
        server.find(BasicGame.class).findRowCount();
    }
    catch (Exception e)
    {
        DdlGenerator gen = ((DefaultServer) server).getDdlGenerator();
        gen.runScript(true, gen.generateCreateDdl());
    }
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:20,代码来源:SQLOfflineGameHandler.java

示例4: SQLOfflineUserHandler

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
public SQLOfflineUserHandler()
{
    ServerConfig config = new ServerConfig();
    config.setDataSourceConfig(MWAPI.getConfig().getDataSourceConfig());
    config.addClass(BasicUser.class);

    server = EbeanServerFactory.create(config);

    try
    {
        server.find(BasicUser.class).findRowCount();
    }
    catch (Exception e)
    {
        DdlGenerator gen = ((DefaultServer) server).getDdlGenerator();
        gen.runScript(true, gen.generateCreateDdl());
    }
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:19,代码来源:SQLOfflineUserHandler.java

示例5: adaptFrom

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourceConfig dsConfig,  SqlDbService svc) {
    ServerConfig config = new ServerConfig();

    config.setName(svc.id());
    config.setDataSourceConfig(adaptFrom(dsConfig, svc));

    config.setDdlGenerate(actConfig.ddlGeneratorConfig.create);
    config.setDdlRun(actConfig.ddlGeneratorConfig.create);
    config.setDdlCreateOnly(!actConfig.ddlGeneratorConfig.drop);

    config.setNamingConvention(namingConvention(actConfig));

    Set<Class> modelClasses = svc.modelClasses();
    if (null != modelClasses && !modelClasses.isEmpty()) {
        for (Class modelClass : modelClasses) {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace(S.concat("add model class into Ebean config: ", modelClass.getName()));
            }
            config.addClass(modelClass);
        }
    }

    return config;
}
 
开发者ID:actframework,项目名称:act-ebean,代码行数:25,代码来源:EbeanConfigAdaptor.java

示例6: init

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
/**
 * Initialize the database (by running patches if required)
 */
private void init(Configuration configuration) {
    // Creates the listeners map
    listeners = Collections.synchronizedMap(new HashMap<>());

    // Register the Ebean server as the default one
    ServerConfig serverConfig = getEbeanConfig().serverConfigs().get(getEbeanServerDefaultName());
    serverConfig.setBackgroundExecutorShutdownSecs(getEbeanCacheShutdownDelay());
    serverConfig.setBackgroundExecutorCorePoolSize(getEbeanCacheThreadPoolSize());
    serverConfig.add(new CustomBeanPersistController(listeners));
    Ebean.register(EbeanServerFactory.create(serverConfig), true);

    // Unregister ebean from the Runtime (Shutdown hooks are bad !)
    BizDockEbeanShutdownManager.killThisBloodyShutdownHook();

    if (isPatcheable(configuration)) {
        log.info("Running the patch for the release " + getRelease());
        patch(log);
        updateRelease();
    } else {
        log.info("The application is up to date, no patch to run");
    }
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:26,代码来源:AbstractDatabaseDependencyServiceImpl.java

示例7: configureDbConfig

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
public void configureDbConfig(ServerConfig config) {
    Validate.notNull(config, "Config cannot be null");

    DataSourceConfig ds = new DataSourceConfig();
    ds.setDriver(configuration.getString("database.driver"));
    ds.setUrl(configuration.getString("database.url"));
    ds.setUsername(configuration.getString("database.username"));
    ds.setPassword(configuration.getString("database.password"));
    ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation")));

    if (ds.getDriver().contains("sqlite")) {
        config.setDatabasePlatform(new SQLitePlatform());
        config.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
    }

    config.setDataSourceConfig(ds);
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:18,代码来源:CraftServer.java

示例8: 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();
}
 
开发者ID:Lugribossk,项目名称:dropwizard-experiment,代码行数:24,代码来源:InMemoryEbeanServer.java

示例9: run

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
    // The existing database with migrations managed by Liquibase.
    DataSourceFactory outdatedDb = configuration.getDatabaseConfig();

    try (CloseableLiquibase outdatedLiquibase = createLiquibase(outdatedDb)) {
        // A temporary database that starts out empty and then gets the autogenerated Ebean table definitions applied.
        DataSourceFactory freshDb = EbeanConfigUtils.clone(outdatedDb);
        String url = outdatedDb.getUrl();
        freshDb.setUrl(url.substring(0, url.lastIndexOf("/")) + "/migrationdiff");

        // Creating the Ebean server makes it apply its table definitions to the database immediately.
        ServerConfig serverConfig = EbeanConfigUtils.createServerConfig(freshDb);
        serverConfig.setDdlGenerate(true);
        serverConfig.setDdlRun(true);
        EbeanServer ebeanServer = EbeanServerFactory.create(serverConfig);

        try (CloseableLiquibase freshLiquibase = createLiquibase(freshDb)) {
            // Create and print the differences between the two databases, i.e. a migration that should be applied to update to the newest Ebean definitions.
            DiffResult diff = outdatedLiquibase.diff(freshLiquibase.getDatabase(), outdatedLiquibase.getDatabase(), CompareControl.STANDARD);
            DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diff, new DiffOutputControl(false, false, true));
            diffToChangeLog.print(System.out);
        }
    }
}
 
开发者ID:Lugribossk,项目名称:dropwizard-experiment,代码行数:26,代码来源:DbDiffCommand.java

示例10: run

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
public void run(HasDatabaseConfiguration configuration, Environment environment) throws Exception {
    ExtendedDataSourceFactory dbConfig = configuration.getDatabaseConfig();
    log.info("Connecting to database on '{}' with username '{}'.", dbConfig.getUrl(), dbConfig.getUser());

    if (dbConfig.isMigrationsEnabled()) {
        try {
            applyMigrations(dbConfig, environment.metrics());
        } catch (Exception e) {
            log.error("Error applying database migrations! {}", e.getMessage());
            throw e;
        }
    } else {
        log.info("Database migrations disabled.");
    }

    ServerConfig serverConfig = EbeanConfigUtils.createServerConfig(dbConfig);
    ebeanServer = EbeanServerFactory.create(serverConfig);
    Preconditions.checkNotNull(ebeanServer);

    environment.healthChecks().register("ebean-" + ebeanServer.getName(), new EbeanHealthCheck(ebeanServer));
}
 
开发者ID:Lugribossk,项目名称:dropwizard-experiment,代码行数:23,代码来源:EbeanBundle.java

示例11: 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;
}
 
开发者ID:tcplugins,项目名称:tcDebRepository,代码行数:36,代码来源:EbeanServerProvider.java

示例12: 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;
}
 
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:15,代码来源:DbTestsApplication.java

示例13: 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);
    }
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:32,代码来源:JavaPlugin.java

示例14: hookLifecycleInterceptors

import com.avaje.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
public void hookLifecycleInterceptors() {
    App.instance().eventBus().bind(PreEbeanCreation.class, new ActEventListenerBase<PreEbeanCreation>("storage:hook-ebean-lifecycle-interceptor") {
        @Override
        public void on(PreEbeanCreation event) throws Exception {
            ServerConfig config = event.source();
            BeanPostLoad postLoad = new StorageFieldConverter(ssm());
            config.add(postLoad);
            BeanPersistController persistController = (BeanPersistController) postLoad;
            config.add(persistController);
        }
    });
}
 
开发者ID:actframework,项目名称:act-storage,代码行数:14,代码来源:EbeanDbHooker.java

示例15: 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);
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-API,代码行数:47,代码来源:JavaPlugin.java


注:本文中的com.avaje.ebean.config.ServerConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。