#1147 - Refactor move DbMigration internals into io.ebeaninternal - change to use DbMigration.create() - move DbMigrationFactory.create() method

This commit is contained in:
rob bygrave
2017-10-04 21:06:55 +13:00
parent 9f9ec8ef9f
commit f85fa772bf
2 changed files with 8 additions and 17 deletions
@@ -6,6 +6,8 @@ import io.ebean.config.ServerConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import java.io.IOException;
import java.util.Iterator;
import java.util.ServiceLoader;
/**
* Generates DDL migration scripts based on changes to the current model.
@@ -39,7 +41,12 @@ public interface DbMigration {
* Create a DbMigration implementation to use.
*/
static DbMigration create() {
return DbMigrationFactory.create();
Iterator<DbMigration> loader = ServiceLoader.load(DbMigration.class).iterator();
if (loader.hasNext()) {
return loader.next();
}
throw new IllegalStateException("No service implementation found for DbMigration?");
}
/**
@@ -1,16 +0,0 @@
package io.ebean.dbmigration;
import java.util.Iterator;
import java.util.ServiceLoader;
class DbMigrationFactory {
static DbMigration create() {
Iterator<DbMigration> loader = ServiceLoader.load(DbMigration.class).iterator();
if (loader.hasNext()) {
return loader.next();
}
throw new IllegalStateException("No service implementation found for DbMigration?");
}
}