• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ServerConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: cleanDB

import io.ebean.config.ServerConfig; //导入依赖的package包/类
private void cleanDB() throws SQLException {
    EbeanServer server = Ebean.getServer("default");
    DropAllDdlGenerator generator = new DropAllDdlGenerator((SpiEbeanServer)server, new ServerConfig());
    // Drop
    Database db = getDB();

    Statement statement = db.getConnection().createStatement();
    try {
        statement.executeUpdate("delete from play_evolutions");
        statement.close();
    } catch (SQLException e) {
        // OK
    }
    db.shutdown();
    generator.runScript(false, generator.generateDropDdl(), "drop all");
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:IntegrationTestCase.java


示例2: defaultEbeanServerConfig

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@SuppressWarnings("SpringJavaAutowiringInspection")
@Bean
@Primary
public ServerConfig defaultEbeanServerConfig() {
  ServerConfig config = new ServerConfig();

  config.setDataSource(dataSource());
  config.addPackage("org.springframework.data.ebean.sample.domain");
  config.setExternalTransactionManager(new SpringJdbcTransactionManager());

  config.loadFromProperties();
  config.setDefaultServer(true);
  config.setRegister(true);
  config.setAutoCommitMode(false);
  config.setExpressionNativeIlike(true);

  config.setCurrentUserProvider(new CurrentUserProvider() {
    @Override
    public Object currentUser() {
      return "test"; // just for test, can rewrite to get the currentUser from threadLocal
    }
  });

  return config;
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:26,代码来源:SampleConfig.java


示例3: getObject

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
  public EbeanServer getObject() throws Exception {

    ServerConfig config = new ServerConfig();
    config.setName("db");
    config.setCurrentUserProvider(currentUser);

//    // set the spring's datasource and transaction manager.
//    config.setDataSource(dataSource);
//    config.setExternalTransactionManager(new SpringAwareJdbcTransactionManager());

    config.loadFromProperties();
    
    // set as default and register so that Model can be
    // used if desired for save() and update() etc
    config.setDefaultServer(true);
    config.setRegister(true);

    return EbeanServerFactory.create(config);
  }
 
开发者ID:ebean-orm-examples,项目名称:example-springboot,代码行数:21,代码来源:EbeanFactoryBean.java


示例4: stop

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void stop() throws Exception {
  new MockUnit(Config.class, ServerConfig.class, EbeanServer.class)
      .expect(createEbean)
      .expect(withoutDdl)
      .expect(unit -> {
        EbeanServer ebean = unit.get(EbeanServer.class);
        ebean.shutdown(false, false);
      })
      .run(unit -> {
        EbeanManaged managed = new EbeanManaged(unit.get(Config.class),
            unit.get(ServerConfig.class));
        managed.stop();
        // ignored
        managed.stop();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:18,代码来源:EbeanManagedTest.java


示例5: setServerConfigDataSource

import io.ebean.config.ServerConfig; //导入依赖的package包/类
private void setServerConfigDataSource(String key, ServerConfig serverConfig) {
    try {
        serverConfig.setDataSource(new WrappingDatasource(dbApi.getDatabase(key).getDataSource()));
    } catch(Exception e) {
        throw new ConfigException.BadValue(
                "ebean." + key,
                e.getMessage(),
                e
        );
    }
}
 
开发者ID:playframework,项目名称:play-ebean,代码行数:12,代码来源:DefaultEbeanConfig.java


示例6: addModelClassesToServerConfig

import io.ebean.config.ServerConfig; //导入依赖的package包/类
private void addModelClassesToServerConfig(String key, ServerConfig serverConfig, Set<String> classes) {
    for (String clazz: classes) {
        try {
            serverConfig.addClass(Class.forName(clazz, true, environment.classLoader()));
        } catch (Exception e) {
            throw new ConfigException.BadValue(
                "ebean." + key,
                "Cannot register class [" + clazz + "] in Ebean server",
                e
            );
        }
    }
}
 
开发者ID:playframework,项目名称:play-ebean,代码行数:14,代码来源:DefaultEbeanConfig.java


示例7: configureNoPackage

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void configureNoPackage() throws Exception {
  new MockUnit(Env.class, Binder.class)
      .expect(containerConfig)
      .expect(unit -> {
        ServerConfig serverConfig = unit.mockConstructor(ServerConfig.class);

        serverConfig.setName("db");
        expect(serverConfig.getPackages()).andReturn(null);
        serverConfig.setPackages(Arrays.asList("my.model"));
        serverConfig.setContainerConfig(unit.get(ContainerConfig.class));
        serverConfig.setDataSource(isA(DataSource.class));
        serverConfig.loadFromProperties(isA(Properties.class));
        serverConfig.setDefaultServer(true);
        serverConfig.setRegister(true);

        unit.registerMock(ServerConfig.class, serverConfig);
      })
      .expect(ebeanProperties())
      .expect(binder)
      .expect(onStop)
      .expect(onStart)
      .run(unit -> {
        new Ebeanby("db")
            .configure(unit.get(Env.class), config(), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:28,代码来源:EbeanbyTest.java


示例8: configurePackages

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void configurePackages() throws Exception {
  new MockUnit(Env.class, Binder.class)
      .expect(containerConfig)
      .expect(unit -> {
        ServerConfig serverConfig = unit.mockConstructor(ServerConfig.class);

        serverConfig.setName("db");
        serverConfig.addPackage("foo");
        serverConfig.addPackage("bar");
        expect(serverConfig.getPackages()).andReturn(Arrays.asList("foo", "bar"));
        serverConfig.setPackages(Arrays.asList("foo", "bar"));
        serverConfig.setContainerConfig(unit.get(ContainerConfig.class));
        serverConfig.setDataSource(isA(DataSource.class));
        serverConfig.loadFromProperties(isA(Properties.class));
        serverConfig.setDefaultServer(true);
        serverConfig.setRegister(true);

        unit.registerMock(ServerConfig.class, serverConfig);
      })
      .expect(ebeanProperties())
      .expect(binder)
      .expect(onStop)
      .expect(onStart)
      .run(unit -> {
        new Ebeanby("db")
            .doWith((final ServerConfig conf) -> {
              conf.addPackage("foo");
              conf.addPackage("bar");
            })
            .configure(unit.get(Env.class), config(), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:34,代码来源:EbeanbyTest.java


示例9: configureEmptyPackage

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void configureEmptyPackage() throws Exception {
  new MockUnit(Env.class, Binder.class)
      .expect(containerConfig)
      .expect(unit -> {
        ServerConfig serverConfig = unit.mockConstructor(ServerConfig.class);

        serverConfig.setName("db");
        expect(serverConfig.getPackages()).andReturn(ImmutableList.of());
        serverConfig.setPackages(Arrays.asList("my.model"));
        serverConfig.setContainerConfig(unit.get(ContainerConfig.class));
        serverConfig.setDataSource(isA(DataSource.class));
        serverConfig.loadFromProperties(isA(Properties.class));
        serverConfig.setDefaultServer(true);
        serverConfig.setRegister(true);

        unit.registerMock(ServerConfig.class, serverConfig);
      })
      .expect(ebeanProperties())
      .expect(binder)
      .expect(onStop)
      .expect(onStart)
      .run(unit -> {
        new Ebeanby("db")
            .configure(unit.get(Env.class), config(), unit.get(Binder.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:28,代码来源:EbeanbyTest.java


示例10: newEbeanManaged

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void newEbeanManaged() throws Exception {
  new MockUnit(Config.class, ServerConfig.class)
      .run(unit -> {
        new EbeanManaged(unit.get(Config.class), unit.get(ServerConfig.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:8,代码来源:EbeanManagedTest.java


示例11: start

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void start() throws Exception {
  new MockUnit(Config.class, ServerConfig.class, EbeanServer.class)
      .expect(createEbean)
      .expect(withoutDdl)
      .run(unit -> {
        new EbeanManaged(unit.get(Config.class), unit.get(ServerConfig.class)).start();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:10,代码来源:EbeanManagedTest.java


示例12: startWithDdl

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void startWithDdl() throws Exception {
  new MockUnit(Config.class, ServerConfig.class, EbeanServer.class)
      .expect(createEbean)
      .expect(withDdl)
      .run(unit -> {
        new EbeanManaged(unit.get(Config.class), unit.get(ServerConfig.class)).start();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:10,代码来源:EbeanManagedTest.java


示例13: startShouldIgnoreOn2ndCall

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void startShouldIgnoreOn2ndCall() throws Exception {
  new MockUnit(Config.class, ServerConfig.class, EbeanServer.class)
      .expect(createEbean)
      .expect(withDdl)
      .run(unit -> {
        EbeanManaged managed = new EbeanManaged(unit.get(Config.class),
            unit.get(ServerConfig.class));
        managed.start();
        // ignored
        managed.start();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:14,代码来源:EbeanManagedTest.java


示例14: get

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Test
public void get() throws Exception {
  new MockUnit(Config.class, ServerConfig.class, EbeanServer.class)
      .expect(createEbean)
      .expect(withoutDdl)
      .run(unit -> {
        EbeanManaged managed = new EbeanManaged(unit.get(Config.class),
            unit.get(ServerConfig.class));
        assertEquals(unit.get(EbeanServer.class), managed.get());
        assertEquals(unit.get(EbeanServer.class), managed.get());
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:13,代码来源:EbeanManagedTest.java


示例15: get

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
public EbeanServer get() {
    String datasourceUrl = mConfiguration.getString(SERVER_CONFIG_PREFIX + "url");
    String datasourceUsername = mConfiguration.getString(SERVER_CONFIG_PREFIX + "username");
    String datasourcePassword = mConfiguration.getString(SERVER_CONFIG_PREFIX + "password");
    String datasourceDriver = mConfiguration.getString(SERVER_CONFIG_PREFIX + "driver");
    String databaseName = mConfiguration.getString(SERVER_CONFIG_PREFIX + "name");
    String platformName = mConfiguration.getString(SERVER_CONFIG_PREFIX + "platformName");

    DataSourceConfig dataSourceConfig = new DataSourceConfig();
    dataSourceConfig.setUrl(datasourceUrl);
    dataSourceConfig.setDriver(datasourceDriver);
    dataSourceConfig.setUsername(datasourceUsername);
    dataSourceConfig.setPassword(datasourcePassword);

    dataSourceConfig.setHeartbeatFreqSecs(60);
    dataSourceConfig.setHeartbeatTimeoutSeconds(30);
    dataSourceConfig.setMinConnections(3);
    dataSourceConfig.setMaxConnections(30);
    dataSourceConfig.setLeakTimeMinutes(1);
    dataSourceConfig.setMaxInactiveTimeSecs(30);
    dataSourceConfig.setWaitTimeoutMillis(1000 * 60);
    dataSourceConfig.setTrimPoolFreqSecs(60);
    dataSourceConfig.setCaptureStackTrace(true);

    ArrayList<Class<?>> models = new ArrayList<>();
    models.add(Credentials.class);
    models.add(Message.class);
    models.add(PayloadElement.class);
    models.add(Recipient.class);
    models.add(PlatformFailure.class);
    models.add(Task.class);

    ServerConfig serverConfig = new ServerConfig();
    serverConfig.setDataSourceConfig(dataSourceConfig);
    serverConfig.setName(databaseName);
    serverConfig.setDatabasePlatformName(platformName);
    serverConfig.setRegister(true);
    serverConfig.setDefaultServer(true);
    serverConfig.setUpdatesDeleteMissingChildren(false);
    serverConfig.setClasses(models);
    serverConfig.setDdlGenerate(false);
    serverConfig.setUpdateChangesOnly(false);

    return EbeanServerFactory.create(serverConfig);
}
 
开发者ID:splendidbits,项目名称:play-pushservices,代码行数:47,代码来源:PushServicesEbeanServerProvider.java


示例16: DropAllDdlGenerator

import io.ebean.config.ServerConfig; //导入依赖的package包/类
public DropAllDdlGenerator(SpiEbeanServer server, ServerConfig serverConfig) {
    super(server, serverConfig);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:4,代码来源:DropAllDdlGenerator.java


示例17: defaultEbeanServer

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Bean
@Primary
public EbeanServer defaultEbeanServer(ServerConfig defaultEbeanServerConfig) {
  return EbeanServerFactory.create(defaultEbeanServerConfig);
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:6,代码来源:SampleConfig.java


示例18: create

import io.ebean.config.ServerConfig; //导入依赖的package包/类
/**
 * Create the Ignite ServerCacheFactory implementation.
 */
@Override
public ServerCacheFactory create(ServerConfig config, BackgroundExecutor executor) {
  return new IgCacheFactory(config, executor);
}
 
开发者ID:ebean-orm,项目名称:ebean-ignite,代码行数:8,代码来源:IgCachePlugin.java


示例19: create

import io.ebean.config.ServerConfig; //导入依赖的package包/类
@Override
public DocStoreIntegration create(SpiServer server) {

  ServerConfig serverConfig = server.getServerConfig();

  Object objectMapper = serverConfig.getObjectMapper();

  DocStoreConfig docStoreConfig = serverConfig.getDocStoreConfig();

  JsonFactory jsonFactory = new JsonFactory();
  IndexQueueWriter indexQueueWriter = new BaseIndexQueueWriter(server, "eb_elastic_queue");
  IndexMessageSender messageSender = new BaseHttpMessageSender(docStoreConfig);

  ElasticUpdateProcessor updateProcessor = new ElasticUpdateProcessor(server, indexQueueWriter, jsonFactory, objectMapper, messageSender, docStoreConfig.getBulkBatchSize());

  ElasticDocumentStore docStore = new ElasticDocumentStore(server, updateProcessor, messageSender, jsonFactory);

  return new Components(updateProcessor, docStore);
}
 
开发者ID:ebean-orm,项目名称:ebean-elastic,代码行数:20,代码来源:ElasticDocStoreFactory.java


示例20: onStart

import io.ebean.config.ServerConfig; //导入依赖的package包/类
public void onStart(ServerConfig serverConfig) {
    serverConfig.setDatabaseSequenceBatchSize(1);
}
 
开发者ID:playframework,项目名称:play-ebean,代码行数:4,代码来源:MyServerConfigStartup.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TableCursor类代码示例发布时间:2022-05-22
下一篇:
Java CraftItemEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap