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


Java ServerConfig.setDefaultServer方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: configure

import io.ebean.config.ServerConfig; //导入方法依赖的package包/类
@Override
public void configure(final Env env, final Config conf, final Binder binder) {
  ServerConfig config = new ServerConfig();

  config.setName(name);

  Config cprops = conf.getConfig("ebean");
  if (conf.hasPath("ebean." + name)) {
    cprops = conf.getConfig("ebean." + name)
        .withFallback(cprops)
        .withoutPath(name);
  }

  Properties props = props(cprops);

  ContainerConfig container = new ContainerConfig();
  container.loadFromProperties(props);

  Key<DataSource> dskey = Key.get(DataSource.class, Names.named(name));
  DataSource ds = env.get(dskey)
      .orElseThrow(() -> new NoSuchElementException("DataSource missing: " + dskey));

  config.setDataSource(ds);
  config.setContainerConfig(container);
  config.loadFromProperties(props);
  config.setDefaultServer(cprops.getBoolean("defaultServer"));
  config.setRegister(cprops.getBoolean("register"));

  if (callback != null) {
    callback.accept(config, conf);
  }

  List<String> packages = config.getPackages();
  if (packages == null || packages.size() == 0) {
    packages = ImmutableList.of(conf.getString("application.ns"));
  }
  config.setPackages(packages);
  PKG.get().addAll(packages);

  EbeanManaged ebean = new EbeanManaged(conf, config);
  env.onStart(ebean::start);
  env.onStop(ebean::stop);
  /** Bind db key: */
  Consumer<Key<EbeanServer>> provider = k -> binder.bind(k).toProvider(ebean);
  ServiceKey keys = env.serviceKey();
  keys.generate(EbeanServer.class, name, provider);

  // Run enhancer once per JVM
  env.onStart(runEnhancer());
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:51,代码来源:Ebeanby.java

示例5: parse

import io.ebean.config.ServerConfig; //导入方法依赖的package包/类
/**
 * Reads the configuration and creates config for Ebean servers.
 *
 * @return a config for Ebean servers.
 */
public EbeanConfig parse() {

    EbeanParsedConfig ebeanConfig = EbeanParsedConfig.parseFromConfig(config);

    Map<String, ServerConfig> serverConfigs = new HashMap<>();

    for (Map.Entry<String, List<String>> entry: ebeanConfig.getDatasourceModels().entrySet()) {
        String key = entry.getKey();

        ServerConfig serverConfig = new ServerConfig();
        serverConfig.setName(key);
        serverConfig.loadFromProperties();

        setServerConfigDataSource(key, serverConfig);

        if (!ebeanConfig.getDefaultDatasource().equals(key)) {
            serverConfig.setDefaultServer(false);
        }

        Set<String> classes = getModelClasses(entry);
        addModelClassesToServerConfig(key, serverConfig, classes);

        serverConfigs.put(key, serverConfig);
    }

    return new DefaultEbeanConfig(ebeanConfig.getDefaultDatasource(), serverConfigs);
}
 
开发者ID:playframework,项目名称:play-ebean,代码行数:33,代码来源:DefaultEbeanConfig.java


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