HHH-13210 Don't log about running a script of type ScriptSourceInputNonExistentImpl

This commit is contained in:
Sanne Grinovero 2019-01-17 17:11:14 +00:00 committed by Guillaume Smet
parent e8b88f5350
commit 9c63819000
6 changed files with 26 additions and 4 deletions

View File

@ -463,7 +463,6 @@ public class SchemaCreatorImpl implements SchemaCreator {
if ( importScriptSetting != null ) {
final ScriptSourceInput importScriptInput = interpretScriptSourceSetting( importScriptSetting, classLoaderService, charsetName );
log.executingImportScript( importScriptInput.toString() );
importScriptInput.prepare();
try {
for ( String command : importScriptInput.read( commandExtractor ) ) {
@ -490,7 +489,6 @@ public class SchemaCreatorImpl implements SchemaCreator {
final ScriptSourceInput importScriptInput = interpretLegacyImportScriptSetting( resourceName, classLoaderService, charsetName );
importScriptInput.prepare();
try {
log.executingImportScript( importScriptInput.toString() );
for ( String command : importScriptInput.read( commandExtractor ) ) {
applySqlString( command, formatter, options, targets );
}

View File

@ -11,7 +11,10 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
import org.hibernate.tool.schema.internal.SchemaCreatorImpl;
import org.hibernate.tool.schema.spi.ScriptSourceInput;
/**
@ -20,13 +23,18 @@ import org.hibernate.tool.schema.spi.ScriptSourceInput;
* @author Steve Ebersole
*/
public abstract class AbstractScriptSourceInput implements ScriptSourceInput {
private static final CoreMessageLogger log = CoreLogging.messageLogger( SchemaCreatorImpl.class );
protected abstract Reader reader();
@Override
public void prepare() {
// by default there is nothing to do
log.executingImportScript( getScriptDescription() );
}
protected abstract String getScriptDescription();
@Override
public List<String> read(ImportSqlCommandExtractor commandExtractor) {
final String[] commands = commandExtractor.extractCommands( reader() );

View File

@ -56,6 +56,11 @@ public class ScriptSourceInputFromFile extends AbstractScriptSourceInput impleme
this.reader = toReader( file, charsetName );
}
@Override
protected String getScriptDescription() {
return file.getAbsolutePath();
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private static Reader toReader(File file, String charsetName) {
if ( ! file.exists() ) {

View File

@ -32,6 +32,11 @@ public class ScriptSourceInputFromReader extends AbstractScriptSourceInput imple
return reader;
}
@Override
protected String getScriptDescription() {
return "[injected ScriptSourceInputFromReader script]";
}
@Override
public String toString() {
return "ScriptSourceInputFromReader()";

View File

@ -65,6 +65,11 @@ public class ScriptSourceInputFromUrl extends AbstractScriptSourceInput implemen
}
}
@Override
protected String getScriptDescription() {
return url.toExternalForm();
}
@Override
public void release() {
try {

View File

@ -17,8 +17,9 @@ import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
* @author Steve Ebersole
*/
public interface ScriptSourceInput {
/**
* Prepare source for use.
* Prepare source for use, and log that this script is about to be imported.
*/
void prepare();