Package com.avaje.ebean.config

Examples of com.avaje.ebean.config.ServerConfig


  @SuppressWarnings({ "unchecked", "rawtypes" })
  private static EbeanServer createServer(String name, DataSource dataSource)
  {
    EbeanServer result = null;
    ServerConfig cfg = new ServerConfig();
    cfg.loadFromProperties();
    cfg.setName(name);
    cfg.setClasses((List) Play.classloader.getAllClasses());
    cfg.setDataSource(new EbeanDataSourceWrapper(dataSource));
    cfg.setRegister("default".equals(name));
    cfg.setDefaultServer("default".equals(name));
    cfg.add(new EbeanModelAdapter());
    try {
      result = EbeanServerFactory.create(cfg);
    } catch (Throwable t) {
      Logger.error("Failed to create ebean server (%s)", t.getMessage());
    }
View Full Code Here


   * @return
   * @throws SQLException
   * @Deprecated SQLStorage cannot save at the moment
   */
  public SQLShopStorage getSQLShopStorageBukkit () throws SQLException {
    ServerConfig  serverConfig  = new ServerConfig();
    scs.getServer().configureDbConfig(serverConfig);
   
    String   url      = serverConfig.getDataSourceConfig().getUrl();
    String  username  = serverConfig.getDataSourceConfig().getUsername();
    String  password  = serverConfig.getDataSourceConfig().getPassword();
    return new SQLShopStorage    (this, url, username, password);
  }
View Full Code Here

        ds.setUsername(username);
        ds.setPassword(password);
        ds.setIsolationLevel(TransactionIsolation.getLevel(isolation));

        //Setup the server configuration
        ServerConfig sc = new ServerConfig();
        sc.setDefaultServer(false);
        sc.setRegister(false);
        sc.setName(ds.getUrl().replaceAll("[^a-zA-Z0-9]", ""));

        //Get all persistent classes
        List<Class<?>> classes = getDatabaseClasses();

        //Do a sanity check first
        if (classes.isEmpty()) {
            //Exception: There is no use in continuing to load this database
            throw new RuntimeException("Database has been enabled, but no classes are registered to it");
        }

        //Register them with the EbeanServer
        sc.setClasses(classes);

        //Check if the SQLite JDBC supplied with Bukkit is being used
        if (ds.getDriver().equalsIgnoreCase("org.sqlite.JDBC")) {
            //Remember the database is a SQLite-database
            usingSQLite = true;

            //Modify the platform, as SQLite has no AUTO_INCREMENT field
            sc.setDatabasePlatform(new SQLitePlatform());
            sc.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
        }

        prepareDatabaseAdditionalConfig(ds, sc);

        //Finally the data source
        sc.setDataSourceConfig(ds);

        //Store the ServerConfig
        serverConfig = sc;
    }
View Full Code Here

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

            if (ebeanConf != null) {
                for (String key: ebeanConf.keys()) {

                    ServerConfig config = new ServerConfig();
                    config.setName(key);
                    config.loadFromProperties();
                    try {
                        config.setDataSource(new WrappingDatasource(dbApi.getDatabase(key).getDataSource()));
                    } catch(Exception e) {
                        throw ebeanConf.reportError(
                            key,
                            e.getMessage(),
                            e
                        );
                    }

                    if (defaultServer.equals(key)) {
                        config.setDefaultServer(true);
                    }

                    String[] toLoad = ebeanConf.getString(key).split(",");
                    Set<String> classes = new HashSet<String>();
                    for (String load: toLoad) {
                        load = load.trim();
                        if (load.endsWith(".*")) {
                            classes.addAll(play.libs.Classpath.getTypes(environment, load.substring(0, load.length()-2)));
                        } else {
                            classes.add(load);
                        }
                    }
                    for (String clazz: classes) {
                        try {
                            config.addClass(Class.forName(clazz, true, environment.classLoader()));
                        } catch (Throwable e) {
                            throw ebeanConf.reportError(
                                key,
                                "Cannot register class [" + clazz + "] in Ebean server",
                                e
View Full Code Here

TOP

Related Classes of com.avaje.ebean.config.ServerConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.