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


Java EbeanServerFactory类代码示例

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


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

示例1: SQLOfflineTeamHandler

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例2: SQLOfflineGameHandler

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例3: SQLOfflineUserHandler

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例4: init

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例5: InMemoryEbeanServer

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例6: run

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例7: run

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例8: createEbeanServerInstance

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例9: init

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例10: dataSourceProvided

import com.avaje.ebean.EbeanServerFactory; //导入依赖的package包/类
@Override
protected void dataSourceProvided(DataSource dataSource, DataSourceConfig dsConfig) {
    ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, dsConfig, this);
    ebeanConfig.setDataSource(dataSource);
    app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig));
    ebean = EbeanServerFactory.create(ebeanConfig);
}
 
开发者ID:actframework,项目名称:act-ebean,代码行数:8,代码来源:EbeanService.java

示例11: createDataSource

import com.avaje.ebean.EbeanServerFactory; //导入依赖的package包/类
@Override
protected DataSource createDataSource() {
    ebeanConfig = new EbeanConfigAdaptor().adaptFrom(this.config, this.config.dataSourceConfig, this);
    app().eventBus().trigger(new EbeanConfigLoaded(ebeanConfig));
    ebean = EbeanServerFactory.create(ebeanConfig);
    return ebeanConfig.getDataSource();
}
 
开发者ID:actframework,项目名称:act-ebean,代码行数:8,代码来源:EbeanService.java

示例12: setup

import com.avaje.ebean.EbeanServerFactory; //导入依赖的package包/类
public static DataAccessConfigService setup(String readDataSourceName,
    String readWriteDataSourceName) throws Exception {

    DataAccessConfigService instance = new DataAccessConfigService(
        EbeanServerFactory.create(readDataSourceName),
        EbeanServerFactory.create(readWriteDataSourceName));

    return instance;
}
 
开发者ID:shailesh17,项目名称:spring-boot-ebean-starter,代码行数:10,代码来源:DataAccessConfigService.java

示例13: initialize

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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

示例14: findAsOf_given_intersectionWithNoHistory_then_joinNormalAndNoEffectiveDatePredicate

import com.avaje.ebean.EbeanServerFactory; //导入依赖的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();

}
 
开发者ID:ebean-orm-examples,项目名称:avaje-ebeanorm-examples,代码行数:39,代码来源:CustomerFindWithManyToMany.java

示例15: initialize

import com.avaje.ebean.EbeanServerFactory; //导入依赖的package包/类
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            ServerConfig config = new ServerConfig();
            config.setDefaultServer(true);
            final DataSourceConfig dataSourceConfig = new DataSourceConfig();
            dataSourceConfig
                    .setUrl("jdbc:sqlite:C:/Users/markus/Entwickeln/Java/CraftBukkitTestServer/plugins/SmoothWorldUpdater/SmoothWorldUpdater.db");
            dataSourceConfig.setDriver("org.sqlite.JDBC");
            dataSourceConfig.setMinConnections(1);
            dataSourceConfig.setMaxConnections(25);
            dataSourceConfig.setUsername("");
            dataSourceConfig.setPassword("");
            dataSourceConfig.setIsolationLevel(TransactionIsolation
                    .getLevel("READ_UNCOMMITTED"));
            config.setName("default");
            config.setDataSourceConfig(dataSourceConfig);
            config.addClass(de.hapm.swu.data.ChunkInfo.class);
            config.addClass(de.hapm.swu.data.ChunkInfoId.class);
            config.addClass(de.hapm.swu.data.BlockTypeInfo.class);
            config.addClass(de.hapm.swu.data.WorldInfo.class);
            server = EbeanServerFactory.create(config);
            visualizer = new ChunkInfoVisualizer();
            visualizer.setProvider(new EbeanChunkInfoProvider(server));
            chunkInfoPanel.setVisualizer(visualizer);
            chunkInfoPanel.start();
        }
    });
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    chunkInfoPanel = new ChunkInfoVisualizerPanel();
    frame.getContentPane().add(chunkInfoPanel, BorderLayout.CENTER);
}
 
开发者ID:hapm,项目名称:swu,代码行数:40,代码来源:ChunkVisualizerMainForm.java


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