mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 06:45:21 +00:00
Merge branch 'add-start-to-plugins' into ebean-new
# Conflicts: # ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java # ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlPlugin.java
This commit is contained in:
commit
7256d97841
9 files changed
+80
-139
No files matched your search
@@ -1,21 +0,0 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
/**
|
||||
* DDL generate and run for drop all/create all.
|
||||
*/
|
||||
public interface SpiDdlGenerator {
|
||||
|
||||
/**
|
||||
* Generate and run the DDL for drop-all and create-all scripts.
|
||||
* <p>
|
||||
* Run based on on property settings for ebean.ddl.generate
|
||||
*/
|
||||
void generateDdl();
|
||||
|
||||
/**
|
||||
* Runs the created DDL files.
|
||||
* <p>
|
||||
* Run based on on property settings for ebean.ddl.run etc.
|
||||
*/
|
||||
void runDdl();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
/**
|
||||
* Provides the DDL Generator for create-all/drop-all.
|
||||
*/
|
||||
public interface SpiDdlGeneratorProvider {
|
||||
|
||||
/**
|
||||
* Provide the DDL generator.
|
||||
*/
|
||||
SpiDdlGenerator generator(SpiEbeanServer server);
|
||||
|
||||
}
|
||||
@@ -161,7 +161,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
private final ReadAuditLogger readAuditLogger;
|
||||
private final CQueryEngine cqueryEngine;
|
||||
private final List<Plugin> serverPlugins;
|
||||
private final SpiDdlGenerator ddlGenerator;
|
||||
private final ScriptRunner scriptRunner;
|
||||
private final ExpressionFactory expressionFactory;
|
||||
private final SpiBackgroundExecutor backgroundExecutor;
|
||||
@@ -224,7 +223,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
this.metaInfoManager = new DefaultMetaInfoManager(this);
|
||||
this.serverPlugins = config.getPlugins();
|
||||
this.tempFileProvider = config.getConfig().getTempFileProvider();
|
||||
this.ddlGenerator = config.initDdlGenerator(this);
|
||||
this.scriptRunner = new DScriptRunner(this);
|
||||
|
||||
configureServerPlugins();
|
||||
@@ -254,9 +252,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
* Execute all the plugins with an online flag indicating the DB is up or not.
|
||||
*/
|
||||
public void executePlugins(boolean online) {
|
||||
if (!config.isDocStoreOnly()) {
|
||||
ddlGenerator.generateDdl();
|
||||
}
|
||||
for (Plugin plugin : serverPlugins) {
|
||||
plugin.online(online);
|
||||
}
|
||||
@@ -386,8 +381,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
migrationRunner.setPlatform(config.getDatabasePlatform().getPlatform().base().name().toLowerCase());
|
||||
migrationRunner.loadProperties(config.getProperties());
|
||||
migrationRunner.run(config.getDataSource());
|
||||
} else if (config.isDdlRun()) {
|
||||
ddlGenerator.runDdl();
|
||||
}
|
||||
for (Plugin plugin : serverPlugins) {
|
||||
plugin.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -601,31 +601,4 @@ public final class InternalConfiguration {
|
||||
return new QueryPlanLoggerExplain();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the DDL generator.
|
||||
*/
|
||||
public SpiDdlGenerator initDdlGenerator(SpiEbeanServer server) {
|
||||
final SpiDdlGeneratorProvider service = service(SpiDdlGeneratorProvider.class);
|
||||
return service == null ? new NoopDdl(server.config().isDdlRun()) : service.generator(server);
|
||||
}
|
||||
|
||||
private static class NoopDdl implements SpiDdlGenerator {
|
||||
private final boolean ddlRun;
|
||||
NoopDdl(boolean ddlRun) {
|
||||
this.ddlRun = ddlRun;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateDdl() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runDdl() {
|
||||
if (ddlRun) {
|
||||
CoreLog.log.error("Configured to run DDL but ebean-ddl-generator is not in the classpath (or ebean-test in the test classpath?)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user