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


Java ServerConfig类代码示例

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


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


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