Skip to content

Commit

Permalink
Change args of FileMigrationLoaderFactory#create()
Browse files Browse the repository at this point in the history
As per @h3adache 's suggestion, the method now takes `SelectedPaths` and `Environment` to give custom implementations more flexibility.
  • Loading branch information
harawata committed Dec 17, 2017
1 parent ad97fd5 commit b95e393
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Expand Up @@ -15,9 +15,8 @@
*/
package org.apache.ibatis.migration;

import java.io.File;
import java.util.Properties;
import org.apache.ibatis.migration.options.SelectedPaths;

public interface FileMigrationLoaderFactory {
MigrationLoader create(File scriptsDir, String charset, Properties variables);
MigrationLoader create(SelectedPaths paths, Environment environment);
}
Expand Up @@ -303,17 +303,16 @@ private File getCustomDriverPath() {
}

protected MigrationLoader getMigrationLoader() {
File scriptPath = paths.getScriptPath();
String scriptCharset = environment().getScriptCharset();
Properties variables = environment().getVariables();
Environment env = environment();
MigrationLoader migrationLoader = null;
for (FileMigrationLoaderFactory factory : ServiceLoader.load(FileMigrationLoaderFactory.class)) {
if (migrationLoader != null) {
throw new MigrationException("Found multiple implementations of FileMigrationLoaderFactory via SPI.");
}
migrationLoader = factory.create(scriptPath, scriptCharset, variables);
migrationLoader = factory.create(paths, env);
}
return migrationLoader != null ? migrationLoader : new FileMigrationLoader(scriptPath, scriptCharset, variables);
return migrationLoader != null ? migrationLoader
: new FileMigrationLoader(paths.getScriptPath(), env.getScriptCharset(), env.getVariables());
}

protected MigrationHook createUpHook() {
Expand Down

0 comments on commit b95e393

Please sign in to comment.